From 613f2bfdcec97daf980c770d7f4474c06b3967fe Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 10 Oct 2022 02:23:39 +0000 Subject: [PATCH] CodeGen from PR 20960 in Azure/azure-rest-api-specs Update readme.python.md (#20960) * Update readme.python.md * Update readme.python.md --- sdk/compute/azure-mgmt-compute/_meta.json | 4 +- .../compute/_compute_management_client.py | 93 +- .../compute/aio/_compute_management_client.py | 93 +- .../azure/mgmt/compute/models.py | 4 +- .../mgmt/compute/v2015_06_15/_version.py | 2 +- .../mgmt/compute/v2016_03_30/_version.py | 2 +- .../compute/v2016_04_30_preview/_version.py | 2 +- .../mgmt/compute/v2017_03_30/_version.py | 2 +- .../mgmt/compute/v2017_09_01/_version.py | 2 +- .../mgmt/compute/v2017_12_01/_version.py | 2 +- .../mgmt/compute/v2018_04_01/_version.py | 2 +- .../mgmt/compute/v2018_06_01/_version.py | 2 +- .../mgmt/compute/v2018_09_30/_version.py | 2 +- .../mgmt/compute/v2018_10_01/_version.py | 2 +- .../mgmt/compute/v2019_03_01/_version.py | 2 +- .../mgmt/compute/v2019_04_01/_version.py | 2 +- .../mgmt/compute/v2019_07_01/_version.py | 2 +- .../mgmt/compute/v2019_11_01/_version.py | 2 +- .../mgmt/compute/v2019_12_01/_version.py | 2 +- .../mgmt/compute/v2020_05_01/_version.py | 2 +- .../mgmt/compute/v2020_06_01/_version.py | 2 +- .../mgmt/compute/v2020_06_30/_version.py | 2 +- .../mgmt/compute/v2020_09_30/_version.py | 2 +- .../compute/v2020_10_01_preview/_version.py | 2 +- .../mgmt/compute/v2020_12_01/_version.py | 2 +- .../mgmt/compute/v2021_03_01/_version.py | 2 +- .../mgmt/compute/v2021_04_01/_version.py | 2 +- .../mgmt/compute/v2021_07_01/_version.py | 2 +- .../mgmt/compute/v2021_08_01/_version.py | 2 +- .../mgmt/compute/v2021_10_01/_version.py | 2 +- .../mgmt/compute/v2021_11_01/_version.py | 2 +- .../mgmt/compute/v2021_12_01/_version.py | 2 +- .../mgmt/compute/v2022_01_03/_version.py | 2 +- .../mgmt/compute/v2022_03_01/_version.py | 2 +- .../mgmt/compute/v2022_03_02/_version.py | 2 +- .../mgmt/compute/v2022_03_03/__init__.py | 24 + .../v2022_03_03/_compute_management_client.py | 170 + .../compute/v2022_03_03/_configuration.py | 70 + .../mgmt/compute/v2022_03_03/_metadata.json | 113 + .../azure/mgmt/compute/v2022_03_03/_patch.py | 20 + .../azure/mgmt/compute/v2022_03_03/_vendor.py | 27 + .../mgmt/compute/v2022_03_03/_version.py | 9 + .../mgmt/compute/v2022_03_03/aio/__init__.py | 21 + .../aio/_compute_management_client.py | 168 + .../compute/v2022_03_03/aio/_configuration.py | 67 + .../mgmt/compute/v2022_03_03/aio/_patch.py | 20 + .../v2022_03_03/aio/operations/__init__.py | 41 + .../_community_galleries_operations.py | 109 + ...unity_gallery_image_versions_operations.py | 213 + .../_community_gallery_images_operations.py | 199 + .../aio/operations/_galleries_operations.py | 819 ++++ ...gallery_application_versions_operations.py | 881 ++++ .../_gallery_applications_operations.py | 808 +++ .../_gallery_image_versions_operations.py | 877 ++++ .../operations/_gallery_images_operations.py | 797 +++ .../_gallery_sharing_profile_operations.py | 273 ++ .../v2022_03_03/aio/operations/_patch.py | 20 + .../_shared_galleries_operations.py | 194 + ...hared_gallery_image_versions_operations.py | 224 + .../_shared_gallery_images_operations.py | 207 + .../compute/v2022_03_03/models/__init__.py | 231 + .../_compute_management_client_enums.py | 207 + .../compute/v2022_03_03/models/_models_py3.py | 4334 +++++++++++++++++ .../mgmt/compute/v2022_03_03/models/_patch.py | 20 + .../v2022_03_03/operations/__init__.py | 41 + .../_community_galleries_operations.py | 141 + ...unity_gallery_image_versions_operations.py | 285 ++ .../_community_gallery_images_operations.py | 260 + .../operations/_galleries_operations.py | 1000 ++++ ...gallery_application_versions_operations.py | 1079 ++++ .../_gallery_applications_operations.py | 968 ++++ .../_gallery_image_versions_operations.py | 1067 ++++ .../operations/_gallery_images_operations.py | 957 ++++ .../_gallery_sharing_profile_operations.py | 307 ++ .../compute/v2022_03_03/operations/_patch.py | 20 + .../_shared_galleries_operations.py | 260 + ...hared_gallery_image_versions_operations.py | 304 ++ .../_shared_gallery_images_operations.py | 278 ++ .../azure/mgmt/compute/v2022_03_03/py.typed | 1 + .../mgmt/compute/v2022_04_04/_version.py | 2 +- .../mgmt/compute/v2022_07_02/__init__.py | 24 + .../v2022_07_02/_compute_management_client.py | 119 + .../compute/v2022_07_02/_configuration.py | 70 + .../mgmt/compute/v2022_07_02/_metadata.json | 106 + .../azure/mgmt/compute/v2022_07_02/_patch.py | 20 + .../azure/mgmt/compute/v2022_07_02/_vendor.py | 27 + .../mgmt/compute/v2022_07_02/_version.py | 9 + .../mgmt/compute/v2022_07_02/aio/__init__.py | 21 + .../aio/_compute_management_client.py | 116 + .../compute/v2022_07_02/aio/_configuration.py | 67 + .../mgmt/compute/v2022_07_02/aio/_patch.py | 20 + .../v2022_07_02/aio/operations/__init__.py | 27 + .../operations/_disk_accesses_operations.py | 1397 ++++++ .../_disk_encryption_sets_operations.py | 924 ++++ .../_disk_restore_point_operations.py | 598 +++ .../aio/operations/_disks_operations.py | 1139 +++++ .../v2022_07_02/aio/operations/_patch.py | 20 + .../aio/operations/_snapshots_operations.py | 1149 +++++ .../compute/v2022_07_02/models/__init__.py | 157 + .../_compute_management_client_enums.py | 254 + .../compute/v2022_07_02/models/_models_py3.py | 3117 ++++++++++++ .../mgmt/compute/v2022_07_02/models/_patch.py | 20 + .../v2022_07_02/operations/__init__.py | 27 + .../operations/_disk_accesses_operations.py | 1738 +++++++ .../_disk_encryption_sets_operations.py | 1117 +++++ .../_disk_restore_point_operations.py | 752 +++ .../operations/_disks_operations.py | 1356 ++++++ .../compute/v2022_07_02/operations/_patch.py | 20 + .../operations/_snapshots_operations.py | 1362 ++++++ .../azure/mgmt/compute/v2022_07_02/py.typed | 1 + .../mgmt/compute/v2022_08_01/_version.py | 2 +- 111 files changed, 34094 insertions(+), 71 deletions(-) create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_metadata.json create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_vendor.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_version.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_application_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_applications_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_sharing_profile_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_compute_management_client_enums.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_models_py3.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_application_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_applications_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_sharing_profile_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_galleries_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_image_versions_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_images_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/py.typed create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_metadata.json create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_vendor.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_version.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_accesses_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_encryption_sets_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_restore_point_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disks_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_snapshots_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_compute_management_client_enums.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_models_py3.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_accesses_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_encryption_sets_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_restore_point_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disks_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_snapshots_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/py.typed diff --git a/sdk/compute/azure-mgmt-compute/_meta.json b/sdk/compute/azure-mgmt-compute/_meta.json index e7f8718262fa..dbc9683be5be 100644 --- a/sdk/compute/azure-mgmt-compute/_meta.json +++ b/sdk/compute/azure-mgmt-compute/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@6.1.9", "@autorest/modelerfour@4.24.3" ], - "commit": "5263f0b2ead74031fa567da2700411743da26e7f", + "commit": "ec43f2e00321fd6f02aed7574a6163cc12fad213", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/compute/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.9 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/compute/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.9 --use=@autorest/modelerfour@4.24.3 --version=3.9.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/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py index d4623f032c81..64ab574aa9d3 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 @@ -63,24 +63,24 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'cloud_service_roles': '2022-04-04', 'cloud_services': '2022-04-04', 'cloud_services_update_domain': '2022-04-04', - 'community_galleries': '2022-01-03', - 'community_gallery_image_versions': '2022-01-03', - 'community_gallery_images': '2022-01-03', - 'disk_accesses': '2022-03-02', - 'disk_encryption_sets': '2022-03-02', - 'disk_restore_point': '2022-03-02', - 'disks': '2022-03-02', - 'galleries': '2022-01-03', - 'gallery_application_versions': '2022-01-03', - 'gallery_applications': '2022-01-03', - 'gallery_image_versions': '2022-01-03', - 'gallery_images': '2022-01-03', - 'gallery_sharing_profile': '2022-01-03', + 'community_galleries': '2022-03-03', + 'community_gallery_image_versions': '2022-03-03', + 'community_gallery_images': '2022-03-03', + 'disk_accesses': '2022-07-02', + 'disk_encryption_sets': '2022-07-02', + 'disk_restore_point': '2022-07-02', + 'disks': '2022-07-02', + 'galleries': '2022-03-03', + 'gallery_application_versions': '2022-03-03', + 'gallery_applications': '2022-03-03', + 'gallery_image_versions': '2022-03-03', + 'gallery_images': '2022-03-03', + 'gallery_sharing_profile': '2022-03-03', 'resource_skus': '2021-07-01', - 'shared_galleries': '2022-01-03', - 'shared_gallery_image_versions': '2022-01-03', - 'shared_gallery_images': '2022-01-03', - 'snapshots': '2022-03-02', + 'shared_galleries': '2022-03-03', + 'shared_gallery_image_versions': '2022-03-03', + 'shared_gallery_images': '2022-03-03', + 'snapshots': '2022-07-02', }}, _PROFILE_TAG + " latest" ) @@ -140,7 +140,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-01-03: :mod:`v2022_01_03.models` * 2022-03-01: :mod:`v2022_03_01.models` * 2022-03-02: :mod:`v2022_03_02.models` + * 2022-03-03: :mod:`v2022_03_03.models` * 2022-04-04: :mod:`v2022_04_04.models` + * 2022-07-02: :mod:`v2022_07_02.models` * 2022-08-01: :mod:`v2022_08_01.models` """ if api_version == '2015-06-15': @@ -236,9 +238,15 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-03-02': from .v2022_03_02 import models return models + elif api_version == '2022-03-03': + from .v2022_03_03 import models + return models elif api_version == '2022-04-04': from .v2022_04_04 import models return models + elif api_version == '2022-07-02': + from .v2022_07_02 import models + return models elif api_version == '2022-08-01': from .v2022_08_01 import models return models @@ -467,12 +475,15 @@ def community_galleries(self): * 2021-07-01: :class:`CommunityGalleriesOperations` * 2022-01-03: :class:`CommunityGalleriesOperations` + * 2022-03-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 == '2022-03-03': + from .v2022_03_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 @@ -484,12 +495,15 @@ def community_gallery_image_versions(self): * 2021-07-01: :class:`CommunityGalleryImageVersionsOperations` * 2022-01-03: :class:`CommunityGalleryImageVersionsOperations` + * 2022-03-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 == '2022-03-03': + from .v2022_03_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 @@ -501,12 +515,15 @@ def community_gallery_images(self): * 2021-07-01: :class:`CommunityGalleryImagesOperations` * 2022-01-03: :class:`CommunityGalleryImagesOperations` + * 2022-03-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 == '2022-03-03': + from .v2022_03_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 @@ -612,6 +629,7 @@ def disk_accesses(self): * 2021-08-01: :class:`DiskAccessesOperations` * 2021-12-01: :class:`DiskAccessesOperations` * 2022-03-02: :class:`DiskAccessesOperations` + * 2022-07-02: :class:`DiskAccessesOperations` """ api_version = self._get_api_version('disk_accesses') if api_version == '2020-05-01': @@ -630,6 +648,8 @@ def disk_accesses(self): from .v2021_12_01.operations import DiskAccessesOperations as OperationClass elif api_version == '2022-03-02': from .v2022_03_02.operations import DiskAccessesOperations as OperationClass + elif api_version == '2022-07-02': + from .v2022_07_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 @@ -649,6 +669,7 @@ def disk_encryption_sets(self): * 2021-08-01: :class:`DiskEncryptionSetsOperations` * 2021-12-01: :class:`DiskEncryptionSetsOperations` * 2022-03-02: :class:`DiskEncryptionSetsOperations` + * 2022-07-02: :class:`DiskEncryptionSetsOperations` """ api_version = self._get_api_version('disk_encryption_sets') if api_version == '2019-07-01': @@ -671,6 +692,8 @@ def disk_encryption_sets(self): from .v2021_12_01.operations import DiskEncryptionSetsOperations as OperationClass elif api_version == '2022-03-02': from .v2022_03_02.operations import DiskEncryptionSetsOperations as OperationClass + elif api_version == '2022-07-02': + from .v2022_07_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 @@ -686,6 +709,7 @@ def disk_restore_point(self): * 2021-08-01: :class:`DiskRestorePointOperations` * 2021-12-01: :class:`DiskRestorePointOperations` * 2022-03-02: :class:`DiskRestorePointOperations` + * 2022-07-02: :class:`DiskRestorePointOperations` """ api_version = self._get_api_version('disk_restore_point') if api_version == '2020-09-30': @@ -700,6 +724,8 @@ def disk_restore_point(self): from .v2021_12_01.operations import DiskRestorePointOperations as OperationClass elif api_version == '2022-03-02': from .v2022_03_02.operations import DiskRestorePointOperations as OperationClass + elif api_version == '2022-07-02': + from .v2022_07_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 @@ -725,6 +751,7 @@ def disks(self): * 2021-08-01: :class:`DisksOperations` * 2021-12-01: :class:`DisksOperations` * 2022-03-02: :class:`DisksOperations` + * 2022-07-02: :class:`DisksOperations` """ api_version = self._get_api_version('disks') if api_version == '2016-04-30-preview': @@ -759,6 +786,8 @@ def disks(self): from .v2021_12_01.operations import DisksOperations as OperationClass elif api_version == '2022-03-02': from .v2022_03_02.operations import DisksOperations as OperationClass + elif api_version == '2022-07-02': + from .v2022_07_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 @@ -776,6 +805,7 @@ def galleries(self): * 2021-07-01: :class:`GalleriesOperations` * 2021-10-01: :class:`GalleriesOperations` * 2022-01-03: :class:`GalleriesOperations` + * 2022-03-03: :class:`GalleriesOperations` """ api_version = self._get_api_version('galleries') if api_version == '2018-06-01': @@ -794,6 +824,8 @@ def galleries(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -810,6 +842,7 @@ def gallery_application_versions(self): * 2021-07-01: :class:`GalleryApplicationVersionsOperations` * 2021-10-01: :class:`GalleryApplicationVersionsOperations` * 2022-01-03: :class:`GalleryApplicationVersionsOperations` + * 2022-03-03: :class:`GalleryApplicationVersionsOperations` """ api_version = self._get_api_version('gallery_application_versions') if api_version == '2019-03-01': @@ -826,6 +859,8 @@ def gallery_application_versions(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -842,6 +877,7 @@ def gallery_applications(self): * 2021-07-01: :class:`GalleryApplicationsOperations` * 2021-10-01: :class:`GalleryApplicationsOperations` * 2022-01-03: :class:`GalleryApplicationsOperations` + * 2022-03-03: :class:`GalleryApplicationsOperations` """ api_version = self._get_api_version('gallery_applications') if api_version == '2019-03-01': @@ -858,6 +894,8 @@ def gallery_applications(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -875,6 +913,7 @@ def gallery_image_versions(self): * 2021-07-01: :class:`GalleryImageVersionsOperations` * 2021-10-01: :class:`GalleryImageVersionsOperations` * 2022-01-03: :class:`GalleryImageVersionsOperations` + * 2022-03-03: :class:`GalleryImageVersionsOperations` """ api_version = self._get_api_version('gallery_image_versions') if api_version == '2018-06-01': @@ -893,6 +932,8 @@ def gallery_image_versions(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -910,6 +951,7 @@ def gallery_images(self): * 2021-07-01: :class:`GalleryImagesOperations` * 2021-10-01: :class:`GalleryImagesOperations` * 2022-01-03: :class:`GalleryImagesOperations` + * 2022-03-03: :class:`GalleryImagesOperations` """ api_version = self._get_api_version('gallery_images') if api_version == '2018-06-01': @@ -928,6 +970,8 @@ def gallery_images(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -941,6 +985,7 @@ def gallery_sharing_profile(self): * 2021-07-01: :class:`GallerySharingProfileOperations` * 2021-10-01: :class:`GallerySharingProfileOperations` * 2022-01-03: :class:`GallerySharingProfileOperations` + * 2022-03-03: :class:`GallerySharingProfileOperations` """ api_version = self._get_api_version('gallery_sharing_profile') if api_version == '2020-09-30': @@ -951,6 +996,8 @@ def gallery_sharing_profile(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -1271,6 +1318,7 @@ def shared_galleries(self): * 2020-09-30: :class:`SharedGalleriesOperations` * 2021-07-01: :class:`SharedGalleriesOperations` * 2022-01-03: :class:`SharedGalleriesOperations` + * 2022-03-03: :class:`SharedGalleriesOperations` """ api_version = self._get_api_version('shared_galleries') if api_version == '2020-09-30': @@ -1279,6 +1327,8 @@ def shared_galleries(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -1291,6 +1341,7 @@ def shared_gallery_image_versions(self): * 2020-09-30: :class:`SharedGalleryImageVersionsOperations` * 2021-07-01: :class:`SharedGalleryImageVersionsOperations` * 2022-01-03: :class:`SharedGalleryImageVersionsOperations` + * 2022-03-03: :class:`SharedGalleryImageVersionsOperations` """ api_version = self._get_api_version('shared_gallery_image_versions') if api_version == '2020-09-30': @@ -1299,6 +1350,8 @@ def shared_gallery_image_versions(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -1311,6 +1364,7 @@ def shared_gallery_images(self): * 2020-09-30: :class:`SharedGalleryImagesOperations` * 2021-07-01: :class:`SharedGalleryImagesOperations` * 2022-01-03: :class:`SharedGalleryImagesOperations` + * 2022-03-03: :class:`SharedGalleryImagesOperations` """ api_version = self._get_api_version('shared_gallery_images') if api_version == '2020-09-30': @@ -1319,6 +1373,8 @@ def shared_gallery_images(self): 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 == '2022-03-03': + from .v2022_03_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 @@ -1344,6 +1400,7 @@ def snapshots(self): * 2021-08-01: :class:`SnapshotsOperations` * 2021-12-01: :class:`SnapshotsOperations` * 2022-03-02: :class:`SnapshotsOperations` + * 2022-07-02: :class:`SnapshotsOperations` """ api_version = self._get_api_version('snapshots') if api_version == '2016-04-30-preview': @@ -1378,6 +1435,8 @@ def snapshots(self): from .v2021_12_01.operations import SnapshotsOperations as OperationClass elif api_version == '2022-03-02': from .v2022_03_02.operations import SnapshotsOperations as OperationClass + elif api_version == '2022-07-02': + from .v2022_07_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 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 2bbb66951aee..5eddff3dd99e 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 @@ -63,24 +63,24 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'cloud_service_roles': '2022-04-04', 'cloud_services': '2022-04-04', 'cloud_services_update_domain': '2022-04-04', - 'community_galleries': '2022-01-03', - 'community_gallery_image_versions': '2022-01-03', - 'community_gallery_images': '2022-01-03', - 'disk_accesses': '2022-03-02', - 'disk_encryption_sets': '2022-03-02', - 'disk_restore_point': '2022-03-02', - 'disks': '2022-03-02', - 'galleries': '2022-01-03', - 'gallery_application_versions': '2022-01-03', - 'gallery_applications': '2022-01-03', - 'gallery_image_versions': '2022-01-03', - 'gallery_images': '2022-01-03', - 'gallery_sharing_profile': '2022-01-03', + 'community_galleries': '2022-03-03', + 'community_gallery_image_versions': '2022-03-03', + 'community_gallery_images': '2022-03-03', + 'disk_accesses': '2022-07-02', + 'disk_encryption_sets': '2022-07-02', + 'disk_restore_point': '2022-07-02', + 'disks': '2022-07-02', + 'galleries': '2022-03-03', + 'gallery_application_versions': '2022-03-03', + 'gallery_applications': '2022-03-03', + 'gallery_image_versions': '2022-03-03', + 'gallery_images': '2022-03-03', + 'gallery_sharing_profile': '2022-03-03', 'resource_skus': '2021-07-01', - 'shared_galleries': '2022-01-03', - 'shared_gallery_image_versions': '2022-01-03', - 'shared_gallery_images': '2022-01-03', - 'snapshots': '2022-03-02', + 'shared_galleries': '2022-03-03', + 'shared_gallery_image_versions': '2022-03-03', + 'shared_gallery_images': '2022-03-03', + 'snapshots': '2022-07-02', }}, _PROFILE_TAG + " latest" ) @@ -140,7 +140,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-01-03: :mod:`v2022_01_03.models` * 2022-03-01: :mod:`v2022_03_01.models` * 2022-03-02: :mod:`v2022_03_02.models` + * 2022-03-03: :mod:`v2022_03_03.models` * 2022-04-04: :mod:`v2022_04_04.models` + * 2022-07-02: :mod:`v2022_07_02.models` * 2022-08-01: :mod:`v2022_08_01.models` """ if api_version == '2015-06-15': @@ -236,9 +238,15 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-03-02': from ..v2022_03_02 import models return models + elif api_version == '2022-03-03': + from ..v2022_03_03 import models + return models elif api_version == '2022-04-04': from ..v2022_04_04 import models return models + elif api_version == '2022-07-02': + from ..v2022_07_02 import models + return models elif api_version == '2022-08-01': from ..v2022_08_01 import models return models @@ -467,12 +475,15 @@ def community_galleries(self): * 2021-07-01: :class:`CommunityGalleriesOperations` * 2022-01-03: :class:`CommunityGalleriesOperations` + * 2022-03-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 == '2022-03-03': + from ..v2022_03_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 @@ -484,12 +495,15 @@ def community_gallery_image_versions(self): * 2021-07-01: :class:`CommunityGalleryImageVersionsOperations` * 2022-01-03: :class:`CommunityGalleryImageVersionsOperations` + * 2022-03-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 == '2022-03-03': + from ..v2022_03_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 @@ -501,12 +515,15 @@ def community_gallery_images(self): * 2021-07-01: :class:`CommunityGalleryImagesOperations` * 2022-01-03: :class:`CommunityGalleryImagesOperations` + * 2022-03-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 == '2022-03-03': + from ..v2022_03_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 @@ -612,6 +629,7 @@ def disk_accesses(self): * 2021-08-01: :class:`DiskAccessesOperations` * 2021-12-01: :class:`DiskAccessesOperations` * 2022-03-02: :class:`DiskAccessesOperations` + * 2022-07-02: :class:`DiskAccessesOperations` """ api_version = self._get_api_version('disk_accesses') if api_version == '2020-05-01': @@ -630,6 +648,8 @@ def disk_accesses(self): from ..v2021_12_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 == '2022-07-02': + from ..v2022_07_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 @@ -649,6 +669,7 @@ def disk_encryption_sets(self): * 2021-08-01: :class:`DiskEncryptionSetsOperations` * 2021-12-01: :class:`DiskEncryptionSetsOperations` * 2022-03-02: :class:`DiskEncryptionSetsOperations` + * 2022-07-02: :class:`DiskEncryptionSetsOperations` """ api_version = self._get_api_version('disk_encryption_sets') if api_version == '2019-07-01': @@ -671,6 +692,8 @@ def disk_encryption_sets(self): from ..v2021_12_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 == '2022-07-02': + from ..v2022_07_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 @@ -686,6 +709,7 @@ def disk_restore_point(self): * 2021-08-01: :class:`DiskRestorePointOperations` * 2021-12-01: :class:`DiskRestorePointOperations` * 2022-03-02: :class:`DiskRestorePointOperations` + * 2022-07-02: :class:`DiskRestorePointOperations` """ api_version = self._get_api_version('disk_restore_point') if api_version == '2020-09-30': @@ -700,6 +724,8 @@ def disk_restore_point(self): from ..v2021_12_01.aio.operations import DiskRestorePointOperations as OperationClass elif api_version == '2022-03-02': from ..v2022_03_02.aio.operations import DiskRestorePointOperations as OperationClass + elif api_version == '2022-07-02': + from ..v2022_07_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 @@ -725,6 +751,7 @@ def disks(self): * 2021-08-01: :class:`DisksOperations` * 2021-12-01: :class:`DisksOperations` * 2022-03-02: :class:`DisksOperations` + * 2022-07-02: :class:`DisksOperations` """ api_version = self._get_api_version('disks') if api_version == '2016-04-30-preview': @@ -759,6 +786,8 @@ def disks(self): from ..v2021_12_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 == '2022-07-02': + from ..v2022_07_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 @@ -776,6 +805,7 @@ def galleries(self): * 2021-07-01: :class:`GalleriesOperations` * 2021-10-01: :class:`GalleriesOperations` * 2022-01-03: :class:`GalleriesOperations` + * 2022-03-03: :class:`GalleriesOperations` """ api_version = self._get_api_version('galleries') if api_version == '2018-06-01': @@ -794,6 +824,8 @@ def galleries(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -810,6 +842,7 @@ def gallery_application_versions(self): * 2021-07-01: :class:`GalleryApplicationVersionsOperations` * 2021-10-01: :class:`GalleryApplicationVersionsOperations` * 2022-01-03: :class:`GalleryApplicationVersionsOperations` + * 2022-03-03: :class:`GalleryApplicationVersionsOperations` """ api_version = self._get_api_version('gallery_application_versions') if api_version == '2019-03-01': @@ -826,6 +859,8 @@ def gallery_application_versions(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -842,6 +877,7 @@ def gallery_applications(self): * 2021-07-01: :class:`GalleryApplicationsOperations` * 2021-10-01: :class:`GalleryApplicationsOperations` * 2022-01-03: :class:`GalleryApplicationsOperations` + * 2022-03-03: :class:`GalleryApplicationsOperations` """ api_version = self._get_api_version('gallery_applications') if api_version == '2019-03-01': @@ -858,6 +894,8 @@ def gallery_applications(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -875,6 +913,7 @@ def gallery_image_versions(self): * 2021-07-01: :class:`GalleryImageVersionsOperations` * 2021-10-01: :class:`GalleryImageVersionsOperations` * 2022-01-03: :class:`GalleryImageVersionsOperations` + * 2022-03-03: :class:`GalleryImageVersionsOperations` """ api_version = self._get_api_version('gallery_image_versions') if api_version == '2018-06-01': @@ -893,6 +932,8 @@ def gallery_image_versions(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -910,6 +951,7 @@ def gallery_images(self): * 2021-07-01: :class:`GalleryImagesOperations` * 2021-10-01: :class:`GalleryImagesOperations` * 2022-01-03: :class:`GalleryImagesOperations` + * 2022-03-03: :class:`GalleryImagesOperations` """ api_version = self._get_api_version('gallery_images') if api_version == '2018-06-01': @@ -928,6 +970,8 @@ def gallery_images(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -941,6 +985,7 @@ def gallery_sharing_profile(self): * 2021-07-01: :class:`GallerySharingProfileOperations` * 2021-10-01: :class:`GallerySharingProfileOperations` * 2022-01-03: :class:`GallerySharingProfileOperations` + * 2022-03-03: :class:`GallerySharingProfileOperations` """ api_version = self._get_api_version('gallery_sharing_profile') if api_version == '2020-09-30': @@ -951,6 +996,8 @@ def gallery_sharing_profile(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -1271,6 +1318,7 @@ def shared_galleries(self): * 2020-09-30: :class:`SharedGalleriesOperations` * 2021-07-01: :class:`SharedGalleriesOperations` * 2022-01-03: :class:`SharedGalleriesOperations` + * 2022-03-03: :class:`SharedGalleriesOperations` """ api_version = self._get_api_version('shared_galleries') if api_version == '2020-09-30': @@ -1279,6 +1327,8 @@ def shared_galleries(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -1291,6 +1341,7 @@ def shared_gallery_image_versions(self): * 2020-09-30: :class:`SharedGalleryImageVersionsOperations` * 2021-07-01: :class:`SharedGalleryImageVersionsOperations` * 2022-01-03: :class:`SharedGalleryImageVersionsOperations` + * 2022-03-03: :class:`SharedGalleryImageVersionsOperations` """ api_version = self._get_api_version('shared_gallery_image_versions') if api_version == '2020-09-30': @@ -1299,6 +1350,8 @@ def shared_gallery_image_versions(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -1311,6 +1364,7 @@ def shared_gallery_images(self): * 2020-09-30: :class:`SharedGalleryImagesOperations` * 2021-07-01: :class:`SharedGalleryImagesOperations` * 2022-01-03: :class:`SharedGalleryImagesOperations` + * 2022-03-03: :class:`SharedGalleryImagesOperations` """ api_version = self._get_api_version('shared_gallery_images') if api_version == '2020-09-30': @@ -1319,6 +1373,8 @@ def shared_gallery_images(self): 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 == '2022-03-03': + from ..v2022_03_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 @@ -1344,6 +1400,7 @@ def snapshots(self): * 2021-08-01: :class:`SnapshotsOperations` * 2021-12-01: :class:`SnapshotsOperations` * 2022-03-02: :class:`SnapshotsOperations` + * 2022-07-02: :class:`SnapshotsOperations` """ api_version = self._get_api_version('snapshots') if api_version == '2016-04-30-preview': @@ -1378,6 +1435,8 @@ def snapshots(self): from ..v2021_12_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 == '2022-07-02': + from ..v2022_07_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py index 715530d2c40d..d830a2a180c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py @@ -5,7 +5,7 @@ # license information. # -------------------------------------------------------------------------- from .v2021_07_01.models import * -from .v2022_01_03.models import * -from .v2022_03_02.models import * +from .v2022_03_03.models import * from .v2022_04_04.models import * +from .v2022_07_02.models import * from .v2022_08_01.models import * diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/__init__.py new file mode 100644 index 000000000000..835f3211b3cd --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._compute_management_client import ComputeManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_compute_management_client.py new file mode 100644 index 000000000000..e7ea37e28043 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_compute_management_client.py @@ -0,0 +1,170 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._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: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Compute Client. + + :ivar galleries: GalleriesOperations operations + :vartype galleries: azure.mgmt.compute.v2022_03_03.operations.GalleriesOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.v2022_03_03.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: + azure.mgmt.compute.v2022_03_03.operations.GalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: + azure.mgmt.compute.v2022_03_03.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.v2022_03_03.operations.GalleryApplicationVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: + azure.mgmt.compute.v2022_03_03.operations.GallerySharingProfileOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: azure.mgmt.compute.v2022_03_03.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: + azure.mgmt.compute.v2022_03_03.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.v2022_03_03.operations.SharedGalleryImageVersionsOperations + :ivar community_galleries: CommunityGalleriesOperations operations + :vartype community_galleries: + azure.mgmt.compute.v2022_03_03.operations.CommunityGalleriesOperations + :ivar community_gallery_images: CommunityGalleryImagesOperations operations + :vartype community_gallery_images: + azure.mgmt.compute.v2022_03_03.operations.CommunityGalleryImagesOperations + :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations + :vartype community_gallery_image_versions: + azure.mgmt.compute.v2022_03_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 "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-03-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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **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) + 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 + ) + + def _send_request(self, request: HttpRequest, **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, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ComputeManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_configuration.py new file mode 100644 index 000000000000..d01841a7fb05 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_configuration.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ComputeManagementClientConfiguration(Configuration): # 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-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: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-03-03") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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_03/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_metadata.json new file mode 100644 index 000000000000..9af32c2ac69d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_metadata.json @@ -0,0 +1,113 @@ +{ + "chosen_version": "2022-03-03", + "total_api_version_list": ["2022-03-03"], + "client": { + "name": "ComputeManagementClient", + "filename": "_compute_management_client", + "description": "Compute Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "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 + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"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" + } +} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_03/_vendor.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/__init__.py new file mode 100644 index 000000000000..2351b55ffa1d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._compute_management_client import ComputeManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_compute_management_client.py new file mode 100644 index 000000000000..34cc2f1c05e8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_compute_management_client.py @@ -0,0 +1,168 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._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: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Compute Client. + + :ivar galleries: GalleriesOperations operations + :vartype galleries: azure.mgmt.compute.v2022_03_03.aio.operations.GalleriesOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.v2022_03_03.aio.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: + azure.mgmt.compute.v2022_03_03.aio.operations.GalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: + azure.mgmt.compute.v2022_03_03.aio.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.v2022_03_03.aio.operations.GalleryApplicationVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: + azure.mgmt.compute.v2022_03_03.aio.operations.GallerySharingProfileOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: + azure.mgmt.compute.v2022_03_03.aio.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: + azure.mgmt.compute.v2022_03_03.aio.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.v2022_03_03.aio.operations.SharedGalleryImageVersionsOperations + :ivar community_galleries: CommunityGalleriesOperations operations + :vartype community_galleries: + azure.mgmt.compute.v2022_03_03.aio.operations.CommunityGalleriesOperations + :ivar community_gallery_images: CommunityGalleryImagesOperations operations + :vartype community_gallery_images: + azure.mgmt.compute.v2022_03_03.aio.operations.CommunityGalleryImagesOperations + :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations + :vartype community_gallery_image_versions: + azure.mgmt.compute.v2022_03_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 "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-03-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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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) + 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 + ) + + def _send_request(self, request: HttpRequest, **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, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ComputeManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_configuration.py new file mode 100644 index 000000000000..aebb5d655c51 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ComputeManagementClientConfiguration(Configuration): # 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-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: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-03-03") # type: str + + 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._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") + 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_03/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_03/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/__init__.py new file mode 100644 index 000000000000..aa7e32324e0e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/__init__.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._galleries_operations import GalleriesOperations +from ._gallery_images_operations import GalleryImagesOperations +from ._gallery_image_versions_operations import GalleryImageVersionsOperations +from ._gallery_applications_operations import GalleryApplicationsOperations +from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations +from ._gallery_sharing_profile_operations import GallerySharingProfileOperations +from ._shared_galleries_operations import SharedGalleriesOperations +from ._shared_gallery_images_operations import SharedGalleryImagesOperations +from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations +from ._community_galleries_operations import CommunityGalleriesOperations +from ._community_gallery_images_operations import CommunityGalleryImagesOperations +from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_galleries_operations.py new file mode 100644 index 000000000000..5b434cf2db06 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_galleries_operations.py @@ -0,0 +1,109 @@ +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._community_galleries_operations import build_get_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`community_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGallery] + + request = build_get_request( + location=location, + public_gallery_name=public_gallery_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_image_versions_operations.py new file mode 100644 index 000000000000..732148135f74 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_image_versions_operations.py @@ -0,0 +1,213 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._community_gallery_image_versions_operations import build_get_request, build_list_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an image. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_images_operations.py new file mode 100644 index 000000000000..4ec84d73953b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_community_gallery_images_operations.py @@ -0,0 +1,199 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._community_gallery_images_operations import build_get_request, build_list_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}"} # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommunityGalleryImage"]: + """List community gallery images inside a gallery. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_galleries_operations.py new file mode 100644 index 000000000000..e2d5b265c74f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_galleries_operations.py @@ -0,0 +1,819 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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_03_03.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO], **kwargs: Any + ) -> _models.Gallery: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Gallery", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Gallery", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Gallery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], **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 model type or a IO type. Required. + :type gallery: ~azure.mgmt.compute.v2022_03_03.models.Gallery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Gallery", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.GalleryUpdate, IO], **kwargs: Any + ) -> _models.Gallery: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], **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 + model type or a IO type. Required. + :type gallery: ~azure.mgmt.compute.v2022_03_03.models.GalleryUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Gallery", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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.v2022_03_03.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.v2022_03_03.models.GalleryExpandParams + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.Gallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Gallery"]: + """List galleries under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Gallery"]: + """List galleries under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_application_versions_operations.py new file mode 100644 index 000000000000..367c6b47e8d9 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_application_versions_operations.py @@ -0,0 +1,881 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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], + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application_version, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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], + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application_version, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersionUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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. "ReplicationStatus" Default + value is None. + :type expand: str or ~azure.mgmt.compute.v2022_03_03.models.ReplicationStatusTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # type: ignore + + @distributed_trace + def list_by_gallery_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryApplicationVersion"]: + """List gallery Application Versions in a gallery Application Definition. + + :param resource_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryApplicationVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery_application.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_gallery_application.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_applications_operations.py new file mode 100644 index 000000000000..ebece0a4da8f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_applications_operations.py @@ -0,0 +1,808 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO], + **kwargs: Any + ) -> _models.GalleryApplication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplication or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, IO], + **kwargs: Any + ) -> _models.GalleryApplication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationUpdate or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryApplication or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + @distributed_trace + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryApplication"]: + """List gallery Application Definitions in a gallery. + + :param resource_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryApplication or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_gallery.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_image_versions_operations.py new file mode 100644 index 000000000000..fe9dea79e6fe --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_image_versions_operations.py @@ -0,0 +1,877 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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], + **kwargs: Any + ) -> _models.GalleryImageVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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], + **kwargs: Any + ) -> _models.GalleryImageVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionUpdate + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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. "ReplicationStatus" Default + value is None. + :type expand: str or ~azure.mgmt.compute.v2022_03_03.models.ReplicationStatusTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + @distributed_trace + def list_by_gallery_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryImageVersion"]: + """List gallery image versions in a gallery image definition. + + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery_image.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_gallery_image.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_images_operations.py new file mode 100644 index 000000000000..9bb6aa953e7c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_images_operations.py @@ -0,0 +1,797 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO], + **kwargs: Any + ) -> _models.GalleryImage: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryImage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImage", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO], + **kwargs: Any + ) -> _models.GalleryImage: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 + model type or a IO type. Required. + :type gallery_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImage", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + @distributed_trace + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryImage"]: + """List gallery image definitions in a gallery. + + :param resource_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_gallery.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_sharing_profile_operations.py new file mode 100644 index 000000000000..9889f73c0e29 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_gallery_sharing_profile_operations.py @@ -0,0 +1,273 @@ +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._gallery_sharing_profile_operations import build_update_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO], + **kwargs: Any + ) -> _models.SharingUpdate: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharingUpdate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sharing_update, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SharingUpdate", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("SharingUpdate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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], + **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 + model type or a IO type. Required. + :type sharing_update: ~azure.mgmt.compute.v2022_03_03.models.SharingUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharingUpdate] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharingUpdate", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_03/aio/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_galleries_operations.py new file mode 100644 index 000000000000..e032f1635695 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_galleries_operations.py @@ -0,0 +1,194 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._shared_galleries_operations import build_get_request, build_list_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> AsyncIterable["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. + + :param location: Resource location. Required. + :type location: str + :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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGallery or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGallery] + + request = build_get_request( + location=location, + gallery_unique_name=gallery_unique_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_image_versions_operations.py new file mode 100644 index 000000000000..7be6d7ecd1ad --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_image_versions_operations.py @@ -0,0 +1,224 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._shared_gallery_image_versions_operations import build_get_request, build_list_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + gallery_image_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions by subscription id or tenant id. + + :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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_images_operations.py new file mode 100644 index 000000000000..07f9d4f4f4ec --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/aio/operations/_shared_gallery_images_operations.py @@ -0,0 +1,207 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._shared_gallery_images_operations import build_get_request, build_list_request + +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.v2022_03_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> AsyncIterable["_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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/__init__.py new file mode 100644 index 000000000000..164dff985f0f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/__init__.py @@ -0,0 +1,231 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ApiError +from ._models_py3 import ApiErrorBase +from ._models_py3 import CommunityGallery +from ._models_py3 import CommunityGalleryImage +from ._models_py3 import CommunityGalleryImageList +from ._models_py3 import CommunityGalleryImageVersion +from ._models_py3 import CommunityGalleryImageVersionList +from ._models_py3 import CommunityGalleryInfo +from ._models_py3 import DataDiskImageEncryption +from ._models_py3 import Disallowed +from ._models_py3 import DiskImageEncryption +from ._models_py3 import EncryptionImages +from ._models_py3 import Gallery +from ._models_py3 import GalleryApplication +from ._models_py3 import GalleryApplicationCustomAction +from ._models_py3 import GalleryApplicationCustomActionParameter +from ._models_py3 import GalleryApplicationList +from ._models_py3 import GalleryApplicationUpdate +from ._models_py3 import GalleryApplicationVersion +from ._models_py3 import GalleryApplicationVersionList +from ._models_py3 import GalleryApplicationVersionPublishingProfile +from ._models_py3 import GalleryApplicationVersionSafetyProfile +from ._models_py3 import GalleryApplicationVersionUpdate +from ._models_py3 import GalleryArtifactPublishingProfileBase +from ._models_py3 import GalleryArtifactSafetyProfileBase +from ._models_py3 import GalleryArtifactSource +from ._models_py3 import GalleryArtifactVersionFullSource +from ._models_py3 import GalleryArtifactVersionSource +from ._models_py3 import GalleryDataDiskImage +from ._models_py3 import GalleryDiskImage +from ._models_py3 import GalleryDiskImageSource +from ._models_py3 import GalleryExtendedLocation +from ._models_py3 import GalleryIdentifier +from ._models_py3 import GalleryImage +from ._models_py3 import GalleryImageFeature +from ._models_py3 import GalleryImageIdentifier +from ._models_py3 import GalleryImageList +from ._models_py3 import GalleryImageUpdate +from ._models_py3 import GalleryImageVersion +from ._models_py3 import GalleryImageVersionList +from ._models_py3 import GalleryImageVersionPublishingProfile +from ._models_py3 import GalleryImageVersionSafetyProfile +from ._models_py3 import GalleryImageVersionStorageProfile +from ._models_py3 import GalleryImageVersionUpdate +from ._models_py3 import GalleryList +from ._models_py3 import GalleryOSDiskImage +from ._models_py3 import GalleryTargetExtendedLocation +from ._models_py3 import GalleryUpdate +from ._models_py3 import ImagePurchasePlan +from ._models_py3 import InnerError +from ._models_py3 import LatestGalleryImageVersion +from ._models_py3 import ManagedArtifact +from ._models_py3 import OSDiskImageEncryption +from ._models_py3 import OSDiskImageSecurityProfile +from ._models_py3 import PirCommunityGalleryResource +from ._models_py3 import PirResource +from ._models_py3 import PirSharedGalleryResource +from ._models_py3 import PolicyViolation +from ._models_py3 import RecommendedMachineConfiguration +from ._models_py3 import RegionalReplicationStatus +from ._models_py3 import RegionalSharingStatus +from ._models_py3 import ReplicationStatus +from ._models_py3 import Resource +from ._models_py3 import ResourceRange +from ._models_py3 import SharedGallery +from ._models_py3 import SharedGalleryDataDiskImage +from ._models_py3 import SharedGalleryDiskImage +from ._models_py3 import SharedGalleryImage +from ._models_py3 import SharedGalleryImageList +from ._models_py3 import SharedGalleryImageVersion +from ._models_py3 import SharedGalleryImageVersionList +from ._models_py3 import SharedGalleryImageVersionStorageProfile +from ._models_py3 import SharedGalleryList +from ._models_py3 import SharedGalleryOSDiskImage +from ._models_py3 import SharingProfile +from ._models_py3 import SharingProfileGroup +from ._models_py3 import SharingStatus +from ._models_py3 import SharingUpdate +from ._models_py3 import SoftDeletePolicy +from ._models_py3 import TargetRegion +from ._models_py3 import UpdateResourceDefinition +from ._models_py3 import UserArtifactManage +from ._models_py3 import UserArtifactSettings +from ._models_py3 import UserArtifactSource + +from ._compute_management_client_enums import AggregatedReplicationState +from ._compute_management_client_enums import Architecture +from ._compute_management_client_enums import ConfidentialVMEncryptionType +from ._compute_management_client_enums import GalleryApplicationCustomActionParameterType +from ._compute_management_client_enums import GalleryExpandParams +from ._compute_management_client_enums import GalleryExtendedLocationType +from ._compute_management_client_enums import GalleryProvisioningState +from ._compute_management_client_enums import GallerySharingPermissionTypes +from ._compute_management_client_enums import HostCaching +from ._compute_management_client_enums import HyperVGeneration +from ._compute_management_client_enums import OperatingSystemStateTypes +from ._compute_management_client_enums import OperatingSystemTypes +from ._compute_management_client_enums import PolicyViolationCategory +from ._compute_management_client_enums import ReplicationMode +from ._compute_management_client_enums import ReplicationState +from ._compute_management_client_enums import ReplicationStatusTypes +from ._compute_management_client_enums import SelectPermissions +from ._compute_management_client_enums import SharedGalleryHostCaching +from ._compute_management_client_enums import SharedToValues +from ._compute_management_client_enums import SharingProfileGroupTypes +from ._compute_management_client_enums import SharingState +from ._compute_management_client_enums import SharingUpdateOperationTypes +from ._compute_management_client_enums import StorageAccountType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApiError", + "ApiErrorBase", + "CommunityGallery", + "CommunityGalleryImage", + "CommunityGalleryImageList", + "CommunityGalleryImageVersion", + "CommunityGalleryImageVersionList", + "CommunityGalleryInfo", + "DataDiskImageEncryption", + "Disallowed", + "DiskImageEncryption", + "EncryptionImages", + "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", + "GalleryImageVersionUpdate", + "GalleryList", + "GalleryOSDiskImage", + "GalleryTargetExtendedLocation", + "GalleryUpdate", + "ImagePurchasePlan", + "InnerError", + "LatestGalleryImageVersion", + "ManagedArtifact", + "OSDiskImageEncryption", + "OSDiskImageSecurityProfile", + "PirCommunityGalleryResource", + "PirResource", + "PirSharedGalleryResource", + "PolicyViolation", + "RecommendedMachineConfiguration", + "RegionalReplicationStatus", + "RegionalSharingStatus", + "ReplicationStatus", + "Resource", + "ResourceRange", + "SharedGallery", + "SharedGalleryDataDiskImage", + "SharedGalleryDiskImage", + "SharedGalleryImage", + "SharedGalleryImageList", + "SharedGalleryImageVersion", + "SharedGalleryImageVersionList", + "SharedGalleryImageVersionStorageProfile", + "SharedGalleryList", + "SharedGalleryOSDiskImage", + "SharingProfile", + "SharingProfileGroup", + "SharingStatus", + "SharingUpdate", + "SoftDeletePolicy", + "TargetRegion", + "UpdateResourceDefinition", + "UserArtifactManage", + "UserArtifactSettings", + "UserArtifactSource", + "AggregatedReplicationState", + "Architecture", + "ConfidentialVMEncryptionType", + "GalleryApplicationCustomActionParameterType", + "GalleryExpandParams", + "GalleryExtendedLocationType", + "GalleryProvisioningState", + "GallerySharingPermissionTypes", + "HostCaching", + "HyperVGeneration", + "OperatingSystemStateTypes", + "OperatingSystemTypes", + "PolicyViolationCategory", + "ReplicationMode", + "ReplicationState", + "ReplicationStatusTypes", + "SelectPermissions", + "SharedGalleryHostCaching", + "SharedToValues", + "SharingProfileGroupTypes", + "SharingState", + "SharingUpdateOperationTypes", + "StorageAccountType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_compute_management_client_enums.py new file mode 100644 index 000000000000..0384ea6c9b6b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_compute_management_client_enums.py @@ -0,0 +1,207 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 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. :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 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" + + +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" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_models_py3.py new file mode 100644 index 000000000000..4914ea0f3cdb --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_models_py3.py @@ -0,0 +1,4334 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ApiError(_serialization.Model): + """Api error. + + :ivar details: The Api error details. + :vartype details: list[~azure.mgmt.compute.v2022_03_03.models.ApiErrorBase] + :ivar innererror: The Api inner error. + :vartype innererror: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :keyword details: The Api error details. + :paramtype details: list[~azure.mgmt.compute.v2022_03_03.models.ApiErrorBase] + :keyword innererror: The Api inner error. + :paramtype innererror: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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): + """ + :keyword unique_id: The unique id of this community gallery. + :paramtype unique_id: str + """ + super().__init__(**kwargs) + self.name = None + self.location = None + self.type = 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 + """ + + _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): + """ + :keyword unique_id: The unique id of this community gallery. + :paramtype unique_id: str + """ + super().__init__(unique_id=unique_id, **kwargs) + + +class CommunityGalleryImage(PirCommunityGalleryResource): # pylint: disable=too-many-instance-attributes + """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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.HyperVGeneration + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.v2022_03_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_03_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_03_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 + ): + """ + :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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.HyperVGeneration + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.v2022_03_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_03_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_03_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 Azure. + + :ivar value: A list of community gallery images. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of community gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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 Azure. + + :ivar value: A list of community gallery image versions. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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 + ): + """ + :keyword value: A list of community gallery image versions. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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 + ): + """ + :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 = None + self.public_names = 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): + """ + :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 Azure. + + :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): + """ + :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): + """ + :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_03_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_03_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 + ): + """ + :keyword os_disk_image: Contains encryption settings for an OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.v2022_03_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_03_03.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 Azure. + + :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): + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class Gallery(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_03_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_03_03.models.GalleryProvisioningState + :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. + :vartype sharing_profile: ~azure.mgmt.compute.v2022_03_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_03_03.models.SoftDeletePolicy + :ivar sharing_status: Sharing status of current gallery. + :vartype sharing_status: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.GalleryIdentifier + :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. + :paramtype sharing_profile: ~azure.mgmt.compute.v2022_03_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_03_03.models.SoftDeletePolicy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.description = description + self.identifier = identifier + self.provisioning_state = None + self.sharing_profile = sharing_profile + self.soft_delete_policy = soft_delete_policy + self.sharing_status = None + + +class GalleryApplication(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_03_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.v2022_03_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 + ): + """ + :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_03_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.v2022_03_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 Azure. + + :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.v2022_03_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 + ): + """ + :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.v2022_03_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 Azure. + + :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.v2022_03_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 + ): + """ + :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.v2022_03_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 Azure. + + :ivar value: A list of Gallery Applications. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of Gallery Applications. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class GalleryApplicationUpdate(UpdateResourceDefinition): # pylint: disable=too-many-instance-attributes + """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_03_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.v2022_03_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 + ): + """ + :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_03_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.v2022_03_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 Azure. + + :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_03_03.models.GalleryApplicationVersionPublishingProfile + :ivar safety_profile: The safety profile of the Gallery Application Version. + :vartype safety_profile: + ~azure.mgmt.compute.v2022_03_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.v2022_03_03.models.GalleryProvisioningState + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.GalleryApplicationVersionPublishingProfile + :keyword safety_profile: The safety profile of the Gallery Application Version. + :paramtype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersionSafetyProfile + """ + super().__init__(location=location, tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.safety_profile = safety_profile + self.provisioning_state = None + self.replication_status = None + + +class GalleryApplicationVersionList(_serialization.Model): + """The List Gallery Application version operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: A list of gallery Application Versions. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of gallery Application Versions. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_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.v2022_03_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_03_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_03_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 + ): + """ + :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_03_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.v2022_03_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_03_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_03_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 = 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=too-many-instance-attributes + """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 Azure. + + :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_03_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.v2022_03_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_03_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_03_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_03_03.models.UserArtifactSource + :ivar manage_actions: + :vartype manage_actions: ~azure.mgmt.compute.v2022_03_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_03_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.v2022_03_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 + ): + """ + :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_03_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.v2022_03_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_03_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_03_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_03_03.models.UserArtifactSource + :keyword manage_actions: + :paramtype manage_actions: ~azure.mgmt.compute.v2022_03_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_03_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.v2022_03_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): + """ + :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 + """ + + _attribute_map = { + "allow_deletion_of_replicated_locations": {"key": "allowDeletionOfReplicatedLocations", "type": "bool"}, + } + + def __init__(self, *, allow_deletion_of_replicated_locations: Optional[bool] = None, **kwargs): + """ + :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) + + +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_03_03.models.GalleryApplicationVersionPublishingProfile + :ivar safety_profile: The safety profile of the Gallery Application Version. + :vartype safety_profile: + ~azure.mgmt.compute.v2022_03_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.v2022_03_03.models.GalleryProvisioningState + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.GalleryApplicationVersionPublishingProfile + :keyword safety_profile: The safety profile of the Gallery Application Version. + :paramtype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersionSafetyProfile + """ + super().__init__(tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.safety_profile = safety_profile + self.provisioning_state = None + self.replication_status = None + + +class GalleryArtifactSource(_serialization.Model): + """The source image from which the Image Version is going to be created. + + All required parameters must be populated in order to send to Azure. + + :ivar managed_image: The managed artifact. Required. + :vartype managed_image: ~azure.mgmt.compute.v2022_03_03.models.ManagedArtifact + """ + + _validation = { + "managed_image": {"required": True}, + } + + _attribute_map = { + "managed_image": {"key": "managedImage", "type": "ManagedArtifact"}, + } + + def __init__(self, *, managed_image: "_models.ManagedArtifact", **kwargs): + """ + :keyword managed_image: The managed artifact. Required. + :paramtype managed_image: ~azure.mgmt.compute.v2022_03_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 + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :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 + """ + 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. Can specify a disk uri, snapshot uri, + user image or storage account resource. + :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 + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + community_gallery_image_id: Optional[str] = None, + **kwargs + ): + """ + :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 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 + """ + super().__init__(id=id, **kwargs) + self.community_gallery_image_id = community_gallery_image_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.v2022_03_03.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.HostCaching + :keyword source: The source for the disk image. + :paramtype source: ~azure.mgmt.compute.v2022_03_03.models.GalleryDiskImageSource + """ + super().__init__(**kwargs) + self.size_in_gb = 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 Azure. + + :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_03_03.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.HostCaching + :keyword source: The source for the disk image. + :paramtype source: ~azure.mgmt.compute.v2022_03_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. 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 + :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 + ): + """ + :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 + :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.v2022_03_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 + ): + """ + :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_03_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): + """ """ + super().__init__(**kwargs) + self.unique_name = None + + +class GalleryImage(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_03_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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.v2022_03_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_03_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_03_03.models.GalleryProvisioningState + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.ImagePurchasePlan + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.v2022_03_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_03_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 = 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): + """ + :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 Azure. + + :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): + """ + :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 Azure. + + :ivar value: A list of Shared Image Gallery images. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of Shared Image Gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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): # pylint: disable=too-many-instance-attributes + """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_03_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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.v2022_03_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_03_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_03_03.models.GalleryProvisioningState + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.ImagePurchasePlan + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.v2022_03_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_03_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 = 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 Azure. + + :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_03_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_03_03.models.GalleryProvisioningState + :ivar storage_profile: This is the storage profile of a Gallery Image Version. + :vartype storage_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionStorageProfile + :ivar safety_profile: This is the safety profile of the Gallery Image Version. + :vartype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionSafetyProfile + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.v2022_03_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"}, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, + "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, + safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, + **kwargs + ): + """ + :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_03_03.models.GalleryImageVersionPublishingProfile + :keyword storage_profile: This is the storage profile of a Gallery Image Version. + :paramtype storage_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionStorageProfile + :keyword safety_profile: This is the safety profile of the Gallery Image Version. + :paramtype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionSafetyProfile + """ + super().__init__(location=location, tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.provisioning_state = None + self.storage_profile = storage_profile + self.safety_profile = safety_profile + self.replication_status = None + + +class GalleryImageVersionList(_serialization.Model): + """The List Gallery Image version operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: A list of gallery image versions. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of gallery image versions. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_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.v2022_03_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_03_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_03_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 + ): + """ + :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_03_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.v2022_03_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_03_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_03_03.models.GalleryTargetExtendedLocation] + """ + 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 + ) + + +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.v2022_03_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): + """ + :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 = None + self.policy_violations = 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.v2022_03_03.models.GalleryArtifactVersionFullSource + :ivar os_disk_image: This is the OS disk image. + :vartype os_disk_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryOSDiskImage + :ivar data_disk_images: A list of data disk images. + :vartype data_disk_images: list[~azure.mgmt.compute.v2022_03_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 + ): + """ + :keyword source: The source of the gallery artifact version. + :paramtype source: ~azure.mgmt.compute.v2022_03_03.models.GalleryArtifactVersionFullSource + :keyword os_disk_image: This is the OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryOSDiskImage + :keyword data_disk_images: A list of data disk images. + :paramtype data_disk_images: list[~azure.mgmt.compute.v2022_03_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_03_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_03_03.models.GalleryProvisioningState + :ivar storage_profile: This is the storage profile of a Gallery Image Version. + :vartype storage_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionStorageProfile + :ivar safety_profile: This is the safety profile of the Gallery Image Version. + :vartype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionSafetyProfile + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.v2022_03_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"}, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, + "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, + safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, + **kwargs + ): + """ + :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_03_03.models.GalleryImageVersionPublishingProfile + :keyword storage_profile: This is the storage profile of a Gallery Image Version. + :paramtype storage_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionStorageProfile + :keyword safety_profile: This is the safety profile of the Gallery Image Version. + :paramtype safety_profile: + ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionSafetyProfile + """ + super().__init__(tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.provisioning_state = None + self.storage_profile = storage_profile + self.safety_profile = safety_profile + self.replication_status = None + + +class GalleryList(_serialization.Model): + """The List Galleries operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: A list of galleries. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of galleries. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_03.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.HostCaching + :keyword source: The source for the disk image. + :paramtype source: ~azure.mgmt.compute.v2022_03_03.models.GalleryDiskImageSource + """ + super().__init__(host_caching=host_caching, source=source, **kwargs) + + +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_03_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", and + "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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", and + "Premium_LRS". + :paramtype storage_account_type: str or + ~azure.mgmt.compute.v2022_03_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_03_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_03_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_03_03.models.GalleryProvisioningState + :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. + :vartype sharing_profile: ~azure.mgmt.compute.v2022_03_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_03_03.models.SoftDeletePolicy + :ivar sharing_status: Sharing status of current gallery. + :vartype sharing_status: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.GalleryIdentifier + :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. + :paramtype sharing_profile: ~azure.mgmt.compute.v2022_03_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_03_03.models.SoftDeletePolicy + """ + super().__init__(tags=tags, **kwargs) + self.description = description + self.identifier = identifier + self.provisioning_state = None + self.sharing_profile = sharing_profile + self.soft_delete_policy = soft_delete_policy + self.sharing_status = 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 + ): + """ + :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): + """ + :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): + """ + :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 Azure. + + :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): # 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_03_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 + ): + """ + :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_03_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_03_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 + ): + """ + :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_03_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): + """ """ + super().__init__(**kwargs) + self.name = None + self.location = 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): + """ + :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.v2022_03_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 + ): + """ + :keyword category: Describes the nature of the policy violation. Known values are: "Other", + "ImageFlaggedUnsafe", "CopyrightValidation", and "IpTheft". + :paramtype category: str or ~azure.mgmt.compute.v2022_03_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.v2022_03_03.models.ResourceRange + :ivar memory: Describes the resource range. + :vartype memory: ~azure.mgmt.compute.v2022_03_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 + ): + """ + :keyword v_cp_us: Describes the resource range. + :paramtype v_cp_us: ~azure.mgmt.compute.v2022_03_03.models.ResourceRange + :keyword memory: Describes the resource range. + :paramtype memory: ~azure.mgmt.compute.v2022_03_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_03_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): + """ """ + super().__init__(**kwargs) + self.region = None + self.state = None + self.details = None + self.progress = 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_03_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): + """ + :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 = 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_03_03.models.AggregatedReplicationState + :ivar summary: This is a summary of replication status for each region. + :vartype summary: list[~azure.mgmt.compute.v2022_03_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): + """ """ + super().__init__(**kwargs) + self.aggregated_state = None + self.summary = 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 + ): + """ + :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 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 + """ + + _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): + """ + :keyword unique_id: The unique id of this shared gallery. + :paramtype unique_id: str + """ + super().__init__(unique_id=unique_id, **kwargs) + + +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_03_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): + """ + :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_03_03.models.SharedGalleryHostCaching + """ + super().__init__(**kwargs) + self.disk_size_gb = 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 Azure. + + :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_03_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 + ): + """ + :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_03_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): # pylint: disable=too-many-instance-attributes + """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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.HyperVGeneration + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.v2022_03_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_03_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_03_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}, + } + + _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"}, + } + + 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 + ): + """ + :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_03_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_03_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_03_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_03_03.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.v2022_03_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_03_03.models.HyperVGeneration + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.v2022_03_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_03_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_03_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 SharedGalleryImageList(_serialization.Model): + """The List Shared Gallery Images operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: A list of shared gallery images. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of shared gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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 Azure. + + :ivar value: A list of shared gallery images versions. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of shared gallery images versions. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_03.models.SharedGalleryOSDiskImage + :ivar data_disk_images: A list of data disk images. + :vartype data_disk_images: + list[~azure.mgmt.compute.v2022_03_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 + ): + """ + :keyword os_disk_image: This is the OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.v2022_03_03.models.SharedGalleryOSDiskImage + :keyword data_disk_images: A list of data disk images. + :paramtype data_disk_images: + list[~azure.mgmt.compute.v2022_03_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 Azure. + + :ivar value: A list of shared galleries. Required. + :vartype value: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword value: A list of shared galleries. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_03_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_03_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): + """ + :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_03_03.models.SharedGalleryHostCaching + """ + super().__init__(host_caching=host_caching, **kwargs) + + +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_03_03.models.GallerySharingPermissionTypes + :ivar groups: A list of sharing profile groups. + :vartype groups: list[~azure.mgmt.compute.v2022_03_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_03_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 + ): + """ + :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_03_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_03_03.models.CommunityGalleryInfo + """ + super().__init__(**kwargs) + self.permissions = permissions + self.groups = 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_03_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 + ): + """ + :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_03_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_03_03.models.SharingState + :ivar summary: Summary of all regional sharing status. + :vartype summary: list[~azure.mgmt.compute.v2022_03_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): + """ + :keyword summary: Summary of all regional sharing status. + :paramtype summary: list[~azure.mgmt.compute.v2022_03_03.models.RegionalSharingStatus] + """ + super().__init__(**kwargs) + self.aggregated_state = 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 Azure. + + :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_03_03.models.SharingUpdateOperationTypes + :ivar groups: A list of sharing profile groups. + :vartype groups: list[~azure.mgmt.compute.v2022_03_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 + ): + """ + :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_03_03.models.SharingUpdateOperationTypes + :keyword groups: A list of sharing profile groups. + :paramtype groups: list[~azure.mgmt.compute.v2022_03_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): + """ + :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 Azure. + + :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.v2022_03_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_03_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 + ): + """ + :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.v2022_03_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_03_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 UserArtifactManage(_serialization.Model): + """UserArtifactManage. + + All required parameters must be populated in order to send to Azure. + + :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): + """ + :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): + """ + :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 Azure. + + :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): + """ + :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/v2022_03_03/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_03/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/__init__.py new file mode 100644 index 000000000000..aa7e32324e0e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/__init__.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._galleries_operations import GalleriesOperations +from ._gallery_images_operations import GalleryImagesOperations +from ._gallery_image_versions_operations import GalleryImageVersionsOperations +from ._gallery_applications_operations import GalleryApplicationsOperations +from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations +from ._gallery_sharing_profile_operations import GallerySharingProfileOperations +from ._shared_galleries_operations import SharedGalleriesOperations +from ._shared_gallery_images_operations import SharedGalleryImagesOperations +from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations +from ._community_galleries_operations import CommunityGalleriesOperations +from ._community_gallery_images_operations import CommunityGalleryImagesOperations +from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_galleries_operations.py new file mode 100644 index 000000000000..5de3ad7e27b9 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_galleries_operations.py @@ -0,0 +1,141 @@ +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`community_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGallery] + + request = build_get_request( + location=location, + public_gallery_name=public_gallery_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_image_versions_operations.py new file mode 100644 index 000000000000..6a1d6f39e184 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_image_versions_operations.py @@ -0,0 +1,285 @@ +# 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, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> Iterable["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an image. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_images_operations.py new file mode 100644 index 000000000000..a452d6366546 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_community_gallery_images_operations.py @@ -0,0 +1,260 @@ +# 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, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunityGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}"} # type: ignore + + @distributed_trace + def list(self, location: str, public_gallery_name: str, **kwargs: Any) -> Iterable["_models.CommunityGalleryImage"]: + """List community gallery images inside a gallery. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.CommunityGalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommunityGalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_galleries_operations.py new file mode 100644 index 000000000000..a3402d09ad89 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_galleries_operations.py @@ -0,0 +1,1000 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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_03_03.ComputeManagementClient`'s + :attr:`galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO], **kwargs: Any + ) -> _models.Gallery: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Gallery", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Gallery", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Gallery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], **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 model type or a IO type. Required. + :type gallery: ~azure.mgmt.compute.v2022_03_03.models.Gallery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Gallery", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.GalleryUpdate, IO], **kwargs: Any + ) -> _models.Gallery: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], **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 + model type or a IO type. Required. + :type gallery: ~azure.mgmt.compute.v2022_03_03.models.GalleryUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Gallery", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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.v2022_03_03.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.v2022_03_03.models.GalleryExpandParams + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.Gallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Gallery] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gallery"]: + """List galleries under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Gallery"]: + """List galleries under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_application_versions_operations.py new file mode 100644 index 000000000000..0460dacebc5e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_application_versions_operations.py @@ -0,0 +1,1079 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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], + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application_version, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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], + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application_version, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersionUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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. "ReplicationStatus" Default + value is None. + :type expand: str or ~azure.mgmt.compute.v2022_03_03.models.ReplicationStatusTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}"} # type: ignore + + @distributed_trace + def list_by_gallery_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryApplicationVersion"]: + """List gallery Application Versions in a gallery Application Definition. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Application Gallery in which the Application + Definition resides. Required. + :type gallery_name: str + :param gallery_application_name: The name of the Shared Application Gallery Application + Definition from which the Application Versions are to be listed. Required. + :type gallery_application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryApplicationVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery_application.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_gallery_application.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_applications_operations.py new file mode 100644 index 000000000000..e89020ad2ae1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_applications_operations.py @@ -0,0 +1,968 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO], + **kwargs: Any + ) -> _models.GalleryApplication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryApplication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplication or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, IO], + **kwargs: Any + ) -> _models.GalleryApplication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_application: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplicationUpdate or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryApplication or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryApplication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplication] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"} # type: ignore + + @distributed_trace + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryApplication"]: + """List gallery Application Definitions in a gallery. + + :param resource_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryApplication or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryApplicationList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_gallery.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_image_versions_operations.py new file mode 100644 index 000000000000..ac5ff769800e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_image_versions_operations.py @@ -0,0 +1,1067 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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], + **kwargs: Any + ) -> _models.GalleryImageVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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], + **kwargs: Any + ) -> _models.GalleryImageVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersionUpdate + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImageVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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. "ReplicationStatus" Default + value is None. + :type expand: str or ~azure.mgmt.compute.v2022_03_03.models.ReplicationStatusTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore + + @distributed_trace + def list_by_gallery_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryImageVersion"]: + """List gallery image versions in a gallery image definition. + + :param resource_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery_image.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_gallery_image.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_images_operations.py new file mode 100644 index 000000000000..5bf3d175c354 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_images_operations.py @@ -0,0 +1,957 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO], + **kwargs: Any + ) -> _models.GalleryImage: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("GalleryImage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 model type or a IO type. Required. + :type gallery_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryImage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImage", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO], + **kwargs: Any + ) -> _models.GalleryImage: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 + model type or a IO type. Required. + :type gallery_image: ~azure.mgmt.compute.v2022_03_03.models.GalleryImageUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImage", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.GalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}"} # type: ignore + + @distributed_trace + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryImage"]: + """List gallery image definitions in a gallery. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery from which Image Definitions are to + be listed. Required. + :type gallery_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GalleryImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_gallery.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_gallery.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_sharing_profile_operations.py new file mode 100644 index 000000000000..eb1b6b3fdb8b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_gallery_sharing_profile_operations.py @@ -0,0 +1,307 @@ +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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.v2022_03_03.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO], + **kwargs: Any + ) -> _models.SharingUpdate: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharingUpdate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sharing_update, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SharingUpdate", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("SharingUpdate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share"} # 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_03_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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], + **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 + model type or a IO type. Required. + :type sharing_update: ~azure.mgmt.compute.v2022_03_03.models.SharingUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharingUpdate] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharingUpdate", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_03/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_galleries_operations.py new file mode 100644 index 000000000000..950816bcaf09 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_galleries_operations.py @@ -0,0 +1,260 @@ +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> Iterable["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. + + :param location: Resource location. Required. + :type location: str + :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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGallery] + + request = build_get_request( + location=location, + gallery_unique_name=gallery_unique_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_image_versions_operations.py new file mode 100644 index 000000000000..e64feadfabe0 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_image_versions_operations.py @@ -0,0 +1,304 @@ +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + 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}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + gallery_image_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> Iterable["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions by subscription id or tenant id. + + :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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageVersionList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageVersion] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_images_operations.py new file mode 100644 index 000000000000..2d758462656c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/operations/_shared_gallery_images_operations.py @@ -0,0 +1,278 @@ +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_03_03.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> Iterable["_models.SharedGalleryImage"]: + """List shared gallery images by subscription id or tenant id. + + :param location: Resource location. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :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.v2022_03_03.models.SharedToValues + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImageList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_03_03.models.SharedGalleryImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedGalleryImage] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_03/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/__init__.py new file mode 100644 index 000000000000..835f3211b3cd --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._compute_management_client import ComputeManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_compute_management_client.py new file mode 100644 index 000000000000..f17d8f793eab --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_compute_management_client.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import ComputeManagementClientConfiguration +from .operations import ( + DiskAccessesOperations, + DiskEncryptionSetsOperations, + DiskRestorePointOperations, + DisksOperations, + SnapshotsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword + """Compute Client. + + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.v2022_07_02.operations.DisksOperations + :ivar disk_accesses: DiskAccessesOperations operations + :vartype disk_accesses: azure.mgmt.compute.v2022_07_02.operations.DiskAccessesOperations + :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations + :vartype disk_encryption_sets: + azure.mgmt.compute.v2022_07_02.operations.DiskEncryptionSetsOperations + :ivar disk_restore_point: DiskRestorePointOperations operations + :vartype disk_restore_point: + azure.mgmt.compute.v2022_07_02.operations.DiskRestorePointOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.v2022_07_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 "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **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) + 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) + + def _send_request(self, request: HttpRequest, **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, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ComputeManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_configuration.py new file mode 100644 index 000000000000..082bd39d5c3c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_configuration.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ComputeManagementClientConfiguration(Configuration): # 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-07-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: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-07-02") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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_07_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_metadata.json new file mode 100644 index 000000000000..e0fd1031417e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "2022-07-02", + "total_api_version_list": ["2022-07-02"], + "client": { + "name": "ComputeManagementClient", + "filename": "_compute_management_client", + "description": "Compute Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "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 + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "disks": "DisksOperations", + "disk_accesses": "DiskAccessesOperations", + "disk_encryption_sets": "DiskEncryptionSetsOperations", + "disk_restore_point": "DiskRestorePointOperations", + "snapshots": "SnapshotsOperations" + } +} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_07_02/_vendor.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/__init__.py new file mode 100644 index 000000000000..2351b55ffa1d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._compute_management_client import ComputeManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_compute_management_client.py new file mode 100644 index 000000000000..94f132ae1feb --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_compute_management_client.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import ComputeManagementClientConfiguration +from .operations import ( + DiskAccessesOperations, + DiskEncryptionSetsOperations, + DiskRestorePointOperations, + DisksOperations, + SnapshotsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword + """Compute Client. + + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.v2022_07_02.aio.operations.DisksOperations + :ivar disk_accesses: DiskAccessesOperations operations + :vartype disk_accesses: azure.mgmt.compute.v2022_07_02.aio.operations.DiskAccessesOperations + :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations + :vartype disk_encryption_sets: + azure.mgmt.compute.v2022_07_02.aio.operations.DiskEncryptionSetsOperations + :ivar disk_restore_point: DiskRestorePointOperations operations + :vartype disk_restore_point: + azure.mgmt.compute.v2022_07_02.aio.operations.DiskRestorePointOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.v2022_07_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 "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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) + 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) + + def _send_request(self, request: HttpRequest, **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, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ComputeManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_configuration.py new file mode 100644 index 000000000000..37e73c404b6a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ComputeManagementClientConfiguration(Configuration): # 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-07-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: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-07-02") # type: str + + 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._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") + 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_07_02/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_07_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/__init__.py new file mode 100644 index 000000000000..b013687c8bd2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._disks_operations import DisksOperations +from ._disk_accesses_operations import DiskAccessesOperations +from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations +from ._disk_restore_point_operations import DiskRestorePointOperations +from ._snapshots_operations import SnapshotsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_accesses_operations.py new file mode 100644 index 000000000000..1d3c1430808a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_accesses_operations.py @@ -0,0 +1,1397 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_07_02.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, disk_access_name: str, disk_access: Union[_models.DiskAccess, IO], **kwargs: Any + ) -> _models.DiskAccess: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type or a IO type. Required. + :type disk_access: ~azure.mgmt.compute.v2022_07_02.models.DiskAccess or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskAccess", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO], + **kwargs: Any + ) -> _models.DiskAccess: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_access: ~azure.mgmt.compute.v2022_07_02.models.DiskAccessUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskAccess", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskAccess or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: + """Lists all the disk access resources under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccessList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: + """Lists all the disk access resources under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccessList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + 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, + template_url=self.get_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources"} # type: ignore + + async def _update_a_private_endpoint_connection_initial( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, 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, + template_url=self._update_a_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_a_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def begin_update_a_private_endpoint_connection( + 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **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 model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + 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, + template_url=self.get_a_private_endpoint_connection.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_a_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_a_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace_async + async def begin_delete_a_private_endpoint_connection( + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_private_endpoint_connections.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_encryption_sets_operations.py new file mode 100644 index 000000000000..5d35359ef6b3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_encryption_sets_operations.py @@ -0,0 +1,924 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_07_02.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO], + **kwargs: Any + ) -> _models.DiskEncryptionSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO], + **kwargs: Any + ) -> _models.DiskEncryptionSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSetUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSetList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSetList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets"} # type: ignore + + @distributed_trace + def list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> AsyncIterable[str]: + """Lists all resources that are encrypted with this disk encryption set. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUriList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_associated_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_associated_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_restore_point_operations.py new file mode 100644 index 000000000000..97308bc996e6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disk_restore_point_operations.py @@ -0,0 +1,598 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +from ...operations._disk_restore_point_operations import ( + build_get_request, + build_grant_access_request, + build_list_by_restore_point_request, + build_revoke_access_request, +) + +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.v2022_07_02.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskRestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskRestorePoint] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}"} # type: ignore + + @distributed_trace + def list_by_restore_point( + self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DiskRestorePoint"]: + """Lists diskRestorePoints under a vmRestorePoint. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskRestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskRestorePointList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_restore_point.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_restore_point.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints"} # 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], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess"} # type: ignore + + async def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disks_operations.py new file mode 100644 index 000000000000..866e5b35237c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_disks_operations.py @@ -0,0 +1,1139 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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_07_02.aio.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO], **kwargs: Any + ) -> _models.Disk: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Disk", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Disk", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type + or a IO type. Required. + :type disk: ~azure.mgmt.compute.v2022_07_02.models.Disk or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO], **kwargs: Any + ) -> _models.Disk: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Disk", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Disk", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], **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 model + type or a IO type. Required. + :type disk: ~azure.mgmt.compute.v2022_07_02.models.DiskUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Disk or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.Disk + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + request = build_get_request( + resource_group_name=resource_group_name, + disk_name=disk_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Disk"]: + """Lists all the disks under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Disk"]: + """Lists all the disks under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks"} # type: ignore + + async def _grant_access_initial( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess"} # type: ignore + + async def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_07_02/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_snapshots_operations.py new file mode 100644 index 000000000000..d4c266f38a11 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/aio/operations/_snapshots_operations.py @@ -0,0 +1,1149 @@ +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import 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 ..._vendor import _convert_request +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, +) + +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.v2022_07_02.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO], **kwargs: Any + ) -> _models.Snapshot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], **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 + model type or a IO type. Required. + :type snapshot: ~azure.mgmt.compute.v2022_07_02.models.Snapshot or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.SnapshotUpdate, IO], **kwargs: Any + ) -> _models.Snapshot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type or a IO type. Required. + :type snapshot: ~azure.mgmt.compute.v2022_07_02.models.SnapshotUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + request = build_get_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, snapshot_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: + """Lists snapshots under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SnapshotList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: + """Lists snapshots under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SnapshotList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots"} # type: ignore + + async def _grant_access_initial( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, IO], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess"} # type: ignore + + async def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, snapshot_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/__init__.py new file mode 100644 index 000000000000..a961d211432f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/__init__.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AccessUri +from ._models_py3 import ApiError +from ._models_py3 import ApiErrorBase +from ._models_py3 import CopyCompletionError +from ._models_py3 import CreationData +from ._models_py3 import Disk +from ._models_py3 import DiskAccess +from ._models_py3 import DiskAccessList +from ._models_py3 import DiskAccessUpdate +from ._models_py3 import DiskEncryptionSet +from ._models_py3 import DiskEncryptionSetList +from ._models_py3 import DiskEncryptionSetUpdate +from ._models_py3 import DiskList +from ._models_py3 import DiskRestorePoint +from ._models_py3 import DiskRestorePointList +from ._models_py3 import DiskSecurityProfile +from ._models_py3 import DiskSku +from ._models_py3 import DiskUpdate +from ._models_py3 import Encryption +from ._models_py3 import EncryptionSetIdentity +from ._models_py3 import EncryptionSettingsCollection +from ._models_py3 import EncryptionSettingsElement +from ._models_py3 import ExtendedLocation +from ._models_py3 import GrantAccessData +from ._models_py3 import ImageDiskReference +from ._models_py3 import InnerError +from ._models_py3 import KeyForDiskEncryptionSet +from ._models_py3 import KeyVaultAndKeyReference +from ._models_py3 import KeyVaultAndSecretReference +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import PropertyUpdatesInProgress +from ._models_py3 import ProxyOnlyResource +from ._models_py3 import PurchasePlan +from ._models_py3 import Resource +from ._models_py3 import ResourceUriList +from ._models_py3 import ResourceWithOptionalLocation +from ._models_py3 import ShareInfoElement +from ._models_py3 import Snapshot +from ._models_py3 import SnapshotList +from ._models_py3 import SnapshotSku +from ._models_py3 import SnapshotUpdate +from ._models_py3 import SourceVault +from ._models_py3 import SubResource +from ._models_py3 import SubResourceReadOnly +from ._models_py3 import SupportedCapabilities +from ._models_py3 import UserAssignedIdentitiesValue + +from ._compute_management_client_enums import AccessLevel +from ._compute_management_client_enums import Architecture +from ._compute_management_client_enums import CopyCompletionErrorReason +from ._compute_management_client_enums import DataAccessAuthMode +from ._compute_management_client_enums import DiskCreateOption +from ._compute_management_client_enums import DiskEncryptionSetIdentityType +from ._compute_management_client_enums import DiskEncryptionSetType +from ._compute_management_client_enums import DiskSecurityTypes +from ._compute_management_client_enums import DiskState +from ._compute_management_client_enums import DiskStorageAccountTypes +from ._compute_management_client_enums import EncryptionType +from ._compute_management_client_enums import ExtendedLocationTypes +from ._compute_management_client_enums import HyperVGeneration +from ._compute_management_client_enums import NetworkAccessPolicy +from ._compute_management_client_enums import OperatingSystemTypes +from ._compute_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._compute_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._compute_management_client_enums import PublicNetworkAccess +from ._compute_management_client_enums import SnapshotStorageAccountTypes +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_compute_management_client_enums.py new file mode 100644 index 000000000000..d7aa998d84b8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_compute_management_client_enums.py @@ -0,0 +1,254 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: Indicates that the source snapshot was deleted while the background copy of the resource + #: created via CopyStart operation was in progress. + COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" + + +class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" + + #: 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. + AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" + #: No additional authentication would be performed when accessing export/upload URL. + NONE = "None" + + +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This enumerates the possible sources of a disk's creation.""" + + #: Create an empty data disk of a size given by diskSizeGB. + EMPTY = "Empty" + #: Disk will be attached to a VM. + ATTACH = "Attach" + #: Create a new disk from a platform image specified by the given imageReference or + #: galleryImageReference. + FROM_IMAGE = "FromImage" + #: Create a disk by importing from a blob specified by a sourceUri in a storage account specified + #: by storageAccountId. + IMPORT = "Import" + #: Create a new disk or snapshot by copying from a disk or snapshot specified by the given + #: sourceResourceId. + COPY = "Copy" + #: Create a new disk by copying from a backup recovery point. + RESTORE = "Restore" + #: Create a new disk by obtaining a write token and using it to directly upload the contents of + #: the disk. + UPLOAD = "Upload" + #: 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. + COPY_START = "CopyStart" + #: 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 + IMPORT_SECURE = "ImportSecure" + #: 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 + UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" + + +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.""" + + #: 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_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" + #: 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. + ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" + #: Confidential VM supported disk and VM guest state would be encrypted with customer managed key. + CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" + + +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the SecurityType of the VM. Applicable for OS disks only.""" + + #: Trusted Launch provides security features such as secure boot and virtual Trusted Platform + #: Module (vTPM) + TRUSTED_LAUNCH = "TrustedLaunch" + #: Indicates Confidential VM disk with only VM guest state encrypted + CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( + "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" + ) + #: Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform + #: managed key + CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" + #: Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer + #: managed key + CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" + + +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This enumerates the possible state of the disk.""" + + #: The disk is not being used and can be attached to a VM. + UNATTACHED = "Unattached" + #: The disk is currently attached to a running VM. + ATTACHED = "Attached" + #: The disk is attached to a stopped-deallocated VM. + RESERVED = "Reserved" + #: The disk is attached to a VM which is in hibernated state. + FROZEN = "Frozen" + #: The disk currently has an Active SAS Uri associated with it. + ACTIVE_SAS = "ActiveSAS" + #: The disk is attached to a VM in hibernated state and has an active SAS URI associated with it. + ACTIVE_SAS_FROZEN = "ActiveSASFrozen" + #: A disk is ready to be created by upload by requesting a write token. + READY_TO_UPLOAD = "ReadyToUpload" + #: A disk is created for upload and a write token has been issued for uploading to it. + ACTIVE_UPLOAD = "ActiveUpload" + + +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku name.""" + + #: Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access. + STANDARD_LRS = "Standard_LRS" + #: Premium SSD locally redundant storage. Best for production and performance sensitive workloads. + PREMIUM_LRS = "Premium_LRS" + #: Standard SSD locally redundant storage. Best for web servers, lightly used enterprise + #: applications and dev/test. + STANDARD_SSD_LRS = "StandardSSD_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. + ULTRA_SSD_LRS = "UltraSSD_LRS" + #: Premium SSD zone redundant storage. Best for the production workloads that need storage + #: resiliency against zone failures. + PREMIUM_ZRS = "Premium_ZRS" + #: Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications + #: and dev/test that need storage resiliency against zone failures. + STANDARD_SSD_ZRS = "StandardSSD_ZRS" + #: Premium SSD v2 locally redundant storage. Best for production and performance-sensitive + #: workloads that consistently require low latency and high IOPS and throughput. + PREMIUM_V2_LRS = "PremiumV2_LRS" + + +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of key used to encrypt the data of the disk.""" + + #: 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_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" + #: Disk is encrypted at rest with Customer managed key that can be changed and revoked by a + #: customer. + ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" + #: Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and + #: the other key is Platform managed. + ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" + + +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.""" + + #: The disk can be exported or uploaded to from any network. + ALLOW_ALL = "AllowAll" + #: The disk can be exported or uploaded to using a DiskAccess resource's private endpoints. + ALLOW_PRIVATE = "AllowPrivate" + #: The disk cannot be exported. + DENY_ALL = "DenyAll" + + +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.""" + + #: 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. + ENABLED = "Enabled" + #: 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. + DISABLED = "Disabled" + + +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku name.""" + + #: Standard HDD locally redundant storage + STANDARD_LRS = "Standard_LRS" + #: Premium SSD locally redundant storage + PREMIUM_LRS = "Premium_LRS" + #: Standard zone redundant storage + STANDARD_ZRS = "Standard_ZRS" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_models_py3.py new file mode 100644 index 000000000000..f423c09c8cb4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_models_py3.py @@ -0,0 +1,3117 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + 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): + """ """ + super().__init__(**kwargs) + self.access_sas = None + self.security_data_access_sas = None + + +class ApiError(_serialization.Model): + """Api error. + + :ivar details: The Api error details. + :vartype details: list[~azure.mgmt.compute.v2022_07_02.models.ApiErrorBase] + :ivar innererror: The Api inner error. + :vartype innererror: ~azure.mgmt.compute.v2022_07_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 + ): + """ + :keyword details: The Api error details. + :paramtype details: list[~azure.mgmt.compute.v2022_07_02.models.ApiErrorBase] + :keyword innererror: The Api inner error. + :paramtype innererror: ~azure.mgmt.compute.v2022_07_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 + ): + """ + :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 Azure. + + :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_07_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): + """ + :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_07_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): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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", and "UploadPreparedSecure". + :vartype create_option: str or ~azure.mgmt.compute.v2022_07_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_07_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_07_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 + """ + + _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"}, + } + + 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, + **kwargs + ): + """ + :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", and "UploadPreparedSecure". + :paramtype create_option: str or ~azure.mgmt.compute.v2022_07_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_07_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_07_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 + """ + 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 = 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 + + +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 Azure. + + :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): + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class Disk(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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.v2022_07_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_07_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_07_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_07_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 = { + "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}, + } + + _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"}, + } + + 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 + ): + """ + :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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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 = None + self.managed_by_extended = None + self.sku = sku + self.zones = zones + self.extended_location = extended_location + self.time_created = 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 = None + self.unique_id = None + self.encryption_settings_collection = encryption_settings_collection + self.provisioning_state = 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 = None + self.encryption = encryption + self.max_shares = max_shares + self.share_info = None + self.network_access_policy = network_access_policy + self.disk_access_id = disk_access_id + self.bursting_enabled_time = None + self.tier = tier + self.bursting_enabled = bursting_enabled + self.property_updates_in_progress = 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 + + +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 Azure. + + :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_07_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_07_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 + ): + """ + :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_07_02.models.ExtendedLocation + """ + super().__init__(location=location, tags=tags, **kwargs) + self.extended_location = extended_location + self.private_endpoint_connections = None + self.provisioning_state = None + self.time_created = None + + +class DiskAccessList(_serialization.Model): + """The List disk access operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: A list of disk access resources. Required. + :vartype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword value: A list of disk access resources. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class DiskEncryptionSet(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_07_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_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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 = None + self.provisioning_state = None + self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled + self.last_key_rotation_timestamp = None + self.auto_key_rotation_error = 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 Azure. + + :ivar value: A list of disk encryption sets. Required. + :vartype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword value: A list of disk encryption sets. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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 Azure. + + :ivar value: A list of disks. Required. + :vartype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword value: A list of disks. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class DiskRestorePoint(ProxyOnlyResource): # pylint: disable=too-many-instance-attributes + """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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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_07_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_07_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_07_02.models.DiskSecurityProfile + """ + super().__init__(**kwargs) + self.time_created = None + self.source_resource_id = None + self.os_type = None + self.hyper_v_generation = hyper_v_generation + self.purchase_plan = purchase_plan + self.supported_capabilities = supported_capabilities + self.family_id = None + self.source_unique_id = None + self.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 = None + self.source_resource_location = 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 Azure. + + :ivar value: A list of disk restore points. Required. + :vartype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword value: A list of disk restore points. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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_07_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 + ): + """ + :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_07_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_07_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): + """ + :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_07_02.models.DiskStorageAccountTypes + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class DiskUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes + """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_07_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_07_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_07_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_07_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_07_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_07_02.models.PurchasePlan + :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. + :vartype supported_capabilities: ~azure.mgmt.compute.v2022_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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_07_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_07_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_07_02.models.PurchasePlan + :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. + :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_07_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_07_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_07_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 = 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.v2022_07_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 + ): + """ + :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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_02.models.UserAssignedIdentitiesValue] + """ + super().__init__(**kwargs) + self.type = type + self.principal_id = None + self.tenant_id = 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 Azure. + + :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_07_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 + ): + """ + :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_07_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_07_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_07_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 + ): + """ + :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. + :paramtype disk_encryption_key: + ~azure.mgmt.compute.v2022_07_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_07_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_07_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 + ): + """ + :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_07_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 Azure. + + :ivar access: Required. Known values are: "None", "Read", and "Write". + :vartype access: str or ~azure.mgmt.compute.v2022_07_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 + ): + """ + :keyword access: Required. Known values are: "None", "Read", and "Write". + :paramtype access: str or ~azure.mgmt.compute.v2022_07_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 + ): + """ + :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): + """ + :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 Azure. + + :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_07_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): + """ + :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_07_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 Azure. + + :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. + :vartype source_vault: ~azure.mgmt.compute.v2022_07_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): + """ + :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. + :paramtype source_vault: ~azure.mgmt.compute.v2022_07_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 Azure. + + :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. + :vartype source_vault: ~azure.mgmt.compute.v2022_07_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): + """ + :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. + :paramtype source_vault: ~azure.mgmt.compute.v2022_07_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): + """ """ + super().__init__(**kwargs) + self.id = 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_07_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_07_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_07_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 + ): + """ + :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_07_02.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.private_endpoint = None + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.compute.v2022_07_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 + ): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword required_zone_names: The private link resource DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.group_id = None + self.required_members = 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_07_02.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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_07_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 + ): + """ + :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_07_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): + """ + :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 Azure. + + :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): + """ + :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 Azure. + + :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): + """ + :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): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.location = location + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class 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): + """ """ + super().__init__(**kwargs) + self.vm_uri = None + + +class Snapshot(Resource): # pylint: disable=too-many-instance-attributes + """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 Azure. + + :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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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.v2022_07_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_07_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_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_02.models.DataAccessAuthMode + """ + super().__init__(location=location, tags=tags, **kwargs) + self.managed_by = None + self.sku = sku + self.extended_location = extended_location + self.time_created = 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 = None + self.disk_state = None + self.unique_id = None + self.encryption_settings_collection = encryption_settings_collection + self.provisioning_state = None + self.incremental = incremental + self.incremental_snapshot_family_id = 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 Azure. + + :ivar value: A list of snapshots. Required. + :vartype value: list[~azure.mgmt.compute.v2022_07_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): + """ + :keyword value: A list of snapshots. Required. + :paramtype value: list[~azure.mgmt.compute.v2022_07_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_07_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): + """ + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and + "Standard_ZRS". + :paramtype name: str or ~azure.mgmt.compute.v2022_07_02.models.SnapshotStorageAccountTypes + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class SnapshotUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes + """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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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 + ): + """ + :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_07_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_07_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_07_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_07_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_07_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_07_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_07_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_07_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): # 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): # 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): + """ """ + super().__init__(**kwargs) + self.id = 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.v2022_07_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 + ): + """ + :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.v2022_07_02.models.Architecture + """ + super().__init__(**kwargs) + self.disk_controller_types = disk_controller_types + 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): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_07_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/__init__.py new file mode 100644 index 000000000000..b013687c8bd2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/__init__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._disks_operations import DisksOperations +from ._disk_accesses_operations import DiskAccessesOperations +from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations +from ._disk_restore_point_operations import DiskRestorePointOperations +from ._snapshots_operations import SnapshotsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-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__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_accesses_operations.py new file mode 100644 index 000000000000..f31e7f35a26a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_accesses_operations.py @@ -0,0 +1,1738 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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( + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_07_02.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, resource_group_name: str, disk_access_name: str, disk_access: Union[_models.DiskAccess, IO], **kwargs: Any + ) -> _models.DiskAccess: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type or a IO type. Required. + :type disk_access: ~azure.mgmt.compute.v2022_07_02.models.DiskAccess or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskAccess", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO], + **kwargs: Any + ) -> _models.DiskAccess: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_access: ~azure.mgmt.compute.v2022_07_02.models.DiskAccessUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskAccess", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskAccess or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccess] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskAccess"]: + """Lists all the disk access resources under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccessList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.DiskAccess"]: + """Lists all the disk access resources under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskAccessList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + 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, + template_url=self.get_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources"} # type: ignore + + def _update_a_private_endpoint_connection_initial( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, 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, + template_url=self._update_a_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_a_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + def begin_update_a_private_endpoint_connection( + 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **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 model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + 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, + template_url=self.get_a_private_endpoint_connection.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_a_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_a_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace + def begin_delete_a_private_endpoint_connection( + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_a_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_private_endpoint_connections.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_encryption_sets_operations.py new file mode 100644 index 000000000000..e43c303fcee4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_encryption_sets_operations.py @@ -0,0 +1,1117 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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.v2022_07_02.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO], + **kwargs: Any + ) -> _models.DiskEncryptionSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO], + **kwargs: Any + ) -> _models.DiskEncryptionSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSetUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSet] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSetList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskEncryptionSetList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets"} # type: ignore + + @distributed_trace + def list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> Iterable[str]: + """Lists all resources that are encrypted with this disk encryption set. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceUriList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_associated_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_associated_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_restore_point_operations.py new file mode 100644 index 000000000000..805cd18be916 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disk_restore_point_operations.py @@ -0,0 +1,752 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "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 = _format_url_section(_url, **path_format_arguments) + + # 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.v2022_07_02.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.DiskRestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskRestorePoint] + + 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, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}"} # type: ignore + + @distributed_trace + def list_by_restore_point( + self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any + ) -> Iterable["_models.DiskRestorePoint"]: + """Lists diskRestorePoints under a vmRestorePoint. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.DiskRestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskRestorePointList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_restore_point.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_restore_point.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints"} # 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], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess"} # type: ignore + + def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disks_operations.py new file mode 100644 index 000000000000..de82a17de3b4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_disks_operations.py @@ -0,0 +1,1356 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) # pylint: disable=line-too-long + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_07_02.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO], **kwargs: Any + ) -> _models.Disk: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Disk", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Disk", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type + or a IO type. Required. + :type disk: ~azure.mgmt.compute.v2022_07_02.models.Disk or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO], **kwargs: Any + ) -> _models.Disk: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Disk", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Disk", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], **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 model + type or a IO type. Required. + :type disk: ~azure.mgmt.compute.v2022_07_02.models.DiskUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Disk or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.Disk + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Disk] + + request = build_get_request( + resource_group_name=resource_group_name, + disk_name=disk_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Disk"]: + """Lists all the disks under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Disk"]: + """Lists all the disks under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiskList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks"} # type: ignore + + def _grant_access_initial( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess"} # type: ignore + + def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, disk_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_07_02/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_snapshots_operations.py new file mode 100644 index 000000000000..e5f7a0d14c58 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/operations/_snapshots_operations.py @@ -0,0 +1,1362 @@ +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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.v2022_07_02.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO], **kwargs: Any + ) -> _models.Snapshot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IO, 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, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], **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 + model type or a IO type. Required. + :type snapshot: ~azure.mgmt.compute.v2022_07_02.models.Snapshot or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.SnapshotUpdate, IO], **kwargs: Any + ) -> _models.Snapshot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IO, 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, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Snapshot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], **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 model type or a IO type. Required. + :type snapshot: ~azure.mgmt.compute.v2022_07_02.models.SnapshotUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_07_02.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Snapshot] + + request = build_get_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, snapshot_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Snapshot"]: + """Lists snapshots under a resource group. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SnapshotList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Snapshot"]: + """Lists snapshots under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_07_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SnapshotList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots"} # type: ignore + + def _grant_access_initial( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, IO], + **kwargs: Any + ) -> Optional[_models.AccessUri]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AccessUri]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(grant_access_data, (IO, 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, + template_url=self._grant_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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("AccessUri", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _grant_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess"} # 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_07_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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], + **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 model type or a IO type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2022_07_02.models.GrantAccessData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_07_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessUri] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._grant_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessUri", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_grant_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess"} # type: ignore + + def _revoke_access_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, snapshot_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, + template_url=self._revoke_access_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + _revoke_access_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._revoke_access_initial( # type: ignore + 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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_revoke_access.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_07_02/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_08_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_08_01/_version.py index 7ffb089b6925..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_08_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "28.0.1" +VERSION = "1.0.0b1"