From d380fa36992b5e183898d0f0fea79289f0153ace Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 30 Oct 2024 02:41:58 +0000 Subject: [PATCH 1/2] code and test --- .../azure-mgmt-extendedlocation/CHANGELOG.md | 19 + .../azure-mgmt-extendedlocation/README.md | 12 +- .../azure-mgmt-extendedlocation/_meta.json | 10 +- .../azure/mgmt/extendedlocation/__init__.py | 18 +- .../mgmt/extendedlocation/_configuration.py | 58 +- .../extendedlocation/_custom_locations.py | 174 +- .../{v2021_03_15_preview => }/_patch.py | 0 .../mgmt/extendedlocation/_serialization.py | 128 +- .../azure/mgmt/extendedlocation/_version.py | 7 +- .../mgmt/extendedlocation/aio/__init__.py | 15 +- .../extendedlocation/aio/_configuration.py | 58 +- .../extendedlocation/aio/_custom_locations.py | 174 +- .../{v2021_03_15_preview => }/aio/_patch.py | 0 .../aio/operations/__init__.py | 0 .../_custom_locations_operations.py | 377 ++--- .../aio/operations/_patch.py | 0 .../azure/mgmt/extendedlocation/models.py | 7 - .../{v2021_08_15 => }/models/__init__.py | 0 .../models/_custom_locations_enums.py | 0 .../{v2021_08_15 => }/models/_models_py3.py | 100 +- .../models/_patch.py | 0 .../operations/__init__.py | 0 .../_custom_locations_operations.py | 400 ++--- .../operations/_patch.py | 0 .../v2021_03_15_preview/__init__.py | 26 - .../v2021_03_15_preview/_configuration.py | 72 - .../v2021_03_15_preview/_custom_locations.py | 92 -- .../v2021_03_15_preview/_metadata.json | 110 -- .../v2021_03_15_preview/_vendor.py | 30 - .../v2021_03_15_preview/_version.py | 9 - .../v2021_03_15_preview/aio/__init__.py | 23 - .../v2021_03_15_preview/aio/_configuration.py | 72 - .../aio/_custom_locations.py | 92 -- .../_custom_locations_operations.py | 968 ----------- .../v2021_03_15_preview/models/__init__.py | 53 - .../models/_custom_locations_enums.py | 25 - .../v2021_03_15_preview/models/_models_py3.py | 775 --------- .../_custom_locations_operations.py | 1252 -------------- .../v2021_03_15_preview/py.typed | 1 - .../extendedlocation/v2021_08_15/__init__.py | 26 - .../v2021_08_15/_configuration.py | 72 - .../v2021_08_15/_custom_locations.py | 92 -- .../v2021_08_15/_metadata.json | 110 -- .../extendedlocation/v2021_08_15/_patch.py | 20 - .../extendedlocation/v2021_08_15/_vendor.py | 30 - .../extendedlocation/v2021_08_15/_version.py | 9 - .../v2021_08_15/aio/__init__.py | 23 - .../v2021_08_15/aio/_configuration.py | 72 - .../v2021_08_15/aio/_custom_locations.py | 92 -- .../v2021_08_15/aio/_patch.py | 20 - .../v2021_08_15/aio/operations/__init__.py | 19 - .../v2021_08_15/aio/operations/_patch.py | 20 - .../v2021_08_15/models/_patch.py | 20 - .../v2021_08_15/operations/__init__.py | 19 - .../v2021_08_15/operations/_patch.py | 20 - .../extendedlocation/v2021_08_15/py.typed | 1 - .../v2021_08_31_preview/__init__.py | 26 - .../v2021_08_31_preview/_configuration.py | 72 - .../v2021_08_31_preview/_custom_locations.py | 98 -- .../v2021_08_31_preview/_metadata.json | 111 -- .../v2021_08_31_preview/_patch.py | 20 - .../v2021_08_31_preview/_vendor.py | 30 - .../v2021_08_31_preview/_version.py | 9 - .../v2021_08_31_preview/aio/__init__.py | 23 - .../v2021_08_31_preview/aio/_configuration.py | 72 - .../aio/_custom_locations.py | 98 -- .../v2021_08_31_preview/aio/_patch.py | 20 - .../aio/operations/__init__.py | 21 - .../_custom_locations_operations.py | 1137 ------------- .../aio/operations/_patch.py | 20 - .../_resource_sync_rules_operations.py | 748 --------- .../v2021_08_31_preview/models/__init__.py | 71 - .../models/_custom_locations_enums.py | 32 - .../v2021_08_31_preview/models/_models_py3.py | 1188 ------------- .../v2021_08_31_preview/models/_patch.py | 20 - .../operations/__init__.py | 21 - .../_custom_locations_operations.py | 1465 ----------------- .../v2021_08_31_preview/operations/_patch.py | 20 - .../_resource_sync_rules_operations.py | 990 ----------- .../v2021_08_31_preview/py.typed | 1 - .../custom_locations_create_update.py | 1 + .../custom_locations_delete.py | 4 +- .../generated_samples/custom_locations_get.py | 1 + ...custom_locations_list_by_resource_group.py | 1 + .../custom_locations_list_by_subscription.py | 1 + ...m_locations_list_enabled_resource_types.py | 1 + .../custom_locations_list_operations.py | 1 + .../custom_locations_patch.py | 1 + .../generated_tests/conftest.py | 35 + ...m_locations_custom_locations_operations.py | 133 ++ ...tions_custom_locations_operations_async.py | 138 ++ .../sdk_packaging.toml | 2 +- .../azure-mgmt-extendedlocation/setup.py | 86 +- 93 files changed, 1046 insertions(+), 11494 deletions(-) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/_patch.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/aio/_patch.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/aio/operations/__init__.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_08_15 => }/aio/operations/_custom_locations_operations.py (70%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/aio/operations/_patch.py (100%) delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models.py rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_08_15 => }/models/__init__.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_08_15 => }/models/_custom_locations_enums.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_08_15 => }/models/_models_py3.py (90%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/models/_patch.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/operations/__init__.py (100%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_08_15 => }/operations/_custom_locations_operations.py (73%) rename sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/{v2021_03_15_preview => }/operations/_patch.py (100%) delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_metadata.json delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_vendor.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_version.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_custom_locations_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_custom_locations_enums.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_models_py3.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_custom_locations_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/py.typed delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_metadata.json delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_vendor.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_version.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/py.typed delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_metadata.json delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_vendor.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_version.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_configuration.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_custom_locations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_custom_locations_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_resource_sync_rules_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_custom_locations_enums.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_models_py3.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/__init__.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_custom_locations_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_patch.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_resource_sync_rules_operations.py delete mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/py.typed create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/conftest.py create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations.py create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations_async.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md b/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md index 71437b748d5b..55aa5eafe078 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md @@ -1,5 +1,24 @@ # Release History +## 2.0.0 (2024-10-30) + +### Features Added + + - Method `CustomLocationsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, resource_name: str, parameters: CustomLocation, content_type: str)` + - Method `CustomLocationsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, resource_name: str, parameters: IO[bytes], content_type: str)` + +### Breaking Changes + + - Model `CustomLocations` deleted or renamed its instance variable `resource_sync_rules` + - Deleted or renamed model `CustomLocationFindTargetResourceGroupProperties` + - Deleted or renamed model `CustomLocationFindTargetResourceGroupResult` + - Deleted or renamed model `MatchExpressionsProperties` + - Deleted or renamed model `PatchableResourceSyncRule` + - Deleted or renamed model `ResourceSyncRule` + - Deleted or renamed model `ResourceSyncRulePropertiesSelector` + - Deleted or renamed method `CustomLocationsOperations.find_target_resource_group` + - Deleted or renamed model `ResourceSyncRulesOperations` + ## 1.2.0b1 (2023-02-14) ### Other Changes diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/README.md b/sdk/extendedlocation/azure-mgmt-extendedlocation/README.md index 97f95c444452..4bde593828b3 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/README.md +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Extended Location Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -45,8 +45,9 @@ client = CustomLocations(credential=DefaultAzureCredential(), subscription_id=su ## Examples - -Code samples for this package can be found at [Extended Location Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +Code samples for this package can be found at: +- [Search Extended Location Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) ## Troubleshooting @@ -58,6 +59,3 @@ Code samples for this package can be found at [Extended Location Management](htt If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-extendedlocation%2FREADME.png) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/_meta.json b/sdk/extendedlocation/azure-mgmt-extendedlocation/_meta.json index be1a2e6bac2b..6302fd050c6a 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/_meta.json +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/_meta.json @@ -1,11 +1,11 @@ { - "commit": "2f17a9028f33fe80cf1ae62642fe9ed63c0a17f7", + "commit": "2776cb32cd6ca9ea953a13ae26c954b989e83367", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.0", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/extendedlocation/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/extendedlocation/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-2021-08-15 --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/extendedlocation/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/__init__.py index 5534971f66dd..4c1be67f98a1 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/__init__.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/__init__.py @@ -7,14 +7,20 @@ # -------------------------------------------------------------------------- from ._custom_locations import CustomLocations -__all__ = ['CustomLocations'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk -from ._version import VERSION +__all__ = [ + "CustomLocations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) -__version__ = VERSION +_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_configuration.py index 2a67789dc578..65cf84672544 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_configuration.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_configuration.py @@ -1,16 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -20,7 +17,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class CustomLocationsConfiguration(Configuration): + +class CustomLocationsConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for CustomLocations. Note that all parameters used to create this instance are saved as instance @@ -30,38 +28,38 @@ class CustomLocationsConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-15". 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 - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2021-08-15") + 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.") - super(CustomLocationsConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-extendedlocation/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-extendedlocation/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_custom_locations.py index 70edb2ad1b11..fc42d9623171 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_custom_locations.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_custom_locations.py @@ -1,144 +1,112 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from . import models as _models from ._configuration import CustomLocationsConfiguration from ._serialization import Deserializer, Serializer +from .operations import CustomLocationsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class CustomLocations(MultiApiClientMixin, _SDKClient): +class CustomLocations: # pylint: disable=client-accepts-api-version-keyword """The customLocations Rest API spec. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar custom_locations: CustomLocationsOperations operations + :vartype custom_locations: azure.mgmt.extendedlocation.operations.CustomLocationsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword api_version: Api Version. Default value is "2021-08-15". 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. """ - DEFAULT_API_VERSION = '2021-08-15' - _PROFILE_TAG = "azure.mgmt.extendedlocation.CustomLocations" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "TokenCredential", subscription_id: str, - api_version: Optional[str]=None, base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, **kwargs: Any - ): - self._config = CustomLocationsConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(CustomLocations, self).__init__( - api_version=api_version, - profile=profile + ) -> None: + self._config = CustomLocationsConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.custom_locations = CustomLocationsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - * 2021-03-15-preview: :mod:`v2021_03_15_preview.models` - * 2021-08-15: :mod:`v2021_08_15.models` - * 2021-08-31-preview: :mod:`v2021_08_31_preview.models` - """ - if api_version == '2021-03-15-preview': - from .v2021_03_15_preview import models - return models - elif api_version == '2021-08-15': - from .v2021_08_15 import models - return models - elif api_version == '2021-08-31-preview': - from .v2021_08_31_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def custom_locations(self): - """Instance depends on the API version: - - * 2021-03-15-preview: :class:`CustomLocationsOperations` - * 2021-08-15: :class:`CustomLocationsOperations` - * 2021-08-31-preview: :class:`CustomLocationsOperations` - """ - api_version = self._get_api_version('custom_locations') - if api_version == '2021-03-15-preview': - from .v2021_03_15_preview.operations import CustomLocationsOperations as OperationClass - elif api_version == '2021-08-15': - from .v2021_08_15.operations import CustomLocationsOperations as OperationClass - elif api_version == '2021-08-31-preview': - from .v2021_08_31_preview.operations import CustomLocationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_locations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def resource_sync_rules(self): - """Instance depends on the API version: - - * 2021-08-31-preview: :class:`ResourceSyncRulesOperations` + 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 """ - api_version = self._get_api_version('resource_sync_rules') - if api_version == '2021-08-31-preview': - from .v2021_08_31_preview.operations import ResourceSyncRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'resource_sync_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - def close(self): + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_patch.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_patch.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_patch.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_serialization.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_serialization.py index 25467dfc00bb..8139854b97bb 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_serialization.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,14 +346,12 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -392,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -417,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -447,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -547,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -631,7 +624,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -651,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -711,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -731,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -743,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -751,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -805,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -825,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -893,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -985,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1162,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1201,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1222,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1273,7 +1275,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1297,7 +1299,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1363,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1436,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1473,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1507,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1570,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1644,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1692,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1749,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1800,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1854,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1885,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1902,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1937,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1974,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1990,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_version.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_version.py index e3ee24db5af5..48944bf3938a 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_version.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/_version.py @@ -1,8 +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. +# Licensed under the MIT License. See License.txt in the project root for 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.2.0b1" +VERSION = "2.0.0" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/__init__.py index 6ea441765af1..9316966f170f 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/__init__.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._custom_locations import CustomLocations -__all__ = ['CustomLocations'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "CustomLocations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_configuration.py index 4b89ea94f4c2..97cfe4e7c3d8 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_configuration.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_configuration.py @@ -1,16 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -20,7 +17,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class CustomLocationsConfiguration(Configuration): + +class CustomLocationsConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for CustomLocations. Note that all parameters used to create this instance are saved as instance @@ -30,38 +28,38 @@ class CustomLocationsConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-15". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2021-08-15") + 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.") - super(CustomLocationsConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-extendedlocation/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-extendedlocation/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_custom_locations.py index 58f028cc2677..5310b7b1210f 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_custom_locations.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_custom_locations.py @@ -1,144 +1,114 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import CustomLocationsConfiguration +from .operations import CustomLocationsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class CustomLocations(MultiApiClientMixin, _SDKClient): +class CustomLocations: # pylint: disable=client-accepts-api-version-keyword """The customLocations Rest API spec. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar custom_locations: CustomLocationsOperations operations + :vartype custom_locations: azure.mgmt.extendedlocation.aio.operations.CustomLocationsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword api_version: Api Version. Default value is "2021-08-15". 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. """ - DEFAULT_API_VERSION = '2021-08-15' - _PROFILE_TAG = "azure.mgmt.extendedlocation.CustomLocations" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - api_version: Optional[str] = None, base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: - self._config = CustomLocationsConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(CustomLocations, self).__init__( - api_version=api_version, - profile=profile + self._config = CustomLocationsConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.custom_locations = CustomLocationsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - * 2021-03-15-preview: :mod:`v2021_03_15_preview.models` - * 2021-08-15: :mod:`v2021_08_15.models` - * 2021-08-31-preview: :mod:`v2021_08_31_preview.models` - """ - if api_version == '2021-03-15-preview': - from ..v2021_03_15_preview import models - return models - elif api_version == '2021-08-15': - from ..v2021_08_15 import models - return models - elif api_version == '2021-08-31-preview': - from ..v2021_08_31_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def custom_locations(self): - """Instance depends on the API version: - - * 2021-03-15-preview: :class:`CustomLocationsOperations` - * 2021-08-15: :class:`CustomLocationsOperations` - * 2021-08-31-preview: :class:`CustomLocationsOperations` - """ - api_version = self._get_api_version('custom_locations') - if api_version == '2021-03-15-preview': - from ..v2021_03_15_preview.aio.operations import CustomLocationsOperations as OperationClass - elif api_version == '2021-08-15': - from ..v2021_08_15.aio.operations import CustomLocationsOperations as OperationClass - elif api_version == '2021-08-31-preview': - from ..v2021_08_31_preview.aio.operations import CustomLocationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'custom_locations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def resource_sync_rules(self): - """Instance depends on the API version: - - * 2021-08-31-preview: :class:`ResourceSyncRulesOperations` + 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 """ - api_version = self._get_api_version('resource_sync_rules') - if api_version == '2021-08-31-preview': - from ..v2021_08_31_preview.aio.operations import ResourceSyncRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'resource_sync_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - async def close(self): + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_patch.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_patch.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/_patch.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/__init__.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/__init__.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/__init__.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/_custom_locations_operations.py similarity index 70% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_custom_locations_operations.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/_custom_locations_operations.py index 578db37cdac2..8af4bcf6dca5 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_custom_locations_operations.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/_custom_locations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from typing import ( + Any, + AsyncIterable, + AsyncIterator, + Callable, + Dict, + IO, + List, + Optional, + Type, + TypeVar, + Union, + cast, + overload, +) import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +32,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +46,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._custom_locations_operations import ( build_create_or_update_request, build_delete_request, @@ -42,10 +57,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +71,7 @@ class CustomLocationsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_15.aio.CustomLocations`'s + :class:`~azure.mgmt.extendedlocation.aio.CustomLocations`'s :attr:`custom_locations` attribute. """ @@ -73,20 +88,19 @@ def __init__(self, *args, **kwargs) -> None: def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocationOperation"]: """Lists all available Custom Locations operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomLocationOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationOperation] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.models.CustomLocationOperation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,14 +111,12 @@ def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocatio def prepare_request(next_link=None): if not next_link: - request = build_list_operations_request( + _request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +128,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) @@ -132,10 +143,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -148,8 +160,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocation"]: """Gets a list of Custom Locations in a subscription. @@ -157,19 +167,18 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomLo Gets a list of Custom Locations in the specified subscription. The operation returns properties of each Custom Location. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomLocation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,15 +189,13 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomLo def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -200,13 +207,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationListResult", pipeline_response) @@ -216,10 +222,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,10 +239,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -248,19 +251,18 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. 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 CustomLocation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,16 +273,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -292,13 +292,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationListResult", pipeline_response) @@ -308,10 +307,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,10 +324,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: """Gets a Custom Location. @@ -339,12 +335,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :rtype: ~azure.mgmt.extendedlocation.models.CustomLocation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,23 +350,22 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_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) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,21 +375,21 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - error_map = { + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.CustomLocation, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,19 +400,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CustomLocation") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -426,39 +420,35 @@ async def _create_or_update_initial( 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) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - @overload async def begin_create_or_update( self, @@ -479,22 +469,13 @@ async def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :type parameters: ~azure.mgmt.extendedlocation.models.CustomLocation :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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -503,7 +484,7 @@ async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -518,28 +499,23 @@ async def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.CustomLocation, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.CustomLocation]: """Creates or updates a Custom Location. @@ -551,29 +527,17 @@ async def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation 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. + CustomLocation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.extendedlocation.models.CustomLocation or IO[bytes] :return: An instance of AsyncLROPoller that returns either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -591,12 +555,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -609,22 +574,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomLocation].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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return AsyncLROPoller[_models.CustomLocation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -635,38 +598,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_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) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -680,14 +647,6 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_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: @@ -695,13 +654,13 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -710,11 +669,12 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -726,17 +686,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def update( @@ -765,13 +721,13 @@ async def update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param identity: Identity for the resource. Default value is None. - :type identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :type identity: ~azure.mgmt.extendedlocation.models.Identity :param tags: Resource tags. Default value is None. :type tags: dict[str, str] :param authentication: This is optional input that contains the authentication that should be used to generate the namespace. Default value is None. :type authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :param cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. Default value is None. :type cluster_extension_ids: list[str] @@ -782,18 +738,17 @@ async def update( :type host_resource_id: str :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :type host_type: str or ~azure.mgmt.extendedlocation.models.HostType :param namespace: Kubernetes namespace that will be created on the specified cluster. Default value is None. :type namespace: str :param provisioning_state: Provisioning State for the Custom Location. Default value is None. :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :rtype: ~azure.mgmt.extendedlocation.models.CustomLocation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -804,7 +759,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) @@ -821,22 +776,21 @@ async def update( ) _json = self._serialize.body(_parameters, "PatchableCustomLocations") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -846,16 +800,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def list_enabled_resource_types( @@ -870,19 +820,18 @@ def list_enabled_resource_types( :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EnabledResourceType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.EnabledResourceType] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.models.EnabledResourceType] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -893,17 +842,15 @@ def list_enabled_resource_types( def prepare_request(next_link=None): if not next_link: - request = build_list_enabled_resource_types_request( + _request = build_list_enabled_resource_types_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -915,13 +862,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) @@ -931,10 +877,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -946,7 +893,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/_patch.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_patch.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/aio/operations/_patch.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models.py deleted file mode 100644 index 68b797843878..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models.py +++ /dev/null @@ -1,7 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from .v2021_08_15.models import * diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/__init__.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/__init__.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/__init__.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_custom_locations_enums.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_custom_locations_enums.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_custom_locations_enums.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_custom_locations_enums.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_models_py3.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_models_py3.py similarity index 90% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_models_py3.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_models_py3.py index fc72e43df646..35d7f8a2ed22 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_models_py3.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_models_py3.py @@ -10,7 +10,7 @@ import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from ... import _serialization +from .. import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -23,7 +23,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -58,10 +58,10 @@ class TrackedResource(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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -106,10 +106,10 @@ class CustomLocation(TrackedResource): # pylint: disable=too-many-instance-attr Variables are 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -121,13 +121,13 @@ class CustomLocation(TrackedResource): # pylint: disable=too-many-instance-attr :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :vartype identity: ~azure.mgmt.extendedlocation.models.Identity :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_08_15.models.SystemData + :vartype system_data: ~azure.mgmt.extendedlocation.models.SystemData :ivar authentication: This is optional input that contains the authentication that should be used to generate the namespace. :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. :vartype cluster_extension_ids: list[str] @@ -138,7 +138,7 @@ class CustomLocation(TrackedResource): # pylint: disable=too-many-instance-attr :vartype host_resource_id: str :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :vartype host_type: str or ~azure.mgmt.extendedlocation.models.HostType :ivar namespace: Kubernetes namespace that will be created on the specified cluster. :vartype namespace: str :ivar provisioning_state: Provisioning State for the Custom Location. @@ -191,11 +191,11 @@ def __init__( :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :paramtype identity: ~azure.mgmt.extendedlocation.models.Identity :keyword authentication: This is optional input that contains the authentication that should be used to generate the namespace. :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. :paramtype cluster_extension_ids: list[str] @@ -206,7 +206,7 @@ def __init__( :paramtype host_resource_id: str :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :paramtype host_type: str or ~azure.mgmt.extendedlocation.models.HostType :keyword namespace: Kubernetes namespace that will be created on the specified cluster. :paramtype namespace: str :keyword provisioning_state: Provisioning State for the Custom Location. @@ -232,7 +232,7 @@ class CustomLocationListResult(_serialization.Model): :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str :ivar value: The list of Custom Locations. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :vartype value: list[~azure.mgmt.extendedlocation.models.CustomLocation] """ _validation = { @@ -308,12 +308,12 @@ def __init__(self, **kwargs: Any) -> None: class CustomLocationOperationsList(_serialization.Model): """Lists of Custom Locations operations. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar next_link: Next page of operations. :vartype next_link: str :ivar value: Array of customLocationOperation. Required. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationOperation] + :vartype value: list[~azure.mgmt.extendedlocation.models.CustomLocationOperation] """ _validation = { @@ -332,7 +332,7 @@ def __init__( :keyword next_link: Next page of operations. :paramtype next_link: str :keyword value: Array of customLocationOperation. Required. - :paramtype value: list[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationOperation] + :paramtype value: list[~azure.mgmt.extendedlocation.models.CustomLocationOperation] """ super().__init__(**kwargs) self.next_link = next_link @@ -373,7 +373,7 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -382,22 +382,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class EnabledResourceType(ProxyResource): """EnabledResourceType definition. @@ -405,7 +389,7 @@ class EnabledResourceType(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -413,14 +397,14 @@ class EnabledResourceType(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_08_15.models.SystemData + :vartype system_data: ~azure.mgmt.extendedlocation.models.SystemData :ivar cluster_extension_id: Cluster Extension ID. :vartype cluster_extension_id: str :ivar extension_type: Cluster Extension Type. :vartype extension_type: str :ivar types_metadata: Metadata of the Resource Type. :vartype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_08_15.models.EnabledResourceTypePropertiesTypesMetadataItem] + list[~azure.mgmt.extendedlocation.models.EnabledResourceTypePropertiesTypesMetadataItem] """ _validation = { @@ -458,7 +442,7 @@ def __init__( :paramtype extension_type: str :keyword types_metadata: Metadata of the Resource Type. :paramtype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_08_15.models.EnabledResourceTypePropertiesTypesMetadataItem] + list[~azure.mgmt.extendedlocation.models.EnabledResourceTypePropertiesTypesMetadataItem] """ super().__init__(**kwargs) self.system_data = None @@ -467,7 +451,7 @@ def __init__( self.types_metadata = types_metadata -class EnabledResourceTypePropertiesTypesMetadataItem(_serialization.Model): +class EnabledResourceTypePropertiesTypesMetadataItem(_serialization.Model): # pylint: disable=name-too-long """Metadata of the Resource Type. :ivar api_version: Api Version of Resource Type. @@ -514,7 +498,7 @@ class EnabledResourceTypesListResult(_serialization.Model): :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str :ivar value: The list of EnabledResourceTypes available for a customLocation. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_08_15.models.EnabledResourceType] + :vartype value: list[~azure.mgmt.extendedlocation.models.EnabledResourceType] """ _validation = { @@ -574,10 +558,9 @@ class ErrorDetail(_serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~azure.mgmt.extendedlocation.v2021_08_15.models.ErrorDetail] + :vartype details: list[~azure.mgmt.extendedlocation.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.extendedlocation.v2021_08_15.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.extendedlocation.models.ErrorAdditionalInfo] """ _validation = { @@ -611,7 +594,7 @@ class ErrorResponse(_serialization.Model): operations. (This also follows the OData error response format.). :ivar error: The error object. - :vartype error: ~azure.mgmt.extendedlocation.v2021_08_15.models.ErrorDetail + :vartype error: ~azure.mgmt.extendedlocation.models.ErrorDetail """ _attribute_map = { @@ -621,7 +604,7 @@ class ErrorResponse(_serialization.Model): def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. - :paramtype error: ~azure.mgmt.extendedlocation.v2021_08_15.models.ErrorDetail + :paramtype error: ~azure.mgmt.extendedlocation.models.ErrorDetail """ super().__init__(**kwargs) self.error = error @@ -637,7 +620,7 @@ class Identity(_serialization.Model): :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str :ivar type: The identity type. Known values are: "SystemAssigned" and "None". - :vartype type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.extendedlocation.models.ResourceIdentityType """ _validation = { @@ -654,7 +637,7 @@ class Identity(_serialization.Model): def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs: Any) -> None: """ :keyword type: The identity type. Known values are: "SystemAssigned" and "None". - :paramtype type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.ResourceIdentityType + :paramtype type: str or ~azure.mgmt.extendedlocation.models.ResourceIdentityType """ super().__init__(**kwargs) self.principal_id = None @@ -666,13 +649,13 @@ class PatchableCustomLocations(_serialization.Model): """The Custom Locations patchable resource definition. :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :vartype identity: ~azure.mgmt.extendedlocation.models.Identity :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar authentication: This is optional input that contains the authentication that should be used to generate the namespace. :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. :vartype cluster_extension_ids: list[str] @@ -683,7 +666,7 @@ class PatchableCustomLocations(_serialization.Model): :vartype host_resource_id: str :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :vartype host_type: str or ~azure.mgmt.extendedlocation.models.HostType :ivar namespace: Kubernetes namespace that will be created on the specified cluster. :vartype namespace: str :ivar provisioning_state: Provisioning State for the Custom Location. @@ -718,13 +701,13 @@ def __init__( ) -> None: """ :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :paramtype identity: ~azure.mgmt.extendedlocation.models.Identity :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword authentication: This is optional input that contains the authentication that should be used to generate the namespace. :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. :paramtype cluster_extension_ids: list[str] @@ -735,7 +718,7 @@ def __init__( :paramtype host_resource_id: str :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :paramtype host_type: str or ~azure.mgmt.extendedlocation.models.HostType :keyword namespace: Kubernetes namespace that will be created on the specified cluster. :paramtype namespace: str :keyword provisioning_state: Provisioning State for the Custom Location. @@ -760,15 +743,14 @@ class SystemData(_serialization.Model): :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.CreatedByType + :vartype created_by_type: str or ~azure.mgmt.extendedlocation.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_15.models.CreatedByType + :vartype last_modified_by_type: str or ~azure.mgmt.extendedlocation.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -798,16 +780,14 @@ def __init__( :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_15.models.CreatedByType + :paramtype created_by_type: str or ~azure.mgmt.extendedlocation.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_15.models.CreatedByType + :paramtype last_modified_by_type: str or ~azure.mgmt.extendedlocation.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_patch.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_patch.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/models/_patch.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/__init__.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/__init__.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/__init__.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/_custom_locations_operations.py similarity index 73% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_custom_locations_operations.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/_custom_locations_operations.py index ae250599f3f4..08499579f8ca 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_custom_locations_operations.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/_custom_locations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,26 +17,26 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_list_operations_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +67,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +78,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +93,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -122,7 +123,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +146,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,7 +163,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +187,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -205,7 +206,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +229,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -245,7 +246,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -269,7 +270,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -282,13 +283,13 @@ def build_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_enabled_resource_types_request( +def build_list_enabled_resource_types_request( # pylint: disable=name-too-long resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -311,7 +312,7 @@ def build_list_enabled_resource_types_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -328,7 +329,7 @@ class CustomLocationsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_15.CustomLocations`'s + :class:`~azure.mgmt.extendedlocation.CustomLocations`'s :attr:`custom_locations` attribute. """ @@ -345,20 +346,19 @@ def __init__(self, *args, **kwargs): def list_operations(self, **kwargs: Any) -> Iterable["_models.CustomLocationOperation"]: """Lists all available Custom Locations operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomLocationOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationOperation] + ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.models.CustomLocationOperation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,14 +369,12 @@ def list_operations(self, **kwargs: Any) -> Iterable["_models.CustomLocationOper def prepare_request(next_link=None): if not next_link: - request = build_list_operations_request( + _request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -388,13 +386,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) @@ -404,10 +401,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,8 +418,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomLocation"]: """Gets a list of Custom Locations in a subscription. @@ -429,19 +425,17 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomLocatio Gets a list of Custom Locations in the specified subscription. The operation returns properties of each Custom Location. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,15 +446,13 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomLocatio def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -472,13 +464,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationListResult", pipeline_response) @@ -488,10 +479,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,10 +496,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.CustomLocation"]: """Gets a list of Custom Locations in the specified subscription and resource group. @@ -518,19 +506,17 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. 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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,16 +527,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -562,13 +546,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CustomLocationListResult", pipeline_response) @@ -578,10 +561,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -594,10 +578,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: """Gets a Custom Location. @@ -609,12 +589,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :rtype: ~azure.mgmt.extendedlocation.models.CustomLocation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,23 +604,22 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_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) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -651,21 +629,21 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - error_map = { + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.CustomLocation, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -676,19 +654,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CustomLocation") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -696,39 +674,35 @@ def _create_or_update_initial( 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) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - @overload def begin_create_or_update( self, @@ -749,22 +723,13 @@ def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :type parameters: ~azure.mgmt.extendedlocation.models.CustomLocation :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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -773,7 +738,7 @@ def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,28 +753,23 @@ def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.CustomLocation, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.CustomLocation]: """Creates or updates a Custom Location. @@ -821,29 +781,17 @@ def begin_create_or_update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation 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. + CustomLocation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.extendedlocation.models.CustomLocation or IO[bytes] :return: An instance of LROPoller that returns either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.models.CustomLocation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -861,12 +809,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -878,22 +827,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomLocation].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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return LROPoller[_models.CustomLocation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -904,38 +849,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_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) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: @@ -949,14 +898,6 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_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: @@ -964,13 +905,13 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -979,11 +920,12 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -994,17 +936,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def update( @@ -1033,13 +971,13 @@ def update( :param resource_name: Custom Locations name. Required. :type resource_name: str :param identity: Identity for the resource. Default value is None. - :type identity: ~azure.mgmt.extendedlocation.v2021_08_15.models.Identity + :type identity: ~azure.mgmt.extendedlocation.models.Identity :param tags: Resource tags. Default value is None. :type tags: dict[str, str] :param authentication: This is optional input that contains the authentication that should be used to generate the namespace. Default value is None. :type authentication: - ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocationPropertiesAuthentication + ~azure.mgmt.extendedlocation.models.CustomLocationPropertiesAuthentication :param cluster_extension_ids: Contains the reference to the add-on that contains charts to deploy CRDs and operators. Default value is None. :type cluster_extension_ids: list[str] @@ -1050,18 +988,17 @@ def update( :type host_resource_id: str :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_08_15.models.HostType + :type host_type: str or ~azure.mgmt.extendedlocation.models.HostType :param namespace: Kubernetes namespace that will be created on the specified cluster. Default value is None. :type namespace: str :param provisioning_state: Provisioning State for the Custom Location. Default value is None. :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_15.models.CustomLocation + :rtype: ~azure.mgmt.extendedlocation.models.CustomLocation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1072,7 +1009,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) @@ -1089,22 +1026,21 @@ def update( ) _json = self._serialize.body(_parameters, "PatchableCustomLocations") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1114,16 +1050,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomLocation", pipeline_response) + deserialized = self._deserialize("CustomLocation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def list_enabled_resource_types( @@ -1138,19 +1070,17 @@ def list_enabled_resource_types( :type resource_group_name: str :param resource_name: Custom Locations name. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EnabledResourceType or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_15.models.EnabledResourceType] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.models.EnabledResourceType] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1161,17 +1091,15 @@ def list_enabled_resource_types( def prepare_request(next_link=None): if not next_link: - request = build_list_enabled_resource_types_request( + _request = build_list_enabled_resource_types_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1183,13 +1111,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) @@ -1199,10 +1126,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1214,7 +1142,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/_patch.py similarity index 100% rename from sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_patch.py rename to sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/operations/_patch.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/__init__.py deleted file mode 100644 index 4c1be67f98a1..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_configuration.py deleted file mode 100644 index 975672cf07a4..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-03-15-preview". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-15-preview"] = kwargs.pop("api_version", "2021-03-15-preview") - - 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-extendedlocation/{}".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.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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_custom_locations.py deleted file mode 100644 index d1dda738438b..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_custom_locations.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_03_15_preview.operations.CustomLocationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-03-15-preview". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - 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) -> None: - self._client.close() - - def __enter__(self) -> "CustomLocations": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_metadata.json b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_metadata.json deleted file mode 100644 index 2157126ac60d..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-03-15-preview", - "total_api_version_list": ["2021-03-15-preview"], - "client": { - "name": "CustomLocations", - "filename": "_custom_locations", - "description": "The customLocations Rest API spec.", - "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\": [\"CustomLocationsConfiguration\"], \".._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\": [\"CustomLocationsConfiguration\"], \"..._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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"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": { - "custom_locations": "CustomLocationsOperations" - } -} diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_vendor.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_version.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_version.py deleted file mode 100644 index 58920e6942de..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.2.0b1" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/__init__.py deleted file mode 100644 index 9316966f170f..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_configuration.py deleted file mode 100644 index d993990b27b1..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-03-15-preview". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-15-preview"] = kwargs.pop("api_version", "2021-03-15-preview") - - 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-extendedlocation/{}".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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_custom_locations.py deleted file mode 100644 index 10a225502771..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/_custom_locations.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_03_15_preview.aio.operations.CustomLocationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-03-15-preview". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - 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) -> "CustomLocations": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_custom_locations_operations.py deleted file mode 100644 index 6253e35e4485..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/aio/operations/_custom_locations_operations.py +++ /dev/null @@ -1,968 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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._custom_locations_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_enabled_resource_types_request, - build_list_operations_request, - build_update_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CustomLocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_03_15_preview.aio.CustomLocations`'s - :attr:`custom_locations` 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_operations(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocationOperation"]: - """Lists all available Custom Locations operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocationOperation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - - 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_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in a subscription. - - Gets a list of Custom Locations in the specified subscription. The operation returns properties - of each Custom Location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in the specified subscription and resource group. - - Gets a list of Custom Locations in the specified subscription and resource group. The operation - returns properties of each Custom Location. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - 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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: - """Gets a Custom Location. - - Gets the details of the customLocation with a specified resource group and name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - async def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - 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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocation") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - 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("CustomLocation", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a Custom Location. - - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_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: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - resource_name: str, - tags: Optional[Dict[str, str]] = None, - authentication: Optional[_models.CustomLocationPropertiesAuthentication] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, _models.HostType]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> _models.CustomLocation: - """Updates a Custom Location. - - Updates a Custom Location with the specified Resource Name in the specified Resource Group and - Subscription. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param authentication: This is optional input that contains the authentication that should be - used to generate the namespace. Default value is None. - :type authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :param cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. Default value is None. - :type cluster_extension_ids: list[str] - :param display_name: Display name for the Custom Locations location. Default value is None. - :type display_name: str - :param host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. Default value is None. - :type host_resource_id: str - :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :param namespace: Kubernetes namespace that will be created on the specified cluster. Default - value is None. - :type namespace: str - :param provisioning_state: Provisioning State for the Custom Location. Default value is None. - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - _parameters = _models.PatchableCustomLocations( - authentication=authentication, - cluster_extension_ids=cluster_extension_ids, - display_name=display_name, - host_resource_id=host_resource_id, - host_type=host_type, - namespace=namespace, - provisioning_state=provisioning_state, - tags=tags, - ) - _json = self._serialize.body(_parameters, "PatchableCustomLocations") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def list_enabled_resource_types( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EnabledResourceType"]: - """Gets the list of Enabled Resource Types. - - Gets the list of the Enabled Resource Types. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnabledResourceType or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.EnabledResourceType] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - - 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_enabled_resource_types_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/__init__.py deleted file mode 100644 index 4146d36cc5d4..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._models_py3 import CustomLocation -from ._models_py3 import CustomLocationListResult -from ._models_py3 import CustomLocationOperation -from ._models_py3 import CustomLocationOperationsList -from ._models_py3 import CustomLocationPropertiesAuthentication -from ._models_py3 import EnabledResourceType -from ._models_py3 import EnabledResourceTypePropertiesTypesMetadataItem -from ._models_py3 import EnabledResourceTypesListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import PatchableCustomLocations -from ._models_py3 import ProxyResource -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource - -from ._custom_locations_enums import CreatedByType -from ._custom_locations_enums import HostType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocation", - "CustomLocationListResult", - "CustomLocationOperation", - "CustomLocationOperationsList", - "CustomLocationPropertiesAuthentication", - "EnabledResourceType", - "EnabledResourceTypePropertiesTypesMetadataItem", - "EnabledResourceTypesListResult", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "PatchableCustomLocations", - "ProxyResource", - "Resource", - "SystemData", - "TrackedResource", - "CreatedByType", - "HostType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_custom_locations_enums.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_custom_locations_enums.py deleted file mode 100644 index fa229245c05c..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_custom_locations_enums.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class HostType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of host the Custom Locations is referencing (Kubernetes, etc...).""" - - KUBERNETES = "Kubernetes" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_models_py3.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_models_py3.py deleted file mode 100644 index a5a7f7c60d9f..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/models/_models_py3.py +++ /dev/null @@ -1,775 +0,0 @@ -# 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 Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class CustomLocation(TrackedResource): # pylint: disable=too-many-instance-attributes - """Custom Locations 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.SystemData - :ivar authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :vartype cluster_extension_ids: list[str] - :ivar display_name: Display name for the Custom Locations location. - :vartype display_name: str - :ivar host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. - :vartype host_resource_id: str - :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :ivar namespace: Kubernetes namespace that will be created on the specified cluster. - :vartype namespace: str - :ivar provisioning_state: Provisioning State for the Custom Location. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "authentication": {"key": "properties.authentication", "type": "CustomLocationPropertiesAuthentication"}, - "cluster_extension_ids": {"key": "properties.clusterExtensionIds", "type": "[str]"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "host_resource_id": {"key": "properties.hostResourceId", "type": "str"}, - "host_type": {"key": "properties.hostType", "type": "str"}, - "namespace": {"key": "properties.namespace", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - authentication: Optional["_models.CustomLocationPropertiesAuthentication"] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, "_models.HostType"]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :paramtype cluster_extension_ids: list[str] - :keyword display_name: Display name for the Custom Locations location. - :paramtype display_name: str - :keyword host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will - perform a checkAccess API for listAdminCredentials permissions. - :paramtype host_resource_id: str - :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :keyword namespace: Kubernetes namespace that will be created on the specified cluster. - :paramtype namespace: str - :keyword provisioning_state: Provisioning State for the Custom Location. - :paramtype provisioning_state: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.system_data = None - self.authentication = authentication - self.cluster_extension_ids = cluster_extension_ids - self.display_name = display_name - self.host_resource_id = host_resource_id - self.host_type = host_type - self.namespace = namespace - self.provisioning_state = provisioning_state - - -class CustomLocationListResult(_serialization.Model): - """The List Custom Locations operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - :ivar value: The list of Custom Locations. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - """ - - _validation = { - "next_link": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[CustomLocation]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.next_link = None - self.value = None - - -class CustomLocationOperation(_serialization.Model): - """Custom Locations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_data_action: Is this Operation a data plane operation. - :vartype is_data_action: bool - :ivar name: The name of the compute operation. - :vartype name: str - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar description: The description of the operation. - :vartype description: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - """ - - _validation = { - "is_data_action": {"readonly": True}, - "name": {"readonly": True}, - "origin": {"readonly": True}, - "description": {"readonly": True}, - "operation": {"readonly": True}, - "provider": {"readonly": True}, - "resource": {"readonly": True}, - } - - _attribute_map = { - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.is_data_action = None - self.name = None - self.origin = None - self.description = None - self.operation = None - self.provider = None - self.resource = None - - -class CustomLocationOperationsList(_serialization.Model): - """Lists of Custom Locations operations. - - All required parameters must be populated in order to send to Azure. - - :ivar next_link: Next page of operations. - :vartype next_link: str - :ivar value: Array of customLocationOperation. Required. - :vartype value: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationOperation] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[CustomLocationOperation]"}, - } - - def __init__( - self, *, value: List["_models.CustomLocationOperation"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword next_link: Next page of operations. - :paramtype next_link: str - :keyword value: Array of customLocationOperation. Required. - :paramtype value: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationOperation] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class CustomLocationPropertiesAuthentication(_serialization.Model): - """This is optional input that contains the authentication that should be used to generate the - namespace. - - :ivar type: The type of the Custom Locations authentication. - :vartype type: str - :ivar value: The kubeconfig value. - :vartype value: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, type: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of the Custom Locations authentication. - :paramtype type: str - :keyword value: The kubeconfig value. - :paramtype value: str - """ - super().__init__(**kwargs) - self.type = type - self.value = value - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class EnabledResourceType(ProxyResource): - """EnabledResourceType definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.SystemData - :ivar cluster_extension_id: Cluster Extension ID. - :vartype cluster_extension_id: str - :ivar extension_type: Cluster Extension Type. - :vartype extension_type: str - :ivar types_metadata: Metadata of the Resource Type. - :vartype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.EnabledResourceTypePropertiesTypesMetadataItem] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "cluster_extension_id": {"key": "properties.clusterExtensionId", "type": "str"}, - "extension_type": {"key": "properties.extensionType", "type": "str"}, - "types_metadata": { - "key": "properties.typesMetadata", - "type": "[EnabledResourceTypePropertiesTypesMetadataItem]", - }, - } - - def __init__( - self, - *, - cluster_extension_id: Optional[str] = None, - extension_type: Optional[str] = None, - types_metadata: Optional[List["_models.EnabledResourceTypePropertiesTypesMetadataItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cluster_extension_id: Cluster Extension ID. - :paramtype cluster_extension_id: str - :keyword extension_type: Cluster Extension Type. - :paramtype extension_type: str - :keyword types_metadata: Metadata of the Resource Type. - :paramtype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.EnabledResourceTypePropertiesTypesMetadataItem] - """ - super().__init__(**kwargs) - self.system_data = None - self.cluster_extension_id = cluster_extension_id - self.extension_type = extension_type - self.types_metadata = types_metadata - - -class EnabledResourceTypePropertiesTypesMetadataItem(_serialization.Model): - """Metadata of the Resource Type. - - :ivar api_version: Api Version of Resource Type. - :vartype api_version: str - :ivar resource_provider_namespace: Resource Provider Namespace of Resource Type. - :vartype resource_provider_namespace: str - :ivar resource_type: Resource Type. - :vartype resource_type: str - """ - - _attribute_map = { - "api_version": {"key": "apiVersion", "type": "str"}, - "resource_provider_namespace": {"key": "resourceProviderNamespace", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "str"}, - } - - def __init__( - self, - *, - api_version: Optional[str] = None, - resource_provider_namespace: Optional[str] = None, - resource_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword api_version: Api Version of Resource Type. - :paramtype api_version: str - :keyword resource_provider_namespace: Resource Provider Namespace of Resource Type. - :paramtype resource_provider_namespace: str - :keyword resource_type: Resource Type. - :paramtype resource_type: str - """ - super().__init__(**kwargs) - self.api_version = api_version - self.resource_provider_namespace = resource_provider_namespace - self.resource_type = resource_type - - -class EnabledResourceTypesListResult(_serialization.Model): - """List of EnabledResourceTypes definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - :ivar value: The list of EnabledResourceTypes available for a customLocation. - :vartype value: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.EnabledResourceType] - """ - - _validation = { - "next_link": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[EnabledResourceType]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.next_link = None - self.value = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class PatchableCustomLocations(_serialization.Model): - """The Custom Locations patchable resource definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :vartype cluster_extension_ids: list[str] - :ivar display_name: Display name for the Custom Locations location. - :vartype display_name: str - :ivar host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. - :vartype host_resource_id: str - :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :ivar namespace: Kubernetes namespace that will be created on the specified cluster. - :vartype namespace: str - :ivar provisioning_state: Provisioning State for the Custom Location. - :vartype provisioning_state: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "authentication": {"key": "properties.authentication", "type": "CustomLocationPropertiesAuthentication"}, - "cluster_extension_ids": {"key": "properties.clusterExtensionIds", "type": "[str]"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "host_resource_id": {"key": "properties.hostResourceId", "type": "str"}, - "host_type": {"key": "properties.hostType", "type": "str"}, - "namespace": {"key": "properties.namespace", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - authentication: Optional["_models.CustomLocationPropertiesAuthentication"] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, "_models.HostType"]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :paramtype cluster_extension_ids: list[str] - :keyword display_name: Display name for the Custom Locations location. - :paramtype display_name: str - :keyword host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will - perform a checkAccess API for listAdminCredentials permissions. - :paramtype host_resource_id: str - :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :keyword namespace: Kubernetes namespace that will be created on the specified cluster. - :paramtype namespace: str - :keyword provisioning_state: Provisioning State for the Custom Location. - :paramtype provisioning_state: str - """ - super().__init__(**kwargs) - self.tags = tags - self.authentication = authentication - self.cluster_extension_ids = cluster_extension_ids - self.display_name = display_name - self.host_resource_id = host_resource_id - self.host_type = host_type - self.namespace = namespace - self.provisioning_state = provisioning_state - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_custom_locations_operations.py deleted file mode 100644 index fcd4f5446e08..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/operations/_custom_locations_operations.py +++ /dev/null @@ -1,1252 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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 - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_operations_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.ExtendedLocation/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # 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_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_list_enabled_resource_types_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_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 CustomLocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_03_15_preview.CustomLocations`'s - :attr:`custom_locations` 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_operations(self, **kwargs: Any) -> Iterable["_models.CustomLocationOperation"]: - """Lists all available Custom Locations operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocationOperation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - - 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_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in a subscription. - - Gets a list of Custom Locations in the specified subscription. The operation returns properties - of each Custom Location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in the specified subscription and resource group. - - Gets a list of Custom Locations in the specified subscription and resource group. The operation - returns properties of each Custom Location. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - 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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: - """Gets a Custom Location. - - Gets the details of the customLocation with a specified resource group and name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - 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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocation") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - 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("CustomLocation", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a Custom Location. - - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_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: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def update( - self, - resource_group_name: str, - resource_name: str, - tags: Optional[Dict[str, str]] = None, - authentication: Optional[_models.CustomLocationPropertiesAuthentication] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, _models.HostType]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> _models.CustomLocation: - """Updates a Custom Location. - - Updates a Custom Location with the specified Resource Name in the specified Resource Group and - Subscription. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param authentication: This is optional input that contains the authentication that should be - used to generate the namespace. Default value is None. - :type authentication: - ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocationPropertiesAuthentication - :param cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. Default value is None. - :type cluster_extension_ids: list[str] - :param display_name: Display name for the Custom Locations location. Default value is None. - :type display_name: str - :param host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. Default value is None. - :type host_resource_id: str - :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.HostType - :param namespace: Kubernetes namespace that will be created on the specified cluster. Default - value is None. - :type namespace: str - :param provisioning_state: Provisioning State for the Custom Location. Default value is None. - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_03_15_preview.models.CustomLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - _parameters = _models.PatchableCustomLocations( - authentication=authentication, - cluster_extension_ids=cluster_extension_ids, - display_name=display_name, - host_resource_id=host_resource_id, - host_type=host_type, - namespace=namespace, - provisioning_state=provisioning_state, - tags=tags, - ) - _json = self._serialize.body(_parameters, "PatchableCustomLocations") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def list_enabled_resource_types( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.EnabledResourceType"]: - """Gets the list of Enabled Resource Types. - - Gets the list of the Enabled Resource Types. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnabledResourceType or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_03_15_preview.models.EnabledResourceType] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-03-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-15-preview") - ) - cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - - 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_enabled_resource_types_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/py.typed b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_03_15_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/__init__.py deleted file mode 100644 index 4c1be67f98a1..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_configuration.py deleted file mode 100644 index 54fa429a9a91..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-08-15". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", "2021-08-15") - - 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-extendedlocation/{}".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.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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_custom_locations.py deleted file mode 100644 index eb1d2645d99e..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_custom_locations.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_08_15.operations.CustomLocationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-08-15". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - 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) -> None: - self._client.close() - - def __enter__(self) -> "CustomLocations": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_metadata.json b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_metadata.json deleted file mode 100644 index 27d167acbcd6..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-08-15", - "total_api_version_list": ["2021-08-15"], - "client": { - "name": "CustomLocations", - "filename": "_custom_locations", - "description": "The customLocations Rest API spec.", - "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\": [\"CustomLocationsConfiguration\"], \".._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\": [\"CustomLocationsConfiguration\"], \"..._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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"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": { - "custom_locations": "CustomLocationsOperations" - } -} diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_vendor.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_version.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_version.py deleted file mode 100644 index 58920e6942de..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.2.0b1" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/__init__.py deleted file mode 100644 index 9316966f170f..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_configuration.py deleted file mode 100644 index b1fe4c3b9488..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-08-15". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-08-15"] = kwargs.pop("api_version", "2021-08-15") - - 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-extendedlocation/{}".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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_custom_locations.py deleted file mode 100644 index 432975796b20..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_custom_locations.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_08_15.aio.operations.CustomLocationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-08-15". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - 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) -> "CustomLocations": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/__init__.py deleted file mode 100644 index a0e7ddeced6e..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations_operations import CustomLocationsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocationsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/__init__.py deleted file mode 100644 index a0e7ddeced6e..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations_operations import CustomLocationsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocationsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/py.typed b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_15/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/__init__.py deleted file mode 100644 index 4c1be67f98a1..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_configuration.py deleted file mode 100644 index 487a39c7abff..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-08-31-preview". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-08-31-preview"] = kwargs.pop("api_version", "2021-08-31-preview") - - 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-extendedlocation/{}".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.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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_custom_locations.py deleted file mode 100644 index 1479372975e2..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_custom_locations.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations, ResourceSyncRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_08_31_preview.operations.CustomLocationsOperations - :ivar resource_sync_rules: ResourceSyncRulesOperations operations - :vartype resource_sync_rules: - azure.mgmt.extendedlocation.v2021_08_31_preview.operations.ResourceSyncRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-08-31-preview". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.resource_sync_rules = ResourceSyncRulesOperations( - 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) -> None: - self._client.close() - - def __enter__(self) -> "CustomLocations": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_metadata.json b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_metadata.json deleted file mode 100644 index ebaa06f37c6e..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2021-08-31-preview", - "total_api_version_list": ["2021-08-31-preview"], - "client": { - "name": "CustomLocations", - "filename": "_custom_locations", - "description": "The customLocations Rest API spec.", - "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\": [\"CustomLocationsConfiguration\"], \".._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\": [\"CustomLocationsConfiguration\"], \"..._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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"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": { - "custom_locations": "CustomLocationsOperations", - "resource_sync_rules": "ResourceSyncRulesOperations" - } -} diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_vendor.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_version.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_version.py deleted file mode 100644 index 58920e6942de..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.2.0b1" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/__init__.py deleted file mode 100644 index 9316966f170f..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations import CustomLocations - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_configuration.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_configuration.py deleted file mode 100644 index 008f631b704b..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocationsConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for CustomLocations. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-08-31-preview". 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(CustomLocationsConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-08-31-preview"] = kwargs.pop("api_version", "2021-08-31-preview") - - 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-extendedlocation/{}".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/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_custom_locations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_custom_locations.py deleted file mode 100644 index d6936389a897..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_custom_locations.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import CustomLocationsConfiguration -from .operations import CustomLocationsOperations, ResourceSyncRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class CustomLocations: # pylint: disable=client-accepts-api-version-keyword - """The customLocations Rest API spec. - - :ivar custom_locations: CustomLocationsOperations operations - :vartype custom_locations: - azure.mgmt.extendedlocation.v2021_08_31_preview.aio.operations.CustomLocationsOperations - :ivar resource_sync_rules: ResourceSyncRulesOperations operations - :vartype resource_sync_rules: - azure.mgmt.extendedlocation.v2021_08_31_preview.aio.operations.ResourceSyncRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-08-31-preview". 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 = CustomLocationsConfiguration(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.custom_locations = CustomLocationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.resource_sync_rules = ResourceSyncRulesOperations( - 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) -> "CustomLocations": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/__init__.py deleted file mode 100644 index 9e9308950943..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations_operations import CustomLocationsOperations -from ._resource_sync_rules_operations import ResourceSyncRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocationsOperations", - "ResourceSyncRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_custom_locations_operations.py deleted file mode 100644 index dd72c1abfe01..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_custom_locations_operations.py +++ /dev/null @@ -1,1137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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._custom_locations_operations import ( - build_create_or_update_request, - build_delete_request, - build_find_target_resource_group_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_enabled_resource_types_request, - build_list_operations_request, - build_update_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CustomLocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_31_preview.aio.CustomLocations`'s - :attr:`custom_locations` 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_operations(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocationOperation"]: - """Lists all available Custom Locations operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocationOperation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - - 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_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in a subscription. - - Gets a list of Custom Locations in the specified subscription. The operation returns properties - of each Custom Location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in the specified subscription and resource group. - - Gets a list of Custom Locations in the specified subscription and resource group. The operation - returns properties of each Custom Location. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - 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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: - """Gets a Custom Location. - - Gets the details of the customLocation with a specified resource group and name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - async def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocation") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - 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("CustomLocation", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a Custom Location. - - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_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: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - resource_name: str, - identity: Optional[_models.Identity] = None, - tags: Optional[Dict[str, str]] = None, - authentication: Optional[_models.CustomLocationPropertiesAuthentication] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, _models.HostType]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> _models.CustomLocation: - """Updates a Custom Location. - - Updates a Custom Location with the specified Resource Name in the specified Resource Group and - Subscription. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param identity: Identity for the resource. Default value is None. - :type identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param authentication: This is optional input that contains the authentication that should be - used to generate the namespace. Default value is None. - :type authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :param cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. Default value is None. - :type cluster_extension_ids: list[str] - :param display_name: Display name for the Custom Locations location. Default value is None. - :type display_name: str - :param host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. Default value is None. - :type host_resource_id: str - :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :param namespace: Kubernetes namespace that will be created on the specified cluster. Default - value is None. - :type namespace: str - :param provisioning_state: Provisioning State for the Custom Location. Default value is None. - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - _parameters = _models.PatchableCustomLocations( - authentication=authentication, - cluster_extension_ids=cluster_extension_ids, - display_name=display_name, - host_resource_id=host_resource_id, - host_type=host_type, - identity=identity, - namespace=namespace, - provisioning_state=provisioning_state, - tags=tags, - ) - _json = self._serialize.body(_parameters, "PatchableCustomLocations") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def list_enabled_resource_types( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EnabledResourceType"]: - """Gets the list of Enabled Resource Types. - - Gets the list of the Enabled Resource Types. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnabledResourceType or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.EnabledResourceType] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - - 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_enabled_resource_types_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } - - @overload - async def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocationFindTargetResourceGroupProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Required. - :type parameters: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupProperties - :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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Required. - :type parameters: 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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.CustomLocationFindTargetResourceGroupProperties, IO], - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Is either a - CustomLocationFindTargetResourceGroupProperties type or a IO type. Required. - :type parameters: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupProperties - 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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CustomLocationFindTargetResourceGroupResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocationFindTargetResourceGroupProperties") - - request = build_find_target_resource_group_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.find_target_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CustomLocationFindTargetResourceGroupResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - find_target_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_resource_sync_rules_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_resource_sync_rules_operations.py deleted file mode 100644 index 3786d2110979..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/aio/operations/_resource_sync_rules_operations.py +++ /dev/null @@ -1,748 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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._resource_sync_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_custom_location_id_request, - build_update_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ResourceSyncRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_31_preview.aio.CustomLocations`'s - :attr:`resource_sync_rules` 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_by_custom_location_id( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceSyncRule"]: - """Lists all Resource Sync Rules in a Custom Location. - - Gets a list of Resource Sync Rules in the specified subscription. The operation returns - properties of each Resource Sync Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSyncRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.ResourceSyncRuleListResult] = kwargs.pop("cls", None) - - 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_custom_location_id_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_custom_location_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceSyncRuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_custom_location_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any - ) -> _models.ResourceSyncRule: - """Gets a Resource Sync Rule. - - Gets the details of the resourceSyncRule with a specified resource group, subscription id - Custom Location resource name and Resource Sync Rule name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceSyncRule or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: Union[_models.ResourceSyncRule, IO], - **kwargs: Any - ) -> _models.ResourceSyncRule: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceSyncRule") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_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) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: _models.ResourceSyncRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule - :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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Required. - :type parameters: 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: Union[_models.ResourceSyncRule, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Is either a - ResourceSyncRule type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - parameters=parameters, - 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("ResourceSyncRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any - ) -> None: - """Deletes a Resource Sync Rule. - - Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location - Resource Name, Resource Group, and Subscription Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional[_models.ResourceSyncRulePropertiesSelector] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> _models.ResourceSyncRule: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - _parameters = _models.PatchableResourceSyncRule( - priority=priority, selector=selector, tags=tags, target_resource_group=target_resource_group - ) - _json = self._serialize.body(_parameters, "PatchableResourceSyncRule") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional[_models.ResourceSyncRulePropertiesSelector] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceSyncRule]: - """Updates a Resource Sync Rule. - - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified - Resource Group, Subscription and Custom Location name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param priority: Priority represents a priority of the Resource Sync Rule. Default value is - None. - :type priority: int - :param selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. Default value is None. - :type selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :param target_resource_group: For an unmapped custom resource, its labels will be used to find - matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. Default value is None. - :type target_resource_group: 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - tags=tags, - priority=priority, - selector=selector, - target_resource_group=target_resource_group, - 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("ResourceSyncRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.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) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/__init__.py deleted file mode 100644 index 9c224553f099..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/__init__.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._models_py3 import CustomLocation -from ._models_py3 import CustomLocationFindTargetResourceGroupProperties -from ._models_py3 import CustomLocationFindTargetResourceGroupResult -from ._models_py3 import CustomLocationListResult -from ._models_py3 import CustomLocationOperation -from ._models_py3 import CustomLocationOperationsList -from ._models_py3 import CustomLocationPropertiesAuthentication -from ._models_py3 import EnabledResourceType -from ._models_py3 import EnabledResourceTypePropertiesTypesMetadataItem -from ._models_py3 import EnabledResourceTypesListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Identity -from ._models_py3 import MatchExpressionsProperties -from ._models_py3 import PatchableCustomLocations -from ._models_py3 import PatchableResourceSyncRule -from ._models_py3 import ProxyResource -from ._models_py3 import Resource -from ._models_py3 import ResourceSyncRule -from ._models_py3 import ResourceSyncRuleListResult -from ._models_py3 import ResourceSyncRulePropertiesSelector -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource - -from ._custom_locations_enums import CreatedByType -from ._custom_locations_enums import HostType -from ._custom_locations_enums import ResourceIdentityType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocation", - "CustomLocationFindTargetResourceGroupProperties", - "CustomLocationFindTargetResourceGroupResult", - "CustomLocationListResult", - "CustomLocationOperation", - "CustomLocationOperationsList", - "CustomLocationPropertiesAuthentication", - "EnabledResourceType", - "EnabledResourceTypePropertiesTypesMetadataItem", - "EnabledResourceTypesListResult", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Identity", - "MatchExpressionsProperties", - "PatchableCustomLocations", - "PatchableResourceSyncRule", - "ProxyResource", - "Resource", - "ResourceSyncRule", - "ResourceSyncRuleListResult", - "ResourceSyncRulePropertiesSelector", - "SystemData", - "TrackedResource", - "CreatedByType", - "HostType", - "ResourceIdentityType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_custom_locations_enums.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_custom_locations_enums.py deleted file mode 100644 index 18e0939c85a9..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_custom_locations_enums.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class HostType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of host the Custom Locations is referencing (Kubernetes, etc...).""" - - KUBERNETES = "Kubernetes" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type.""" - - SYSTEM_ASSIGNED = "SystemAssigned" - NONE = "None" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_models_py3.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_models_py3.py deleted file mode 100644 index 506050c0ce83..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_models_py3.py +++ /dev/null @@ -1,1188 +0,0 @@ -# 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 Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class CustomLocation(TrackedResource): # pylint: disable=too-many-instance-attributes - """Custom Locations 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.SystemData - :ivar authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :vartype cluster_extension_ids: list[str] - :ivar display_name: Display name for the Custom Locations location. - :vartype display_name: str - :ivar host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. - :vartype host_resource_id: str - :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :ivar namespace: Kubernetes namespace that will be created on the specified cluster. - :vartype namespace: str - :ivar provisioning_state: Provisioning State for the Custom Location. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "identity": {"key": "identity", "type": "Identity"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "authentication": {"key": "properties.authentication", "type": "CustomLocationPropertiesAuthentication"}, - "cluster_extension_ids": {"key": "properties.clusterExtensionIds", "type": "[str]"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "host_resource_id": {"key": "properties.hostResourceId", "type": "str"}, - "host_type": {"key": "properties.hostType", "type": "str"}, - "namespace": {"key": "properties.namespace", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.Identity"] = None, - authentication: Optional["_models.CustomLocationPropertiesAuthentication"] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, "_models.HostType"]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :keyword authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :paramtype cluster_extension_ids: list[str] - :keyword display_name: Display name for the Custom Locations location. - :paramtype display_name: str - :keyword host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will - perform a checkAccess API for listAdminCredentials permissions. - :paramtype host_resource_id: str - :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :keyword namespace: Kubernetes namespace that will be created on the specified cluster. - :paramtype namespace: str - :keyword provisioning_state: Provisioning State for the Custom Location. - :paramtype provisioning_state: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.identity = identity - self.system_data = None - self.authentication = authentication - self.cluster_extension_ids = cluster_extension_ids - self.display_name = display_name - self.host_resource_id = host_resource_id - self.host_type = host_type - self.namespace = namespace - self.provisioning_state = provisioning_state - - -class CustomLocationFindTargetResourceGroupProperties(_serialization.Model): - """The Find Target Resource Group operation request. - - :ivar labels: Labels of the custom resource, this is a map of {key,value} pairs. - :vartype labels: dict[str, str] - """ - - _attribute_map = { - "labels": {"key": "labels", "type": "{str}"}, - } - - def __init__(self, *, labels: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword labels: Labels of the custom resource, this is a map of {key,value} pairs. - :paramtype labels: dict[str, str] - """ - super().__init__(**kwargs) - self.labels = labels - - -class CustomLocationFindTargetResourceGroupResult(_serialization.Model): - """The Find Target Resource Group operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar matched_resource_sync_rule: The matching resource sync rule is the particular resource - sync rule that matched the match expressions and labels and had lowest priority. This is the - rule responsible for mapping the target resource to the target resource group. - :vartype matched_resource_sync_rule: str - :ivar target_resource_group: The target resource group of matching resource sync rule. The - labels from the request will be used to find out matching resource sync rule against the - selector property of the resource sync rule. The one with highest priority will be returned if - there are multiple matching rules. - :vartype target_resource_group: str - """ - - _validation = { - "matched_resource_sync_rule": {"readonly": True}, - "target_resource_group": {"readonly": True}, - } - - _attribute_map = { - "matched_resource_sync_rule": {"key": "matchedResourceSyncRule", "type": "str"}, - "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.matched_resource_sync_rule = None - self.target_resource_group = None - - -class CustomLocationListResult(_serialization.Model): - """The List Custom Locations operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - :ivar value: The list of Custom Locations. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - """ - - _validation = { - "next_link": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[CustomLocation]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.next_link = None - self.value = None - - -class CustomLocationOperation(_serialization.Model): - """Custom Locations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_data_action: Is this Operation a data plane operation. - :vartype is_data_action: bool - :ivar name: The name of the compute operation. - :vartype name: str - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar description: The description of the operation. - :vartype description: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - """ - - _validation = { - "is_data_action": {"readonly": True}, - "name": {"readonly": True}, - "origin": {"readonly": True}, - "description": {"readonly": True}, - "operation": {"readonly": True}, - "provider": {"readonly": True}, - "resource": {"readonly": True}, - } - - _attribute_map = { - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.is_data_action = None - self.name = None - self.origin = None - self.description = None - self.operation = None - self.provider = None - self.resource = None - - -class CustomLocationOperationsList(_serialization.Model): - """Lists of Custom Locations operations. - - All required parameters must be populated in order to send to Azure. - - :ivar next_link: Next page of operations. - :vartype next_link: str - :ivar value: Array of customLocationOperation. Required. - :vartype value: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationOperation] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[CustomLocationOperation]"}, - } - - def __init__( - self, *, value: List["_models.CustomLocationOperation"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword next_link: Next page of operations. - :paramtype next_link: str - :keyword value: Array of customLocationOperation. Required. - :paramtype value: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationOperation] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class CustomLocationPropertiesAuthentication(_serialization.Model): - """This is optional input that contains the authentication that should be used to generate the - namespace. - - :ivar type: The type of the Custom Locations authentication. - :vartype type: str - :ivar value: The kubeconfig value. - :vartype value: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, type: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of the Custom Locations authentication. - :paramtype type: str - :keyword value: The kubeconfig value. - :paramtype value: str - """ - super().__init__(**kwargs) - self.type = type - self.value = value - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class EnabledResourceType(ProxyResource): - """EnabledResourceType definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.SystemData - :ivar cluster_extension_id: Cluster Extension ID. - :vartype cluster_extension_id: str - :ivar extension_type: Cluster Extension Type. - :vartype extension_type: str - :ivar types_metadata: Metadata of the Resource Type. - :vartype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.EnabledResourceTypePropertiesTypesMetadataItem] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "cluster_extension_id": {"key": "properties.clusterExtensionId", "type": "str"}, - "extension_type": {"key": "properties.extensionType", "type": "str"}, - "types_metadata": { - "key": "properties.typesMetadata", - "type": "[EnabledResourceTypePropertiesTypesMetadataItem]", - }, - } - - def __init__( - self, - *, - cluster_extension_id: Optional[str] = None, - extension_type: Optional[str] = None, - types_metadata: Optional[List["_models.EnabledResourceTypePropertiesTypesMetadataItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword cluster_extension_id: Cluster Extension ID. - :paramtype cluster_extension_id: str - :keyword extension_type: Cluster Extension Type. - :paramtype extension_type: str - :keyword types_metadata: Metadata of the Resource Type. - :paramtype types_metadata: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.EnabledResourceTypePropertiesTypesMetadataItem] - """ - super().__init__(**kwargs) - self.system_data = None - self.cluster_extension_id = cluster_extension_id - self.extension_type = extension_type - self.types_metadata = types_metadata - - -class EnabledResourceTypePropertiesTypesMetadataItem(_serialization.Model): - """Metadata of the Resource Type. - - :ivar api_version: Api Version of Resource Type. - :vartype api_version: str - :ivar resource_provider_namespace: Resource Provider Namespace of Resource Type. - :vartype resource_provider_namespace: str - :ivar resource_type: Resource Type. - :vartype resource_type: str - """ - - _attribute_map = { - "api_version": {"key": "apiVersion", "type": "str"}, - "resource_provider_namespace": {"key": "resourceProviderNamespace", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "str"}, - } - - def __init__( - self, - *, - api_version: Optional[str] = None, - resource_provider_namespace: Optional[str] = None, - resource_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword api_version: Api Version of Resource Type. - :paramtype api_version: str - :keyword resource_provider_namespace: Resource Provider Namespace of Resource Type. - :paramtype resource_provider_namespace: str - :keyword resource_type: Resource Type. - :paramtype resource_type: str - """ - super().__init__(**kwargs) - self.api_version = api_version - self.resource_provider_namespace = resource_provider_namespace - self.resource_type = resource_type - - -class EnabledResourceTypesListResult(_serialization.Model): - """List of EnabledResourceTypes definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - :ivar value: The list of EnabledResourceTypes available for a customLocation. - :vartype value: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.EnabledResourceType] - """ - - _validation = { - "next_link": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[EnabledResourceType]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.next_link = None - self.value = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Identity(_serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: The identity type. Known values are: "SystemAssigned" and "None". - :vartype type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceIdentityType - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned" and "None". - :paramtype type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceIdentityType - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - - -class MatchExpressionsProperties(_serialization.Model): - """Resource Sync Rules matchExpression property definition. - - :ivar key: Key is the label key that the selector applies to. - :vartype key: str - :ivar operator: The Operator field represents a key's relationship to a set of values. Valid - operators are In, NotIn, Exists and DoesNotExist. - :vartype operator: str - :ivar values: The label value. - :vartype values: list[str] - """ - - _attribute_map = { - "key": {"key": "key", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__( - self, - *, - key: Optional[str] = None, - operator: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword key: Key is the label key that the selector applies to. - :paramtype key: str - :keyword operator: The Operator field represents a key's relationship to a set of values. Valid - operators are In, NotIn, Exists and DoesNotExist. - :paramtype operator: str - :keyword values: The label value. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.key = key - self.operator = operator - self.values = values - - -class PatchableCustomLocations(_serialization.Model): - """The Custom Locations patchable resource definition. - - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :vartype authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :ivar cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :vartype cluster_extension_ids: list[str] - :ivar display_name: Display name for the Custom Locations location. - :vartype display_name: str - :ivar host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. - :vartype host_resource_id: str - :ivar host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :vartype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :ivar namespace: Kubernetes namespace that will be created on the specified cluster. - :vartype namespace: str - :ivar provisioning_state: Provisioning State for the Custom Location. - :vartype provisioning_state: str - """ - - _attribute_map = { - "identity": {"key": "identity", "type": "Identity"}, - "tags": {"key": "tags", "type": "{str}"}, - "authentication": {"key": "properties.authentication", "type": "CustomLocationPropertiesAuthentication"}, - "cluster_extension_ids": {"key": "properties.clusterExtensionIds", "type": "[str]"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "host_resource_id": {"key": "properties.hostResourceId", "type": "str"}, - "host_type": {"key": "properties.hostType", "type": "str"}, - "namespace": {"key": "properties.namespace", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - identity: Optional["_models.Identity"] = None, - tags: Optional[Dict[str, str]] = None, - authentication: Optional["_models.CustomLocationPropertiesAuthentication"] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, "_models.HostType"]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword authentication: This is optional input that contains the authentication that should be - used to generate the namespace. - :paramtype authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :keyword cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. - :paramtype cluster_extension_ids: list[str] - :keyword display_name: Display name for the Custom Locations location. - :paramtype display_name: str - :keyword host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will - perform a checkAccess API for listAdminCredentials permissions. - :paramtype host_resource_id: str - :keyword host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" - :paramtype host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :keyword namespace: Kubernetes namespace that will be created on the specified cluster. - :paramtype namespace: str - :keyword provisioning_state: Provisioning State for the Custom Location. - :paramtype provisioning_state: str - """ - super().__init__(**kwargs) - self.identity = identity - self.tags = tags - self.authentication = authentication - self.cluster_extension_ids = cluster_extension_ids - self.display_name = display_name - self.host_resource_id = host_resource_id - self.host_type = host_type - self.namespace = namespace - self.provisioning_state = provisioning_state - - -class PatchableResourceSyncRule(_serialization.Model): - """The Resource Sync Rules patchable resource definition. - - 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 priority: Priority represents a priority of the Resource Sync Rule. - :vartype priority: int - :ivar provisioning_state: Provisioning State for the Resource Sync Rule. - :vartype provisioning_state: str - :ivar selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. - :vartype selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :ivar target_resource_group: For an unmapped custom resource, its labels will be used to find - matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. - :vartype target_resource_group: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "priority": {"key": "properties.priority", "type": "int"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "selector": {"key": "properties.selector", "type": "ResourceSyncRulePropertiesSelector"}, - "target_resource_group": {"key": "properties.targetResourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional["_models.ResourceSyncRulePropertiesSelector"] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword priority: Priority represents a priority of the Resource Sync Rule. - :paramtype priority: int - :keyword selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. - :paramtype selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :keyword target_resource_group: For an unmapped custom resource, its labels will be used to - find matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. - :paramtype target_resource_group: str - """ - super().__init__(**kwargs) - self.tags = tags - self.priority = priority - self.provisioning_state = None - self.selector = selector - self.target_resource_group = target_resource_group - - -class ResourceSyncRule(TrackedResource): - """Resource Sync Rules 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.SystemData - :ivar priority: Priority represents a priority of the Resource Sync Rule. - :vartype priority: int - :ivar provisioning_state: Provisioning State for the Resource Sync Rule. - :vartype provisioning_state: str - :ivar selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. - :vartype selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :ivar target_resource_group: For an unmapped custom resource, its labels will be used to find - matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. - :vartype target_resource_group: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"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}"}, - "location": {"key": "location", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "priority": {"key": "properties.priority", "type": "int"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "selector": {"key": "properties.selector", "type": "ResourceSyncRulePropertiesSelector"}, - "target_resource_group": {"key": "properties.targetResourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional["_models.ResourceSyncRulePropertiesSelector"] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword priority: Priority represents a priority of the Resource Sync Rule. - :paramtype priority: int - :keyword selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. - :paramtype selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :keyword target_resource_group: For an unmapped custom resource, its labels will be used to - find matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. - :paramtype target_resource_group: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.system_data = None - self.priority = priority - self.provisioning_state = None - self.selector = selector - self.target_resource_group = target_resource_group - - -class ResourceSyncRuleListResult(_serialization.Model): - """The List Resource Sync Rules operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - :ivar value: The list of Resource Sync Rules. - :vartype value: list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - """ - - _validation = { - "next_link": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[ResourceSyncRule]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.next_link = None - self.value = None - - -class ResourceSyncRulePropertiesSelector(_serialization.Model): - """A label selector is composed of two parts, matchLabels and matchExpressions. The first part, - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is - equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', - and the values array contains only 'value'. The second part, matchExpressions is a list of - resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. - The values set must be non-empty in the case of In and NotIn. The values set must be empty in - the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and - matchExpressions must all be satisfied in order to match. - - :ivar match_expressions: MatchExpressions is a list of resource selector requirements. Valid - operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the - case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. - :vartype match_expressions: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.MatchExpressionsProperties] - :ivar match_labels: MatchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. - :vartype match_labels: dict[str, str] - """ - - _attribute_map = { - "match_expressions": {"key": "matchExpressions", "type": "[MatchExpressionsProperties]"}, - "match_labels": {"key": "matchLabels", "type": "{str}"}, - } - - def __init__( - self, - *, - match_expressions: Optional[List["_models.MatchExpressionsProperties"]] = None, - match_labels: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword match_expressions: MatchExpressions is a list of resource selector requirements. Valid - operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the - case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. - :paramtype match_expressions: - list[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.MatchExpressionsProperties] - :keyword match_labels: MatchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. - :paramtype match_labels: dict[str, str] - """ - super().__init__(**kwargs) - self.match_expressions = match_expressions - self.match_labels = match_labels - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/__init__.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/__init__.py deleted file mode 100644 index 9e9308950943..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._custom_locations_operations import CustomLocationsOperations -from ._resource_sync_rules_operations import ResourceSyncRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CustomLocationsOperations", - "ResourceSyncRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_custom_locations_operations.py deleted file mode 100644 index 0ffa41957835..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_custom_locations_operations.py +++ /dev/null @@ -1,1465 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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 - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_operations_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.ExtendedLocation/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # 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_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_list_enabled_resource_types_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_find_target_resource_group_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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 CustomLocationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_31_preview.CustomLocations`'s - :attr:`custom_locations` 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_operations(self, **kwargs: Any) -> Iterable["_models.CustomLocationOperation"]: - """Lists all available Custom Locations operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocationOperation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationOperationsList] = kwargs.pop("cls", None) - - 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_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_operations.metadata = {"url": "/providers/Microsoft.ExtendedLocation/operations"} - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in a subscription. - - Gets a list of Custom Locations in the specified subscription. The operation returns properties - of each Custom Location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.CustomLocation"]: - """Gets a list of Custom Locations in the specified subscription and resource group. - - Gets a list of Custom Locations in the specified subscription and resource group. The operation - returns properties of each Custom Location. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - 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 CustomLocation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocationListResult] = kwargs.pop("cls", None) - - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomLocationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" - } - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.CustomLocation: - """Gets a Custom Location. - - Gets the details of the customLocation with a specified resource group and name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - def _create_or_update_initial( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> _models.CustomLocation: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocation") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Required. - :type parameters: 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, resource_name: str, parameters: Union[_models.CustomLocation, IO], **kwargs: Any - ) -> LROPoller[_models.CustomLocation]: - """Creates or updates a Custom Location. - - Creates or updates a Custom Location in the specified Subscription and Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters supplied to create or update a Custom Location. Is either a - CustomLocation type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation 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 CustomLocation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - 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("CustomLocation", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a Custom Location. - - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_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: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def update( - self, - resource_group_name: str, - resource_name: str, - identity: Optional[_models.Identity] = None, - tags: Optional[Dict[str, str]] = None, - authentication: Optional[_models.CustomLocationPropertiesAuthentication] = None, - cluster_extension_ids: Optional[List[str]] = None, - display_name: Optional[str] = None, - host_resource_id: Optional[str] = None, - host_type: Optional[Union[str, _models.HostType]] = None, - namespace: Optional[str] = None, - provisioning_state: Optional[str] = None, - **kwargs: Any - ) -> _models.CustomLocation: - """Updates a Custom Location. - - Updates a Custom Location with the specified Resource Name in the specified Resource Group and - Subscription. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param identity: Identity for the resource. Default value is None. - :type identity: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.Identity - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param authentication: This is optional input that contains the authentication that should be - used to generate the namespace. Default value is None. - :type authentication: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationPropertiesAuthentication - :param cluster_extension_ids: Contains the reference to the add-on that contains charts to - deploy CRDs and operators. Default value is None. - :type cluster_extension_ids: list[str] - :param display_name: Display name for the Custom Locations location. Default value is None. - :type display_name: str - :param host_resource_id: Connected Cluster or AKS Cluster. The Custom Locations RP will perform - a checkAccess API for listAdminCredentials permissions. Default value is None. - :type host_resource_id: str - :param host_type: Type of host the Custom Locations is referencing (Kubernetes, etc...). - "Kubernetes" Default value is None. - :type host_type: str or ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.HostType - :param namespace: Kubernetes namespace that will be created on the specified cluster. Default - value is None. - :type namespace: str - :param provisioning_state: Provisioning State for the Custom Location. Default value is None. - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomLocation or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocation - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CustomLocation] = kwargs.pop("cls", None) - - _parameters = _models.PatchableCustomLocations( - authentication=authentication, - cluster_extension_ids=cluster_extension_ids, - display_name=display_name, - host_resource_id=host_resource_id, - host_type=host_type, - identity=identity, - namespace=namespace, - provisioning_state=provisioning_state, - tags=tags, - ) - _json = self._serialize.body(_parameters, "PatchableCustomLocations") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomLocation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" - } - - @distributed_trace - def list_enabled_resource_types( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.EnabledResourceType"]: - """Gets the list of Enabled Resource Types. - - Gets the list of the Enabled Resource Types. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnabledResourceType or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.EnabledResourceType] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.EnabledResourceTypesListResult] = kwargs.pop("cls", None) - - 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_enabled_resource_types_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_enabled_resource_types.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EnabledResourceTypesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_enabled_resource_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" - } - - @overload - def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.CustomLocationFindTargetResourceGroupProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Required. - :type parameters: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupProperties - :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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Required. - :type parameters: 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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def find_target_resource_group( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.CustomLocationFindTargetResourceGroupProperties, IO], - **kwargs: Any - ) -> Optional[_models.CustomLocationFindTargetResourceGroupResult]: - """Gets matching target resource group for resource sync. - - Returns the target resource group associated with the resource sync rules of the Custom - Location that match the rules passed in with the Find Target Resource Group Request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param parameters: Parameters of the find target resource group request. Is either a - CustomLocationFindTargetResourceGroupProperties type or a IO type. Required. - :type parameters: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupProperties - 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 - :return: CustomLocationFindTargetResourceGroupResult or None or the result of cls(response) - :rtype: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.CustomLocationFindTargetResourceGroupResult - or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CustomLocationFindTargetResourceGroupResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomLocationFindTargetResourceGroupProperties") - - request = build_find_target_resource_group_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.find_target_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CustomLocationFindTargetResourceGroupResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - find_target_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_resource_sync_rules_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_resource_sync_rules_operations.py deleted file mode 100644 index fde6253ae6a4..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/operations/_resource_sync_rules_operations.py +++ /dev/null @@ -1,990 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -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 - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_custom_location_id_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - "childResourceName": _SERIALIZER.url( - "child_resource_name", - child_resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - "childResourceName": _SERIALIZER.url( - "child_resource_name", - child_resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - "childResourceName": _SERIALIZER.url( - "child_resource_name", - child_resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # 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_update_request( - resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - "childResourceName": _SERIALIZER.url( - "child_resource_name", - child_resource_name, - "str", - max_length=63, - min_length=1, - pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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) - - -class ResourceSyncRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.extendedlocation.v2021_08_31_preview.CustomLocations`'s - :attr:`resource_sync_rules` 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_by_custom_location_id( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceSyncRule"]: - """Lists all Resource Sync Rules in a Custom Location. - - Gets a list of Resource Sync Rules in the specified subscription. The operation returns - properties of each Resource Sync Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSyncRule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.ResourceSyncRuleListResult] = kwargs.pop("cls", None) - - 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_custom_location_id_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_custom_location_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceSyncRuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_custom_location_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any - ) -> _models.ResourceSyncRule: - """Gets a Resource Sync Rule. - - Gets the details of the resourceSyncRule with a specified resource group, subscription id - Custom Location resource name and Resource Sync Rule name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceSyncRule or the result of cls(response) - :rtype: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: Union[_models.ResourceSyncRule, IO], - **kwargs: Any - ) -> _models.ResourceSyncRule: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceSyncRule") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_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) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: _models.ResourceSyncRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule - :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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Required. - :type parameters: 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - parameters: Union[_models.ResourceSyncRule, IO], - **kwargs: Any - ) -> LROPoller[_models.ResourceSyncRule]: - """Creates or updates a Resource Sync Rule. - - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and - Resource Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param parameters: Parameters supplied to create or update a Resource Sync Rule. Is either a - ResourceSyncRule type or a IO type. Required. - :type parameters: ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - parameters=parameters, - 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("ResourceSyncRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any - ) -> None: - """Deletes a Resource Sync Rule. - - Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location - Resource Name, Resource Group, and Subscription Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional[_models.ResourceSyncRulePropertiesSelector] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> _models.ResourceSyncRule: - 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: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - - _parameters = _models.PatchableResourceSyncRule( - priority=priority, selector=selector, tags=tags, target_resource_group=target_resource_group - ) - _json = self._serialize.body(_parameters, "PatchableResourceSyncRule") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceSyncRule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - child_resource_name: str, - tags: Optional[Dict[str, str]] = None, - priority: Optional[int] = None, - selector: Optional[_models.ResourceSyncRulePropertiesSelector] = None, - target_resource_group: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.ResourceSyncRule]: - """Updates a Resource Sync Rule. - - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified - Resource Group, Subscription and Custom Location name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: Custom Locations name. Required. - :type resource_name: str - :param child_resource_name: Resource Sync Rule name. Required. - :type child_resource_name: str - :param tags: Resource tags. Default value is None. - :type tags: dict[str, str] - :param priority: Priority represents a priority of the Resource Sync Rule. Default value is - None. - :type priority: int - :param selector: A label selector is composed of two parts, matchLabels and matchExpressions. - The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the - matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the - operator is 'In', and the values array contains only 'value'. The second part, matchExpressions - is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and - DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must - be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels - and matchExpressions must all be satisfied in order to match. Default value is None. - :type selector: - ~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRulePropertiesSelector - :param target_resource_group: For an unmapped custom resource, its labels will be used to find - matching resource sync rules. If this resource sync rule is one of the matching rules with - highest priority, then the unmapped custom resource will be projected to the target resource - group associated with this resource sync rule. The user creating this resource sync rule should - have write permissions on the target resource group and this write permission will be validated - when creating the resource sync rule. Default value is None. - :type target_resource_group: 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 ResourceSyncRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.extendedlocation.v2021_08_31_preview.models.ResourceSyncRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-08-31-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-08-31-preview") - ) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.ResourceSyncRule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - child_resource_name=child_resource_name, - tags=tags, - priority=priority, - selector=selector, - target_resource_group=target_resource_group, - 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("ResourceSyncRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.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) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" - } diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/py.typed b/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/v2021_08_31_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_create_update.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_create_update.py index 8ea22a70f46e..c6bdaa6493fc 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_create_update.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_create_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_delete.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_delete.py index f011a0029d47..4ce031d26d48 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_delete.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ @@ -29,11 +30,10 @@ def main(): subscription_id="11111111-2222-3333-4444-555555555555", ) - response = client.custom_locations.begin_delete( + client.custom_locations.begin_delete( resource_group_name="testresourcegroup", resource_name="customLocation01", ).result() - print(response) # x-ms-original-file: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsDelete.json diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_get.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_get.py index 1e9f3c69f79a..60b9948e74d4 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_get.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_resource_group.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_resource_group.py index 61051efcb790..b39f88956a1d 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_resource_group.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_subscription.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_subscription.py index 81f616d43462..5ae979cf6f17 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_subscription.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_enabled_resource_types.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_enabled_resource_types.py index d2283a5d06fb..174245d88dd0 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_enabled_resource_types.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_enabled_resource_types.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_operations.py index 10f6b2807db7..02349cba8816 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_operations.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_list_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_patch.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_patch.py index 7fb0da8b87c0..e4b4f0503b29 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_patch.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_samples/custom_locations_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.extendedlocation import CustomLocations """ diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/conftest.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/conftest.py new file mode 100644 index 000000000000..adaa7c48d068 --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + customlocations_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + customlocations_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + customlocations_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + customlocations_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations.py new file mode 100644 index 000000000000..c06f5af59c62 --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 pytest +from azure.mgmt.extendedlocation import CustomLocations + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCustomLocationsCustomLocationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CustomLocations) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_operations(self, resource_group): + response = self.client.custom_locations.list_operations( + api_version="2021-08-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.custom_locations.list_by_subscription( + api_version="2021-08-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.custom_locations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-08-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.custom_locations.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.custom_locations.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "authentication": {"type": "str", "value": "str"}, + "clusterExtensionIds": ["str"], + "displayName": "str", + "hostResourceId": "str", + "hostType": "str", + "id": "str", + "identity": {"principalId": "str", "tenantId": "str", "type": "str"}, + "name": "str", + "namespace": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-08-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.custom_locations.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.custom_locations.update( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_enabled_resource_types(self, resource_group): + response = self.client.custom_locations.list_enabled_resource_types( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations_async.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations_async.py new file mode 100644 index 000000000000..b20644fcd629 --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/generated_tests/test_custom_locations_custom_locations_operations_async.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 pytest +from azure.mgmt.extendedlocation.aio import CustomLocations + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCustomLocationsCustomLocationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CustomLocations, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_operations(self, resource_group): + response = self.client.custom_locations.list_operations( + api_version="2021-08-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.custom_locations.list_by_subscription( + api_version="2021-08-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.custom_locations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-08-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.custom_locations.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.custom_locations.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "authentication": {"type": "str", "value": "str"}, + "clusterExtensionIds": ["str"], + "displayName": "str", + "hostResourceId": "str", + "hostType": "str", + "id": "str", + "identity": {"principalId": "str", "tenantId": "str", "type": "str"}, + "name": "str", + "namespace": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-08-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.custom_locations.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.custom_locations.update( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_enabled_resource_types(self, resource_group): + response = self.client.custom_locations.list_enabled_resource_types( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2021-08-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/sdk_packaging.toml b/sdk/extendedlocation/azure-mgmt-extendedlocation/sdk_packaging.toml index 11dedc260a8e..3911a36b1db5 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/sdk_packaging.toml +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/sdk_packaging.toml @@ -3,6 +3,6 @@ package_name = "azure-mgmt-extendedlocation" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Extended Location Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true title = "CustomLocations" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py index 467163aca676..7211fed1404e 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Extended Location Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", ) From 89e896c84db71a5c0d9c6c1fcb5100d0fceb9644 Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 Date: Wed, 30 Oct 2024 15:34:08 +0800 Subject: [PATCH 2/2] update-testcase --- .../azure-mgmt-extendedlocation/CHANGELOG.md | 15 +------ .../dev_requirements.txt | 2 + .../azure-mgmt-extendedlocation/setup.py | 8 ++-- .../tests/conftest.py | 35 +++++++++++++++ ..._custom_locations_operations_async_test.py | 43 +++++++++++++++++++ ...ations_custom_locations_operations_test.py | 42 ++++++++++++++++++ 6 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/tests/conftest.py create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_async_test.py create mode 100644 sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_test.py diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md b/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md index 55aa5eafe078..6c01e886f312 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/CHANGELOG.md @@ -2,22 +2,9 @@ ## 2.0.0 (2024-10-30) -### Features Added - - - Method `CustomLocationsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, resource_name: str, parameters: CustomLocation, content_type: str)` - - Method `CustomLocationsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, resource_name: str, parameters: IO[bytes], content_type: str)` - ### Breaking Changes - - Model `CustomLocations` deleted or renamed its instance variable `resource_sync_rules` - - Deleted or renamed model `CustomLocationFindTargetResourceGroupProperties` - - Deleted or renamed model `CustomLocationFindTargetResourceGroupResult` - - Deleted or renamed model `MatchExpressionsProperties` - - Deleted or renamed model `PatchableResourceSyncRule` - - Deleted or renamed model `ResourceSyncRule` - - Deleted or renamed model `ResourceSyncRulePropertiesSelector` - - Deleted or renamed method `CustomLocationsOperations.find_target_resource_group` - - Deleted or renamed model `ResourceSyncRulesOperations` + - This package now only targets the latest Api-Version available on Azure and removes APIs of other Api-Version. After this change, the package can have much smaller size. If your application requires a specific and non-latest Api-Version, it's recommended to pin this package to the previous released version; If your application always only use latest Api-Version, please ingore this change. ## 1.2.0b1 (2023-02-14) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/dev_requirements.txt b/sdk/extendedlocation/azure-mgmt-extendedlocation/dev_requirements.txt index 6ccb7f031ddd..fa6811a93df0 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/dev_requirements.txt +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/dev_requirements.txt @@ -1 +1,3 @@ -e ../../../tools/azure-sdk-tools +-e ../../resources/azure-mgmt-resource +aiohttp \ No newline at end of file diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py index 7211fed1404e..99342adcbb89 100644 --- a/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/setup.py @@ -22,9 +22,11 @@ # Version extraction inspired from 'requests' with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), + ( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py") + ), "r", ) as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/conftest.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/conftest.py new file mode 100644 index 000000000000..adaa7c48d068 --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + customlocations_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + customlocations_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + customlocations_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + customlocations_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=customlocations_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_async_test.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_async_test.py new file mode 100644 index 000000000000..a66ab87618ce --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_async_test.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 pytest +from azure.mgmt.extendedlocation.aio import CustomLocations + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestCustomLocationsCustomLocationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CustomLocations, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_operations(self, resource_group): + response = self.client.custom_locations.list_operations() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.custom_locations.list_by_subscription() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.custom_locations.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_test.py b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_test.py new file mode 100644 index 000000000000..ee654f41df8f --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/tests/test_custom_locations_custom_locations_operations_test.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 pytest +from azure.mgmt.extendedlocation import CustomLocations + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestCustomLocationsCustomLocationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CustomLocations) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_operations(self, resource_group): + response = self.client.custom_locations.list_operations() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.custom_locations.list_by_subscription() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.custom_locations.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == []