From 9860aae437df1200a1cd341d317d26837dc2ca38 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 28 Jan 2025 22:16:43 +0000 Subject: [PATCH] CodeGen from PR 32366 in Azure/azure-rest-api-specs Merge 84b2e541bf19d043dd4a38db63e8958ac20c92bf into 175d71800b942faaa4113416d5e395b8ba19ce31 --- .../azure-mgmt-applicationinsights/README.md | 7 +- .../azure-mgmt-applicationinsights/_meta.json | 10 +- ..._application_insights_management_client.py | 73 ++- .../applicationinsights/_configuration.py | 5 +- .../applicationinsights/_serialization.py | 537 +++++++++++------- ..._application_insights_management_client.py | 73 ++- .../applicationinsights/aio/_configuration.py | 5 +- .../v2015_05_01/__init__.py | 12 +- ..._application_insights_management_client.py | 80 ++- .../v2015_05_01/_configuration.py | 8 +- .../v2015_05_01/_metadata.json | 10 +- .../v2015_05_01/_vendor.py | 30 - .../v2015_05_01/_version.py | 2 +- .../v2015_05_01/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 82 ++- .../v2015_05_01/aio/_configuration.py | 8 +- .../v2015_05_01/aio/operations/__init__.py | 44 +- .../operations/_analytics_items_operations.py | 119 ++-- .../aio/operations/_annotations_operations.py | 128 ++--- .../aio/operations/_api_keys_operations.py | 129 ++--- ...component_available_features_operations.py | 36 +- ...ent_current_billing_features_operations.py | 77 +-- ...mponent_feature_capabilities_operations.py | 36 +- .../_component_quota_status_operations.py | 34 +- .../aio/operations/_components_operations.py | 267 ++++----- .../_export_configurations_operations.py | 171 +++--- .../aio/operations/_favorites_operations.py | 163 ++---- .../operations/_my_workbooks_operations.py | 198 +++---- .../v2015_05_01/aio/operations/_operations.py | 39 +- ...ive_detection_configurations_operations.py | 103 ++-- .../_web_test_locations_operations.py | 42 +- .../aio/operations/_web_tests_operations.py | 229 +++----- .../_work_item_configurations_operations.py | 190 +++---- .../aio/operations/_workbooks_operations.py | 170 ++---- .../v2015_05_01/models/__init__.py | 153 ++--- .../v2015_05_01/models/_models_py3.py | 87 ++- .../v2015_05_01/operations/__init__.py | 44 +- .../operations/_analytics_items_operations.py | 125 ++-- .../operations/_annotations_operations.py | 132 ++--- .../operations/_api_keys_operations.py | 137 ++--- ...component_available_features_operations.py | 38 +- ...ent_current_billing_features_operations.py | 81 ++- ...mponent_feature_capabilities_operations.py | 38 +- .../_component_quota_status_operations.py | 36 +- .../operations/_components_operations.py | 276 ++++----- .../_export_configurations_operations.py | 181 +++--- .../operations/_favorites_operations.py | 169 +++--- .../operations/_my_workbooks_operations.py | 206 +++---- .../v2015_05_01/operations/_operations.py | 39 +- ...ive_detection_configurations_operations.py | 109 ++-- .../_web_test_locations_operations.py | 44 +- .../operations/_web_tests_operations.py | 239 +++----- .../_work_item_configurations_operations.py | 199 +++---- .../operations/_workbooks_operations.py | 176 +++--- .../v2017_10_01/__init__.py | 12 +- ..._application_insights_management_client.py | 40 +- .../v2017_10_01/_configuration.py | 8 +- .../v2017_10_01/_metadata.json | 10 +- .../v2017_10_01/_vendor.py | 30 - .../v2017_10_01/_version.py | 2 +- .../v2017_10_01/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 42 +- .../v2017_10_01/aio/_configuration.py | 8 +- .../v2017_10_01/aio/operations/__init__.py | 20 +- ...mponent_current_pricing_plan_operations.py | 115 ++-- ...cription_list_migration_date_operations.py | 34 +- ...migrate_to_new_pricing_model_operations.py | 32 +- ...back_to_legacy_pricing_model_operations.py | 32 +- .../v2017_10_01/models/__init__.py | 21 +- .../v2017_10_01/models/_models_py3.py | 2 - .../v2017_10_01/operations/__init__.py | 20 +- ...mponent_current_pricing_plan_operations.py | 121 ++-- ...cription_list_migration_date_operations.py | 36 +- ...migrate_to_new_pricing_model_operations.py | 32 +- ...back_to_legacy_pricing_model_operations.py | 32 +- .../v2018_05_01_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 46 +- .../v2018_05_01_preview/_configuration.py | 8 +- .../v2018_05_01_preview/_metadata.json | 10 +- .../v2018_05_01_preview/_vendor.py | 30 - .../v2018_05_01_preview/_version.py | 2 +- .../v2018_05_01_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 48 +- .../v2018_05_01_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 18 +- .../aio/operations/_components_operations.py | 284 ++++----- .../aio/operations/_operations.py | 41 +- ...ive_detection_configurations_operations.py | 113 ++-- .../aio/operations/_web_tests_operations.py | 241 ++++---- .../v2018_05_01_preview/models/__init__.py | 77 +-- .../v2018_05_01_preview/models/_models_py3.py | 53 +- .../operations/__init__.py | 18 +- .../operations/_components_operations.py | 295 ++++------ .../operations/_operations.py | 41 +- ...ive_detection_configurations_operations.py | 119 ++-- .../operations/_web_tests_operations.py | 251 ++++---- .../v2018_06_17_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 40 +- .../v2018_06_17_preview/_configuration.py | 8 +- .../v2018_06_17_preview/_metadata.json | 10 +- .../v2018_06_17_preview/_vendor.py | 30 - .../v2018_06_17_preview/_version.py | 2 +- .../v2018_06_17_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 42 +- .../v2018_06_17_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 14 +- .../aio/operations/_operations.py | 41 +- .../aio/operations/_workbooks_operations.py | 179 +++--- .../v2018_06_17_preview/models/__init__.py | 39 +- .../v2018_06_17_preview/models/_models_py3.py | 8 +- .../operations/__init__.py | 14 +- .../operations/_operations.py | 41 +- .../operations/_workbooks_operations.py | 185 +++--- .../v2019_10_17_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 34 +- .../v2019_10_17_preview/_configuration.py | 8 +- .../v2019_10_17_preview/_metadata.json | 10 +- .../v2019_10_17_preview/_vendor.py | 30 - .../v2019_10_17_preview/_version.py | 2 +- .../v2019_10_17_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2019_10_17_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 12 +- .../_workbook_templates_operations.py | 183 +++--- .../v2019_10_17_preview/models/__init__.py | 29 +- .../v2019_10_17_preview/models/_models_py3.py | 8 +- .../operations/__init__.py | 12 +- .../_workbook_templates_operations.py | 188 +++--- .../v2020_02_02/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2020_02_02/_configuration.py | 8 +- .../v2020_02_02/_metadata.json | 10 +- .../v2020_02_02/_vendor.py | 30 - .../v2020_02_02/_version.py | 2 +- .../v2020_02_02/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2020_02_02/aio/_configuration.py | 8 +- .../v2020_02_02/aio/operations/__init__.py | 12 +- .../aio/operations/_components_operations.py | 267 ++++----- .../v2020_02_02/models/__init__.py | 49 +- .../v2020_02_02/models/_models_py3.py | 16 +- .../v2020_02_02/operations/__init__.py | 12 +- .../operations/_components_operations.py | 276 ++++----- .../v2020_02_02_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2020_02_02_preview/_configuration.py | 8 +- .../v2020_02_02_preview/_metadata.json | 10 +- .../v2020_02_02_preview/_vendor.py | 30 - .../v2020_02_02_preview/_version.py | 2 +- .../v2020_02_02_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2020_02_02_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 12 +- .../aio/operations/_components_operations.py | 284 ++++----- .../v2020_02_02_preview/models/__init__.py | 51 +- .../v2020_02_02_preview/models/_models_py3.py | 16 +- .../operations/__init__.py | 12 +- .../operations/_components_operations.py | 295 +++++----- .../v2020_03_01_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 34 +- .../v2020_03_01_preview/_configuration.py | 8 +- .../v2020_03_01_preview/_metadata.json | 10 +- .../v2020_03_01_preview/_vendor.py | 30 - .../v2020_03_01_preview/_version.py | 2 +- .../v2020_03_01_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2020_03_01_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 12 +- ...nent_linked_storage_accounts_operations.py | 145 ++--- .../v2020_03_01_preview/models/__init__.py | 29 +- .../v2020_03_01_preview/models/_models_py3.py | 24 +- .../operations/__init__.py | 12 +- ...nent_linked_storage_accounts_operations.py | 151 ++--- .../v2020_06_02_preview/__init__.py | 12 +- ..._application_insights_management_client.py | 42 +- .../v2020_06_02_preview/_configuration.py | 8 +- .../v2020_06_02_preview/_metadata.json | 10 +- .../v2020_06_02_preview/_vendor.py | 30 - .../v2020_06_02_preview/_version.py | 2 +- .../v2020_06_02_preview/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 44 +- .../v2020_06_02_preview/aio/_configuration.py | 8 +- .../aio/operations/__init__.py | 14 +- .../aio/operations/_live_token_operations.py | 34 +- .../aio/operations/_operations.py | 42 +- .../v2020_06_02_preview/models/__init__.py | 25 +- .../v2020_06_02_preview/models/_models_py3.py | 4 +- .../operations/__init__.py | 14 +- .../operations/_live_token_operations.py | 36 +- .../operations/_operations.py | 41 +- .../v2020_11_20/__init__.py | 12 +- ..._application_insights_management_client.py | 34 +- .../v2020_11_20/_configuration.py | 8 +- .../v2020_11_20/_metadata.json | 10 +- .../v2020_11_20/_vendor.py | 30 - .../v2020_11_20/_version.py | 2 +- .../v2020_11_20/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2020_11_20/aio/_configuration.py | 8 +- .../v2020_11_20/aio/operations/__init__.py | 12 +- .../_workbook_templates_operations.py | 173 +++--- .../v2020_11_20/models/__init__.py | 31 +- .../v2020_11_20/models/_models_py3.py | 8 +- .../v2020_11_20/operations/__init__.py | 12 +- .../_workbook_templates_operations.py | 179 +++--- .../v2021_03_08/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2021_03_08/_configuration.py | 8 +- .../v2021_03_08/_metadata.json | 10 +- .../v2021_03_08/_vendor.py | 30 - .../v2021_03_08/_version.py | 2 +- .../v2021_03_08/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2021_03_08/aio/_configuration.py | 8 +- .../v2021_03_08/aio/operations/__init__.py | 12 +- .../operations/_my_workbooks_operations.py | 198 +++---- .../v2021_03_08/models/__init__.py | 41 +- .../v2021_03_08/models/_models_py3.py | 4 +- .../v2021_03_08/operations/__init__.py | 12 +- .../operations/_my_workbooks_operations.py | 206 +++---- .../v2021_08_01/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2021_08_01/_configuration.py | 8 +- .../v2021_08_01/_metadata.json | 10 +- .../v2021_08_01/_vendor.py | 30 - .../v2021_08_01/_version.py | 2 +- .../v2021_08_01/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2021_08_01/aio/_configuration.py | 8 +- .../v2021_08_01/aio/operations/__init__.py | 12 +- .../aio/operations/_workbooks_operations.py | 250 +++----- .../v2021_08_01/models/__init__.py | 51 +- .../v2021_08_01/models/_models_py3.py | 63 +- .../v2021_08_01/operations/__init__.py | 12 +- .../operations/_workbooks_operations.py | 261 ++++----- .../applicationinsights/v2021_10/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2021_10/_configuration.py | 8 +- .../v2021_10/_metadata.json | 10 +- .../applicationinsights/v2021_10/_vendor.py | 30 - .../applicationinsights/v2021_10/_version.py | 2 +- .../v2021_10/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2021_10/aio/_configuration.py | 8 +- .../v2021_10/aio/operations/__init__.py | 12 +- .../aio/operations/_live_token_operations.py | 32 +- .../v2021_10/models/__init__.py | 25 +- .../v2021_10/models/_models_py3.py | 4 +- .../v2021_10/operations/__init__.py | 12 +- .../operations/_live_token_operations.py | 34 +- .../v2022_04_01/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2022_04_01/_configuration.py | 8 +- .../v2022_04_01/_metadata.json | 10 +- .../v2022_04_01/_vendor.py | 30 - .../v2022_04_01/_version.py | 2 +- .../v2022_04_01/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2022_04_01/aio/_configuration.py | 8 +- .../v2022_04_01/aio/operations/__init__.py | 12 +- .../aio/operations/_workbooks_operations.py | 250 +++----- .../v2022_04_01/models/__init__.py | 51 +- .../v2022_04_01/models/_models_py3.py | 63 +- .../v2022_04_01/operations/__init__.py | 12 +- .../operations/_workbooks_operations.py | 261 ++++----- .../v2022_06_15/__init__.py | 12 +- ..._application_insights_management_client.py | 36 +- .../v2022_06_15/_configuration.py | 8 +- .../v2022_06_15/_metadata.json | 10 +- .../v2022_06_15/_vendor.py | 30 - .../v2022_06_15/_version.py | 2 +- .../v2022_06_15/aio/__init__.py | 12 +- ..._application_insights_management_client.py | 38 +- .../v2022_06_15/aio/_configuration.py | 8 +- .../v2022_06_15/aio/operations/__init__.py | 12 +- .../aio/operations/_web_tests_operations.py | 229 +++----- .../v2022_06_15/models/__init__.py | 37 +- .../v2022_06_15/models/_models_py3.py | 12 +- .../v2022_06_15/operations/__init__.py | 12 +- .../operations/_web_tests_operations.py | 239 +++----- .../generated_samples/web_test_delete.py | 4 +- .../generated_samples/web_test_get.py | 1 + .../generated_samples/web_test_list.py | 1 + .../web_test_list_by_component.py | 1 + .../web_test_list_by_resource_group.py | 1 + .../generated_tests/conftest.py | 47 ++ ...nsights_management_web_tests_operations.py | 135 +++++ ...s_management_web_tests_operations_async.py | 136 +++++ .../azure-mgmt-applicationinsights/setup.py | 86 +-- 289 files changed, 7451 insertions(+), 8551 deletions(-) delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_vendor.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/conftest.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations_async.py diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/README.md b/sdk/applicationinsights/azure-mgmt-applicationinsights/README.md index d6ae8d08ae2d..27872204b7c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/README.md +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Application Insights 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 @@ -59,6 +59,3 @@ Code samples for this package can be found at: 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-applicationinsights%2FREADME.png) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json index 805f24b26fd0..e3a5d91b5c69 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e60df62e9e0d88462e6abba81a76d94eab000f0d", + "commit": "c94980e05045e33fc8ffd42c0797bcbc2ab2ff99", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.27.4", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/applicationinsights/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.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/applicationinsights/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/applicationinsights/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py index eae2afe782e1..b70373c5d8c4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -93,8 +96,28 @@ def __init__( profile: KnownProfiles=KnownProfiles.default, **kwargs: Any ): + if api_version: + kwargs.setdefault('api_version', api_version) self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **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) super(ApplicationInsightsManagementClient, self).__init__( api_version=api_version, profile=profile @@ -183,7 +206,7 @@ def analytics_items(self): else: raise ValueError("API version {} does not have operation group 'analytics_items'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def annotations(self): @@ -197,7 +220,7 @@ def annotations(self): else: raise ValueError("API version {} does not have operation group 'annotations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_keys(self): @@ -211,7 +234,7 @@ def api_keys(self): else: raise ValueError("API version {} does not have operation group 'api_keys'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_available_features(self): @@ -225,7 +248,7 @@ def component_available_features(self): else: raise ValueError("API version {} does not have operation group 'component_available_features'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_current_billing_features(self): @@ -239,7 +262,7 @@ def component_current_billing_features(self): else: raise ValueError("API version {} does not have operation group 'component_current_billing_features'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_current_pricing_plan(self): @@ -253,7 +276,7 @@ def component_current_pricing_plan(self): else: raise ValueError("API version {} does not have operation group 'component_current_pricing_plan'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_feature_capabilities(self): @@ -267,7 +290,7 @@ def component_feature_capabilities(self): else: raise ValueError("API version {} does not have operation group 'component_feature_capabilities'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_linked_storage_accounts(self): @@ -281,7 +304,7 @@ def component_linked_storage_accounts(self): else: raise ValueError("API version {} does not have operation group 'component_linked_storage_accounts'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_quota_status(self): @@ -295,7 +318,7 @@ def component_quota_status(self): else: raise ValueError("API version {} does not have operation group 'component_quota_status'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def components(self): @@ -318,7 +341,7 @@ def components(self): else: raise ValueError("API version {} does not have operation group 'components'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_list_migration_date(self): @@ -332,7 +355,7 @@ def ea_subscription_list_migration_date(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_list_migration_date'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_migrate_to_new_pricing_model(self): @@ -346,7 +369,7 @@ def ea_subscription_migrate_to_new_pricing_model(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_migrate_to_new_pricing_model'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_rollback_to_legacy_pricing_model(self): @@ -360,7 +383,7 @@ def ea_subscription_rollback_to_legacy_pricing_model(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_rollback_to_legacy_pricing_model'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def export_configurations(self): @@ -374,7 +397,7 @@ def export_configurations(self): else: raise ValueError("API version {} does not have operation group 'export_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def favorites(self): @@ -388,7 +411,7 @@ def favorites(self): else: raise ValueError("API version {} does not have operation group 'favorites'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def live_token(self): @@ -405,7 +428,7 @@ def live_token(self): else: raise ValueError("API version {} does not have operation group 'live_token'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def my_workbooks(self): @@ -422,7 +445,7 @@ def my_workbooks(self): else: raise ValueError("API version {} does not have operation group 'my_workbooks'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -445,7 +468,7 @@ def operations(self): else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def proactive_detection_configurations(self): @@ -462,7 +485,7 @@ def proactive_detection_configurations(self): else: raise ValueError("API version {} does not have operation group 'proactive_detection_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def web_test_locations(self): @@ -476,7 +499,7 @@ def web_test_locations(self): else: raise ValueError("API version {} does not have operation group 'web_test_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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def web_tests(self): @@ -496,7 +519,7 @@ def web_tests(self): else: raise ValueError("API version {} does not have operation group 'web_tests'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def work_item_configurations(self): @@ -510,7 +533,7 @@ def work_item_configurations(self): else: raise ValueError("API version {} does not have operation group 'work_item_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workbook_templates(self): @@ -527,7 +550,7 @@ def workbook_templates(self): else: raise ValueError("API version {} does not have operation group 'workbook_templates'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workbooks(self): @@ -550,7 +573,7 @@ def workbooks(self): else: raise ValueError("API version {} does not have operation group 'workbooks'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) def close(self): self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py index 203cbfc5c398..b2d1f4f97019 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- 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 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): +class ApplicationInsightsManagementClientConfiguration: """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, 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-applicationinsights/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_serialization.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_serialization.py index e3cc6ce6ed6f..a94487cbf17a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_serialization.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_serialization.py @@ -24,7 +24,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +51,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -63,8 +61,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") @@ -91,6 +89,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +112,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -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 @@ -153,6 +155,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +177,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: @@ -189,15 +189,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -211,7 +226,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -240,24 +255,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: - self.additional_properties: Dict[str, Any] = {} - for k in kwargs: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +329,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +365,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +378,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 +389,14 @@ 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( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -387,12 +425,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -402,7 +443,7 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -415,9 +456,10 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ 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( @@ -433,9 +475,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -447,7 +491,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): @@ -455,21 +499,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -508,11 +556,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -547,7 +597,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) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,17 +613,20 @@ 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 - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -599,12 +652,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -640,7 +695,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -651,7 +707,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,23 +720,24 @@ 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) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -709,18 +766,20 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access 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) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -731,30 +790,30 @@ 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: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - 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) @@ -764,19 +823,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -785,32 +845,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -825,12 +884,11 @@ 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) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -846,23 +904,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -876,8 +937,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -887,13 +947,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - 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'. + Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -905,9 +965,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) @@ -943,16 +1008,17 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -967,7 +1033,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -975,6 +1041,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -985,7 +1052,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) @@ -999,7 +1066,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1030,56 +1097,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1087,11 +1159,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1101,30 +1174,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1137,12 +1212,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1162,19 +1238,20 @@ 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): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1182,11 +1259,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1201,14 +1278,15 @@ 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:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1222,7 +1300,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:]) @@ -1230,17 +1307,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1277,7 +1366,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1329,22 +1418,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1352,7 +1440,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1361,9 +1449,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1471,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 @@ -1401,11 +1489,12 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1414,12 +1503,13 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1436,15 +1526,15 @@ 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): + if 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 + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1473,10 +1563,9 @@ 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) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1503,18 +1592,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, 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 # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1529,10 +1620,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1550,10 +1643,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1570,31 +1665,42 @@ 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 def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1603,15 +1709,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1732,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1644,15 +1755,15 @@ 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) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1669,6 +1780,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1679,11 +1791,12 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1692,7 +1805,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: @@ -1718,11 +1831,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1730,6 +1842,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1741,24 +1854,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1766,6 +1878,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1779,8 +1892,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1792,6 +1904,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1800,12 +1913,11 @@ 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: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1821,6 +1933,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1833,6 +1946,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1848,22 +1962,24 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ 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): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1876,6 +1992,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -1885,15 +2002,15 @@ 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) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -1902,13 +2019,14 @@ 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): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -1923,6 +2041,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1937,15 +2056,15 @@ 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) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1974,9 +2093,8 @@ 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) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1984,15 +2102,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py index ce030d0c5d7b..60e3b6217c5f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -93,8 +96,28 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: + if api_version: + kwargs.setdefault('api_version', api_version) self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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) super(ApplicationInsightsManagementClient, self).__init__( api_version=api_version, profile=profile @@ -183,7 +206,7 @@ def analytics_items(self): else: raise ValueError("API version {} does not have operation group 'analytics_items'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def annotations(self): @@ -197,7 +220,7 @@ def annotations(self): else: raise ValueError("API version {} does not have operation group 'annotations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_keys(self): @@ -211,7 +234,7 @@ def api_keys(self): else: raise ValueError("API version {} does not have operation group 'api_keys'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_available_features(self): @@ -225,7 +248,7 @@ def component_available_features(self): else: raise ValueError("API version {} does not have operation group 'component_available_features'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_current_billing_features(self): @@ -239,7 +262,7 @@ def component_current_billing_features(self): else: raise ValueError("API version {} does not have operation group 'component_current_billing_features'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_current_pricing_plan(self): @@ -253,7 +276,7 @@ def component_current_pricing_plan(self): else: raise ValueError("API version {} does not have operation group 'component_current_pricing_plan'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_feature_capabilities(self): @@ -267,7 +290,7 @@ def component_feature_capabilities(self): else: raise ValueError("API version {} does not have operation group 'component_feature_capabilities'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_linked_storage_accounts(self): @@ -281,7 +304,7 @@ def component_linked_storage_accounts(self): else: raise ValueError("API version {} does not have operation group 'component_linked_storage_accounts'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def component_quota_status(self): @@ -295,7 +318,7 @@ def component_quota_status(self): else: raise ValueError("API version {} does not have operation group 'component_quota_status'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def components(self): @@ -318,7 +341,7 @@ def components(self): else: raise ValueError("API version {} does not have operation group 'components'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_list_migration_date(self): @@ -332,7 +355,7 @@ def ea_subscription_list_migration_date(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_list_migration_date'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_migrate_to_new_pricing_model(self): @@ -346,7 +369,7 @@ def ea_subscription_migrate_to_new_pricing_model(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_migrate_to_new_pricing_model'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ea_subscription_rollback_to_legacy_pricing_model(self): @@ -360,7 +383,7 @@ def ea_subscription_rollback_to_legacy_pricing_model(self): else: raise ValueError("API version {} does not have operation group 'ea_subscription_rollback_to_legacy_pricing_model'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def export_configurations(self): @@ -374,7 +397,7 @@ def export_configurations(self): else: raise ValueError("API version {} does not have operation group 'export_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def favorites(self): @@ -388,7 +411,7 @@ def favorites(self): else: raise ValueError("API version {} does not have operation group 'favorites'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def live_token(self): @@ -405,7 +428,7 @@ def live_token(self): else: raise ValueError("API version {} does not have operation group 'live_token'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def my_workbooks(self): @@ -422,7 +445,7 @@ def my_workbooks(self): else: raise ValueError("API version {} does not have operation group 'my_workbooks'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -445,7 +468,7 @@ def operations(self): else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def proactive_detection_configurations(self): @@ -462,7 +485,7 @@ def proactive_detection_configurations(self): else: raise ValueError("API version {} does not have operation group 'proactive_detection_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def web_test_locations(self): @@ -476,7 +499,7 @@ def web_test_locations(self): else: raise ValueError("API version {} does not have operation group 'web_test_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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def web_tests(self): @@ -496,7 +519,7 @@ def web_tests(self): else: raise ValueError("API version {} does not have operation group 'web_tests'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def work_item_configurations(self): @@ -510,7 +533,7 @@ def work_item_configurations(self): else: raise ValueError("API version {} does not have operation group 'work_item_configurations'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workbook_templates(self): @@ -527,7 +550,7 @@ def workbook_templates(self): else: raise ValueError("API version {} does not have operation group 'workbook_templates'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workbooks(self): @@ -550,7 +573,7 @@ def workbooks(self): else: raise ValueError("API version {} does not have operation group 'workbooks'".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))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py index ab580a2f7b3a..fb5bd4f40a7f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- 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 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): +class ApplicationInsightsManagementClientConfiguration: """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, 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-applicationinsights/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py index 11708e3b2a5f..d15af6817708 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -36,11 +39,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class ApplicationInsightsManagementClient: # pylint: disable=too-many-instance-attributes """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations @@ -109,47 +111,79 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2015-05-01") + self.annotations = AnnotationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize, "2015-05-01") self.export_configurations = ExportConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_quota_status = ComponentQuotaStatusOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_available_features = ComponentAvailableFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) self.work_item_configurations = WorkItemConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.favorites = FavoritesOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) self.web_test_locations = WebTestLocationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.analytics_items = AnalyticsItemsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.my_workbooks = MyWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -169,12 +203,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py index be63336a92f3..c456e3306d68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-05-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json index 9f0a42785dff..ec57c150dcfd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py index f02ef1550bc0..7fe4752c869d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -36,11 +39,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class ApplicationInsightsManagementClient: # pylint: disable=too-many-instance-attributes """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations @@ -113,47 +115,81 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2015-05-01") + self.annotations = AnnotationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize, "2015-05-01") self.export_configurations = ExportConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_quota_status = ComponentQuotaStatusOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.component_available_features = ComponentAvailableFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) self.work_item_configurations = WorkItemConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.favorites = FavoritesOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) self.web_test_locations = WebTestLocationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.analytics_items = AnalyticsItemsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" + ) + self.my_workbooks = MyWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-05-01" ) - self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -173,12 +209,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py index 7a04a8487258..4838cab8ea8f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-05-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/__init__.py index 6a3cadab2ecf..a6e31fd3e1fd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/__init__.py @@ -5,27 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._annotations_operations import AnnotationsOperations -from ._api_keys_operations import APIKeysOperations -from ._export_configurations_operations import ExportConfigurationsOperations -from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations -from ._component_quota_status_operations import ComponentQuotaStatusOperations -from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations -from ._component_available_features_operations import ComponentAvailableFeaturesOperations -from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations -from ._components_operations import ComponentsOperations -from ._work_item_configurations_operations import WorkItemConfigurationsOperations -from ._favorites_operations import FavoritesOperations -from ._web_test_locations_operations import WebTestLocationsOperations -from ._web_tests_operations import WebTestsOperations -from ._analytics_items_operations import AnalyticsItemsOperations -from ._workbooks_operations import WorkbooksOperations -from ._my_workbooks_operations import MyWorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._annotations_operations import AnnotationsOperations # type: ignore +from ._api_keys_operations import APIKeysOperations # type: ignore +from ._export_configurations_operations import ExportConfigurationsOperations # type: ignore +from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations # type: ignore +from ._component_quota_status_operations import ComponentQuotaStatusOperations # type: ignore +from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations # type: ignore +from ._component_available_features_operations import ComponentAvailableFeaturesOperations # type: ignore +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._components_operations import ComponentsOperations # type: ignore +from ._work_item_configurations_operations import WorkItemConfigurationsOperations # type: ignore +from ._favorites_operations import FavoritesOperations # type: ignore +from ._web_test_locations_operations import WebTestLocationsOperations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore +from ._analytics_items_operations import AnalyticsItemsOperations # type: ignore +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._my_workbooks_operations import MyWorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -47,5 +53,5 @@ "WorkbooksOperations", "MyWorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py index ea1442a77aa0..d71373dda759 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._analytics_items_operations import ( build_delete_request, build_get_request, @@ -32,6 +31,10 @@ build_put_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -87,13 +91,12 @@ async def list( :param include_content: Flag indicating whether or not to return the content of each applicable item. If false, only return the item information. Default value is None. :type include_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,10 +107,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentAnalyticsItem]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -116,16 +119,14 @@ async def list( type=type, include_content=include_content, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,16 +135,12 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response) + deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -172,13 +169,12 @@ async def get( :param name: The name of a specific item defined in the Application Insights component. Default value is None. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,10 +185,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -200,16 +196,14 @@ async def get( id=id, name=name, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,16 +212,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", 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.insights/components/{resourceName}/{scopePath}/item" - } + return deserialized # type: ignore @overload async def put( @@ -262,7 +252,6 @@ async def put( :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem @@ -275,7 +264,7 @@ async def put( resource_group_name: str, resource_name: str, scope_path: Union[str, _models.ItemScopePath], - item_properties: IO, + item_properties: IO[bytes], override_item: Optional[bool] = None, *, content_type: str = "application/json", @@ -294,14 +283,13 @@ async def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. Required. - :type item_properties: IO + :type item_properties: IO[bytes] :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. Default value is None. :type override_item: bool :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem @@ -314,7 +302,7 @@ async def put( resource_group_name: str, resource_name: str, scope_path: Union[str, _models.ItemScopePath], - item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO], + item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO[bytes]], override_item: Optional[bool] = None, **kwargs: Any ) -> _models.ApplicationInsightsComponentAnalyticsItem: @@ -331,23 +319,19 @@ async def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. Is either a ApplicationInsightsComponentAnalyticsItem type - or a IO type. Required. + or a IO[bytes] type. Required. :type item_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem or - IO + IO[bytes] :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. Default value is None. :type override_item: bool - :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,19 +342,19 @@ async def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(item_properties, (IO, bytes)): + if isinstance(item_properties, (IOBase, bytes)): _content = item_properties else: _json = self._serialize.body(item_properties, "ApplicationInsightsComponentAnalyticsItem") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -380,16 +364,14 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -398,19 +380,15 @@ async def put( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, resource_name: str, @@ -436,12 +414,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param name: The name of a specific item defined in the Application Insights component. Default value is None. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,10 +429,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -463,16 +440,14 @@ async def delete( # pylint: disable=inconsistent-return-statements id=id, name=name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -482,8 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py index 3ac157beab4b..ba70caa5cb31 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._annotations_operations import ( build_create_request, build_delete_request, @@ -35,6 +34,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -74,7 +78,6 @@ def list( :type start: str :param end: The end time to query for annotations. Required. :type end: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Annotation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] @@ -83,10 +86,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.AnnotationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,19 +100,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, start=start, end=end, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -120,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AnnotationsListResult", pipeline_response) @@ -137,11 +137,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - } - @overload async def create( self, @@ -181,7 +177,6 @@ async def create( :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: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: @@ -192,7 +187,7 @@ async def create( self, resource_group_name: str, resource_name: str, - annotation_properties: IO, + annotation_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -206,11 +201,10 @@ async def create( :type resource_name: str :param annotation_properties: Properties that need to be specified to create an annotation of a Application Insights component. Required. - :type annotation_properties: IO + :type annotation_properties: 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 :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: @@ -221,7 +215,7 @@ async def create( self, resource_group_name: str, resource_name: str, - annotation_properties: Union[_models.Annotation, IO], + annotation_properties: Union[_models.Annotation, IO[bytes]], **kwargs: Any ) -> List[_models.Annotation]: """Create an Annotation of an Application Insights component. @@ -232,18 +226,14 @@ async def create( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param annotation_properties: Properties that need to be specified to create an annotation of a - Application Insights component. Is either a Annotation type or a IO type. Required. + Application Insights component. Is either a Annotation type or a IO[bytes] type. Required. :type annotation_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation 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 + IO[bytes] :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,19 +244,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(annotation_properties, (IO, bytes)): + if isinstance(annotation_properties, (IOBase, bytes)): _content = annotation_properties else: _json = self._serialize.body(annotation_properties, "Annotation") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -274,16 +264,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,21 +281,15 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[Annotation]", pipeline_response) + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any) -> None: """Delete an Annotation of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -318,12 +300,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param annotation_id: The unique annotation ID. This is unique within a Application Insights component. Required. :type annotation_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,25 +315,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, annotation_id=annotation_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,11 +341,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -382,12 +357,11 @@ async def get( :param annotation_id: The unique annotation ID. This is unique within a Application Insights component. Required. :type annotation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,25 +372,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, annotation_id=annotation_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -426,13 +398,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[Annotation]", pipeline_response) + deserialized = self._deserialize("[Annotation]", 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.Insights/components/{resourceName}/Annotations/{annotationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py index 2c416c939204..b3d49d198f2b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_keys_operations import ( build_create_request, build_delete_request, @@ -35,6 +34,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,11 +60,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponentAPIKey"]: + # pylint: disable=line-too-long """Gets a list of API keys of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,7 +74,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: @@ -79,10 +83,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,17 +97,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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 @@ -114,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) @@ -131,11 +132,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,10 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - } - @overload async def create( self, @@ -174,7 +171,6 @@ async def create( :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: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: @@ -185,7 +181,7 @@ async def create( self, resource_group_name: str, resource_name: str, - api_key_properties: IO, + api_key_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -199,11 +195,10 @@ async def create( :type resource_name: str :param api_key_properties: Properties that need to be specified to create an API key of a Application Insights component. Required. - :type api_key_properties: IO + :type api_key_properties: 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 :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: @@ -214,7 +209,7 @@ async def create( self, resource_group_name: str, resource_name: str, - api_key_properties: Union[_models.APIKeyRequest, IO], + api_key_properties: Union[_models.APIKeyRequest, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentAPIKey: """Create an API Key of an Application Insights component. @@ -225,18 +220,14 @@ async def create( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param api_key_properties: Properties that need to be specified to create an API key of a - Application Insights component. Is either a APIKeyRequest type or a IO type. Required. + Application Insights component. Is either a APIKeyRequest type or a IO[bytes] type. Required. :type api_key_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.APIKeyRequest 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 + IO[bytes] :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,19 +238,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(api_key_properties, (IO, bytes)): + if isinstance(api_key_properties, (IOBase, bytes)): _content = api_key_properties else: _json = self._serialize.body(api_key_properties, "APIKeyRequest") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -267,16 +258,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,16 +274,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - } + return deserialized # type: ignore @distributed_trace_async async def delete( @@ -310,12 +295,11 @@ async def delete( :param key_id: The API Key ID. This is unique within a Application Insights component. Required. :type key_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -326,25 +310,23 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, key_id=key_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -353,16 +335,12 @@ async def delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -378,12 +356,11 @@ async def get( :param key_id: The API Key ID. This is unique within a Application Insights component. Required. :type key_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,25 +371,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, key_id=key_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", 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.Insights/components/{resourceName}/APIKeys/{keyId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py index 8d94d43f51e8..4c2c93f880a0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_available_features_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -61,13 +64,12 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAvailableFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,24 +80,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAvailableFeatures] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -104,13 +104,11 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAvailableFeatures", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentAvailableFeatures", 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.Insights/components/{resourceName}/getavailablebillingfeatures" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py index 3c063ee42e45..a5ddba608aff 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,21 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_current_billing_features_operations import build_get_request, build_update_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ComponentCurrentBillingFeaturesOperations: +class ComponentCurrentBillingFeaturesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -49,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -61,13 +65,12 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,24 +81,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -104,16 +105,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures" - } + return deserialized # type: ignore @overload async def update( @@ -139,7 +136,6 @@ async def update( :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: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures @@ -151,7 +147,7 @@ async def update( self, resource_group_name: str, resource_name: str, - billing_features_properties: IO, + billing_features_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -165,11 +161,10 @@ async def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. Required. - :type billing_features_properties: IO + :type billing_features_properties: 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 :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures @@ -181,7 +176,7 @@ async def update( self, resource_group_name: str, resource_name: str, - billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO], + billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentBillingFeatures: """Update current billing features for an Application Insights component. @@ -193,20 +188,16 @@ async def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. Is either a - ApplicationInsightsComponentBillingFeatures type or a IO type. Required. + ApplicationInsightsComponentBillingFeatures type or a IO[bytes] type. Required. :type billing_features_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures - 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 + or IO[bytes] :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,19 +208,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(billing_features_properties, (IO, bytes)): + if isinstance(billing_features_properties, (IOBase, bytes)): _content = billing_features_properties else: _json = self._serialize.body(billing_features_properties, "ApplicationInsightsComponentBillingFeatures") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -237,16 +228,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -255,13 +244,9 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", 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.Insights/components/{resourceName}/currentbillingfeatures" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py index 56fbfa33e895..502fc6d50992 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_feature_capabilities_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -61,13 +64,12 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFeatureCapabilities or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,24 +80,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentFeatureCapabilities] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -104,13 +104,11 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFeatureCapabilities", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentFeatureCapabilities", 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.Insights/components/{resourceName}/featurecapabilities" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py index 92a49f5960c4..ac42b4dd23e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_quota_status_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -61,13 +64,12 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentQuotaStatus or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,24 +80,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentQuotaStatus] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -104,13 +104,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py index 0dc841745dd0..41496c734d55 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._components_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,12 +64,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -76,10 +80,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +94,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +111,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -126,11 +127,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,18 +143,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -163,10 +162,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,16 +176,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 @@ -197,14 +194,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -214,11 +210,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,14 +226,8 @@ 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.Insights/components" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -245,12 +235,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,24 +250,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,11 +275,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -305,12 +288,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,24 +303,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,16 +327,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -383,7 +359,6 @@ async def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -394,7 +369,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -409,11 +384,10 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -424,7 +398,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -436,18 +410,15 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,19 +429,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -478,16 +449,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -496,16 +465,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -529,7 +494,6 @@ async def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -540,7 +504,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -553,11 +517,10 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -568,7 +531,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -579,17 +542,14 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. - :type component_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,19 +560,19 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -620,16 +580,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -638,16 +596,12 @@ async def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def purge( @@ -678,7 +632,6 @@ async def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -689,7 +642,7 @@ async def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -709,11 +662,10 @@ async def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +673,11 @@ async def purge( @distributed_trace_async async def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -737,17 +693,13 @@ async def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBody or IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,19 +710,19 @@ async def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -778,16 +730,14 @@ async def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,16 +746,12 @@ async def purge( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def get_purge_status( @@ -821,12 +767,11 @@ async def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -837,25 +782,23 @@ async def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,13 +807,9 @@ async def get_purge_status( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py index 6fd255497110..a4f867d097f4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._export_configurations_operations import ( build_create_request, build_delete_request, @@ -33,6 +32,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -67,13 +71,12 @@ async def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,24 +87,22 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,16 +111,14 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentExportConfiguration]", pipeline_response) + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - } + return deserialized # type: ignore @overload async def create( @@ -145,7 +144,6 @@ async def create( :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: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] @@ -157,7 +155,7 @@ async def create( self, resource_group_name: str, resource_name: str, - export_properties: IO, + export_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -171,11 +169,10 @@ async def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. Required. - :type export_properties: IO + :type export_properties: 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 :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] @@ -187,7 +184,7 @@ async def create( self, resource_group_name: str, resource_name: str, - export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO], + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], **kwargs: Any ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: """Create a Continuous Export configuration of an Application Insights component. @@ -199,20 +196,16 @@ async def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. Is either a - ApplicationInsightsComponentExportRequest type or a IO type. Required. + ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest 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 + IO[bytes] :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -223,19 +216,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_properties, (IO, bytes)): + if isinstance(export_properties, (IOBase, bytes)): _content = export_properties else: _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -243,16 +236,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,16 +252,14 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentExportConfiguration]", pipeline_response) + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - } + return deserialized # type: ignore @distributed_trace_async async def delete( @@ -286,13 +275,12 @@ async def delete( :param export_id: The Continuous Export configuration ID. This is unique within a Application Insights component. Required. :type export_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,25 +291,23 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -330,16 +316,14 @@ async def delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -355,13 +339,12 @@ async def get( :param export_id: The Continuous Export configuration ID. This is unique within a Application Insights component. Required. :type export_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,25 +355,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -399,16 +380,14 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", 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.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore @overload async def update( @@ -438,7 +417,6 @@ async def update( :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: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration @@ -451,7 +429,7 @@ async def update( resource_group_name: str, resource_name: str, export_id: str, - export_properties: IO, + export_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -468,11 +446,10 @@ async def update( :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export configuration. Required. - :type export_properties: IO + :type export_properties: 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 :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration @@ -485,7 +462,7 @@ async def update( resource_group_name: str, resource_name: str, export_id: str, - export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO], + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentExportConfiguration: """Update the Continuous Export configuration for this export id. @@ -499,21 +476,17 @@ async def update( Insights component. Required. :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export - configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO type. + configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest 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 + IO[bytes] :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,19 +497,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_properties, (IO, bytes)): + if isinstance(export_properties, (IOBase, bytes)): _content = export_properties else: _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, @@ -545,16 +518,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -563,13 +534,11 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", 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.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py index 3391029fb79a..b1aec23b2a0e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._favorites_operations import ( build_add_request, build_delete_request, @@ -33,6 +32,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -87,13 +91,12 @@ async def list( :type can_fetch_content: bool :param tags: Tags that must be present on each favorite returned. Default value is None. :type tags: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,10 +107,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentFavorite]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -116,16 +119,14 @@ async def list( can_fetch_content=can_fetch_content, tags=tags, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,16 +135,12 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response) + deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -159,12 +156,11 @@ async def get( :param favorite_id: The Id of a specific favorite defined in the Application Insights component. Required. :type favorite_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,25 +171,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,16 +196,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", 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.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @overload async def add( @@ -241,7 +231,6 @@ async def add( :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: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -253,7 +242,7 @@ async def add( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: IO, + favorite_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +259,10 @@ async def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. Required. - :type favorite_properties: IO + :type favorite_properties: 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 :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +274,7 @@ async def add( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO], + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentFavorite: """Adds a new favorites to an Application Insights component. @@ -301,18 +289,15 @@ async def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. Is either a ApplicationInsightsComponentFavorite - type or a IO type. Required. + type or a IO[bytes] type. Required. :type favorite_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite or + IO[bytes] :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,19 +308,19 @@ async def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(favorite_properties, (IO, bytes)): + if isinstance(favorite_properties, (IOBase, bytes)): _content = favorite_properties else: _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") - request = build_add_request( + _request = build_add_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, @@ -344,16 +329,14 @@ async def add( content_type=content_type, json=_json, content=_content, - template_url=self.add.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,16 +345,12 @@ async def add( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - add.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @overload async def update( @@ -401,7 +380,6 @@ async def update( :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: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -413,7 +391,7 @@ async def update( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: IO, + favorite_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +408,10 @@ async def update( :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing favorite. Required. - :type favorite_properties: IO + :type favorite_properties: 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 :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +423,7 @@ async def update( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO], + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentFavorite: """Updates a favorite that has already been added to an Application Insights component. @@ -460,18 +437,15 @@ async def update( component. Required. :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing - favorite. Is either a ApplicationInsightsComponentFavorite type or a IO type. Required. + favorite. Is either a ApplicationInsightsComponentFavorite type or a IO[bytes] type. Required. :type favorite_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite or + IO[bytes] :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,19 +456,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(favorite_properties, (IO, bytes)): + if isinstance(favorite_properties, (IOBase, bytes)): _content = favorite_properties else: _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, @@ -503,16 +477,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,21 +493,15 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", 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.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any) -> None: """Remove a favorite that is associated to an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -546,12 +512,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param favorite_id: The Id of a specific favorite defined in the Application Insights component. Required. :type favorite_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,25 +527,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -590,8 +553,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py index 67c1fd59e11f..3155224ce1e8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._my_workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,6 +62,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -83,7 +87,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook] @@ -92,10 +95,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,19 +109,17 @@ 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -129,14 +130,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -146,11 +146,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,10 +163,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.Insights/myWorkbooks" - } - @distributed_trace def list_by_subscription( self, @@ -186,7 +182,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook] @@ -195,10 +190,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,18 +204,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -231,14 +224,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -248,11 +240,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,8 +257,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks"} - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.MyWorkbook: """Get a single private workbook by its resourceName. @@ -276,12 +266,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,24 +281,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: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,21 +306,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -341,12 +322,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,24 +337,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -385,11 +363,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/myWorkbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -414,7 +388,6 @@ async def create_or_update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +398,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -439,11 +412,10 @@ async def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -454,7 +426,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], **kwargs: Any ) -> _models.MyWorkbook: """Create a new private workbook. @@ -465,17 +437,14 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook 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 + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook or + IO[bytes] :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,19 +455,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - 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, @@ -506,16 +475,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,21 +492,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MyWorkbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}" - } - @overload async def update( self, @@ -563,7 +522,6 @@ async def update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -574,7 +532,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -588,11 +546,10 @@ async def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -603,7 +560,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], **kwargs: Any ) -> _models.MyWorkbook: """Updates a private workbook that has already been added. @@ -614,17 +571,14 @@ async def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook 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 + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook or + IO[bytes] :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -635,19 +589,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -655,16 +609,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -674,13 +626,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py index 2ea7ada16b83..f778bb328f8a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,12 +53,12 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available insights REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] @@ -65,10 +67,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,14 +81,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,14 +97,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -114,11 +113,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py index e503e55868fe..93694e82538e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,25 +18,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._proactive_detection_configurations_operations import ( build_get_request, build_list_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProactiveDetectionConfigurationsOperations: +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -53,11 +56,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + # pylint: disable=line-too-long """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,14 +70,13 @@ async def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,26 +87,24 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( "cls", None ) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,17 +114,13 @@ async def list( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -138,14 +136,13 @@ async def get( :param configuration_id: The ProactiveDetection configuration ID. This is unique within a Application Insights component. Required. :type configuration_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,25 +153,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,17 +179,13 @@ async def get( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore @overload async def update( @@ -224,7 +215,6 @@ async def update( :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: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -238,7 +228,7 @@ async def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: IO, + proactive_detection_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -255,11 +245,10 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Required. - :type proactive_detection_properties: IO + :type proactive_detection_properties: 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 :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -273,7 +262,9 @@ async def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: Union[_models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO], + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: """Update the ProactiveDetection configuration for this configuration id. @@ -288,21 +279,17 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Is either a - ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO type. Required. + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration - 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 + or IO[bytes] :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,21 +300,21 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(proactive_detection_properties, (IO, bytes)): + if isinstance(proactive_detection_properties, (IOBase, bytes)): _content = proactive_detection_properties else: _json = self._serialize.body( proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, @@ -336,16 +323,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,14 +340,10 @@ async def update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py index a3025fca520c..787df4981769 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._web_test_locations_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,11 +53,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponentWebTestLocation"]: + # pylint: disable=line-too-long """Gets a list of web test locations available to this Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -63,7 +67,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 ApplicationInsightsComponentWebTestLocation or the result of cls(response) :rtype: @@ -73,10 +76,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsWebTestLocationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,17 +90,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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 @@ -108,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) @@ -125,11 +125,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,7 +140,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py index 102f76ab028e..f737bd4beb94 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._web_tests_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +37,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +63,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: @@ -68,7 +72,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -77,10 +80,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,16 +94,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_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 @@ -111,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -128,11 +128,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,10 +144,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.Insights/webtests" - } - @distributed_trace_async async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -157,12 +153,11 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) :type resource_group_name: str :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,24 +168,22 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,16 +192,12 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", 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.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -233,7 +222,6 @@ async def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +232,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -258,11 +246,10 @@ async def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +260,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -284,17 +271,15 @@ async def create_or_update( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. - :type web_test_definition: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest 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 + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,19 +290,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -325,16 +310,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -343,16 +326,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -376,7 +355,6 @@ async def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -387,7 +365,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -400,11 +378,10 @@ async def update_tags( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -415,7 +392,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -426,17 +403,14 @@ async def update_tags( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Is either a - TagsResource type or a IO type. Required. - :type web_test_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,19 +421,19 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -467,16 +441,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,21 +457,15 @@ async def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, web_test_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> None: """Deletes an Application Insights web test. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -507,12 +473,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,24 +488,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -550,17 +513,12 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: """Get all Application Insights web test alerts definitions within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -569,10 +527,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,15 +541,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -602,14 +558,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -619,11 +574,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -635,8 +590,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -648,7 +601,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -657,10 +609,10 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,17 +623,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -692,14 +642,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -709,11 +658,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -724,7 +673,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py index 502381a7c72f..1c4e91c17be8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._work_item_configurations_operations import ( build_create_request, build_delete_request, @@ -37,6 +36,10 @@ build_update_item_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,11 +62,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.WorkItemConfiguration"]: + # pylint: disable=line-too-long """Gets the list work item configurations that exist for the application. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -71,7 +76,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 WorkItemConfiguration or the result of cls(response) :rtype: @@ -81,10 +85,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfigurationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +99,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) @@ -133,11 +134,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +151,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - } - @overload async def create( self, @@ -178,7 +175,6 @@ async def create( :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: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -189,7 +185,7 @@ async def create( self, resource_group_name: str, resource_name: str, - work_item_configuration_properties: IO, + work_item_configuration_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -203,11 +199,10 @@ async def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. Required. - :type work_item_configuration_properties: IO + :type work_item_configuration_properties: 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 :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -218,7 +213,7 @@ async def create( self, resource_group_name: str, resource_name: str, - work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO], + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], **kwargs: Any ) -> _models.WorkItemConfiguration: """Create a work item configuration for an Application Insights component. @@ -230,18 +225,14 @@ async def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. Is either a - WorkItemCreateConfiguration type or a IO type. Required. + WorkItemCreateConfiguration type or a IO[bytes] type. Required. :type work_item_configuration_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration or IO[bytes] :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,19 +243,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(work_item_configuration_properties, (IO, bytes)): + if isinstance(work_item_configuration_properties, (IOBase, bytes)): _content = work_item_configuration_properties else: _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -272,16 +263,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,16 +279,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - } + return deserialized # type: ignore @distributed_trace_async async def get_default( @@ -312,12 +297,11 @@ async def get_default( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,24 +312,22 @@ async def get_default( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) - request = build_get_default_request( + _request = build_get_default_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_default.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,19 +336,15 @@ async def get_default( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, resource_name: str, work_item_config_id: str, **kwargs: Any ) -> None: """Delete a work item configuration of an Application Insights component. @@ -379,12 +357,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param work_item_config_id: The unique work item configuration Id. This can be either friendly name of connector as defined in connector configuration. Required. :type work_item_config_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,25 +372,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -423,11 +398,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_item( @@ -443,12 +414,11 @@ async def get_item( :param work_item_config_id: The unique work item configuration Id. This can be either friendly name of connector as defined in connector configuration. Required. :type work_item_config_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,25 +429,23 @@ async def get_item( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) - request = build_get_item_request( + _request = build_get_item_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_item.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -486,16 +454,12 @@ async def get_item( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_item.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return deserialized # type: ignore @overload async def update_item( @@ -525,7 +489,6 @@ async def update_item( :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: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -537,7 +500,7 @@ async def update_item( resource_group_name: str, resource_name: str, work_item_config_id: str, - work_item_configuration_properties: IO, + work_item_configuration_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -554,11 +517,10 @@ async def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. Required. - :type work_item_configuration_properties: IO + :type work_item_configuration_properties: 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 :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -570,7 +532,7 @@ async def update_item( resource_group_name: str, resource_name: str, work_item_config_id: str, - work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO], + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], **kwargs: Any ) -> _models.WorkItemConfiguration: """Update a work item configuration for an Application Insights component. @@ -585,18 +547,14 @@ async def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. Is either a - WorkItemCreateConfiguration type or a IO type. Required. + WorkItemCreateConfiguration type or a IO[bytes] type. Required. :type work_item_configuration_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration or IO[bytes] :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -607,19 +565,19 @@ async def update_item( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(work_item_configuration_properties, (IO, bytes)): + if isinstance(work_item_configuration_properties, (IOBase, bytes)): _content = work_item_configuration_properties else: _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") - request = build_update_item_request( + _request = build_update_item_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, @@ -628,16 +586,14 @@ async def update_item( content_type=content_type, json=_json, content=_content, - template_url=self.update_item.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -646,13 +602,9 @@ async def update_item( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_item.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py index 62379f3353d1..36276cde98fa 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,6 +61,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -82,7 +86,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook] @@ -91,10 +94,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,19 +108,17 @@ 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -128,14 +129,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -145,11 +145,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,10 +162,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.insights/workbooks" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.Workbook: """Get a single workbook by its resourceName. @@ -175,12 +171,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,24 +186,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: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.Workbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,21 +211,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -240,12 +227,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,24 +242,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,11 +268,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -313,7 +293,6 @@ async def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +303,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -338,11 +317,10 @@ async def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -353,7 +331,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Create a new workbook. @@ -364,17 +342,14 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook 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 + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,19 +360,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -405,16 +380,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,21 +397,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}" - } - @overload async def update( self, @@ -462,7 +427,6 @@ async def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -473,7 +437,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -487,11 +451,10 @@ async def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -502,7 +465,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -513,17 +476,14 @@ async def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook 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 + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -534,19 +494,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -554,16 +514,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +531,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py index 6b6f106aa216..e51fb7fa8416 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py @@ -5,79 +5,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import APIKeyRequest -from ._models_py3 import Annotation -from ._models_py3 import AnnotationError -from ._models_py3 import AnnotationsListResult -from ._models_py3 import ApplicationInsightsComponent -from ._models_py3 import ApplicationInsightsComponentAPIKey -from ._models_py3 import ApplicationInsightsComponentAPIKeyListResult -from ._models_py3 import ApplicationInsightsComponentAnalyticsItem -from ._models_py3 import ApplicationInsightsComponentAnalyticsItemProperties -from ._models_py3 import ApplicationInsightsComponentAvailableFeatures -from ._models_py3 import ApplicationInsightsComponentBillingFeatures -from ._models_py3 import ApplicationInsightsComponentDataVolumeCap -from ._models_py3 import ApplicationInsightsComponentExportConfiguration -from ._models_py3 import ApplicationInsightsComponentExportRequest -from ._models_py3 import ApplicationInsightsComponentFavorite -from ._models_py3 import ApplicationInsightsComponentFeature -from ._models_py3 import ApplicationInsightsComponentFeatureCapabilities -from ._models_py3 import ApplicationInsightsComponentFeatureCapability -from ._models_py3 import ApplicationInsightsComponentListResult -from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration -from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions -from ._models_py3 import ApplicationInsightsComponentQuotaStatus -from ._models_py3 import ApplicationInsightsComponentWebTestLocation -from ._models_py3 import ApplicationInsightsWebTestLocationsListResult -from ._models_py3 import ComponentPurgeBody -from ._models_py3 import ComponentPurgeBodyFilters -from ._models_py3 import ComponentPurgeResponse -from ._models_py3 import ComponentPurgeStatusResponse -from ._models_py3 import ComponentsResource -from ._models_py3 import ErrorFieldContract -from ._models_py3 import ErrorResponse -from ._models_py3 import InnerError -from ._models_py3 import LinkProperties -from ._models_py3 import MyWorkbook -from ._models_py3 import MyWorkbookError -from ._models_py3 import MyWorkbookResource -from ._models_py3 import MyWorkbooksListResult -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateLinkScopedResource -from ._models_py3 import TagsResource -from ._models_py3 import WebTest -from ._models_py3 import WebTestGeolocation -from ._models_py3 import WebTestListResult -from ._models_py3 import WebTestPropertiesConfiguration -from ._models_py3 import WebtestsResource -from ._models_py3 import WorkItemConfiguration -from ._models_py3 import WorkItemConfigurationError -from ._models_py3 import WorkItemConfigurationsListResult -from ._models_py3 import WorkItemCreateConfiguration -from ._models_py3 import Workbook -from ._models_py3 import WorkbookError -from ._models_py3 import WorkbookResource -from ._models_py3 import WorkbooksListResult +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import ApplicationType -from ._application_insights_management_client_enums import CategoryType -from ._application_insights_management_client_enums import FavoriteSourceType -from ._application_insights_management_client_enums import FavoriteType -from ._application_insights_management_client_enums import FlowType -from ._application_insights_management_client_enums import IngestionMode -from ._application_insights_management_client_enums import ItemScope -from ._application_insights_management_client_enums import ItemScopePath -from ._application_insights_management_client_enums import ItemType -from ._application_insights_management_client_enums import ItemTypeParameter -from ._application_insights_management_client_enums import PurgeState -from ._application_insights_management_client_enums import RequestSource -from ._application_insights_management_client_enums import SharedTypeKind -from ._application_insights_management_client_enums import WebTestKind +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + APIKeyRequest, + Annotation, + AnnotationError, + AnnotationsListResult, + ApplicationInsightsComponent, + ApplicationInsightsComponentAPIKey, + ApplicationInsightsComponentAPIKeyListResult, + ApplicationInsightsComponentAnalyticsItem, + ApplicationInsightsComponentAnalyticsItemProperties, + ApplicationInsightsComponentAvailableFeatures, + ApplicationInsightsComponentBillingFeatures, + ApplicationInsightsComponentDataVolumeCap, + ApplicationInsightsComponentExportConfiguration, + ApplicationInsightsComponentExportRequest, + ApplicationInsightsComponentFavorite, + ApplicationInsightsComponentFeature, + ApplicationInsightsComponentFeatureCapabilities, + ApplicationInsightsComponentFeatureCapability, + ApplicationInsightsComponentListResult, + ApplicationInsightsComponentProactiveDetectionConfiguration, + ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions, + ApplicationInsightsComponentQuotaStatus, + ApplicationInsightsComponentWebTestLocation, + ApplicationInsightsWebTestLocationsListResult, + ComponentPurgeBody, + ComponentPurgeBodyFilters, + ComponentPurgeResponse, + ComponentPurgeStatusResponse, + ComponentsResource, + ErrorFieldContract, + ErrorResponse, + InnerError, + LinkProperties, + MyWorkbook, + MyWorkbookError, + MyWorkbookResource, + MyWorkbooksListResult, + Operation, + OperationDisplay, + OperationListResult, + PrivateLinkScopedResource, + TagsResource, + WebTest, + WebTestGeolocation, + WebTestListResult, + WebTestPropertiesConfiguration, + WebtestsResource, + WorkItemConfiguration, + WorkItemConfigurationError, + WorkItemConfigurationsListResult, + WorkItemCreateConfiguration, + Workbook, + WorkbookError, + WorkbookResource, + WorkbooksListResult, +) + +from ._application_insights_management_client_enums import ( # type: ignore + ApplicationType, + CategoryType, + FavoriteSourceType, + FavoriteType, + FlowType, + IngestionMode, + ItemScope, + ItemScopePath, + ItemType, + ItemTypeParameter, + PurgeState, + RequestSource, + SharedTypeKind, + WebTestKind, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -151,5 +162,5 @@ "SharedTypeKind", "WebTestKind", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py index ed86c8ac8ede..5dac870ef754 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py @@ -1,5 +1,5 @@ -# coding=utf-8 # 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. @@ -13,7 +13,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -183,7 +182,7 @@ class ComponentsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -227,12 +226,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class ApplicationInsightsComponent(ComponentsResource): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponent(ComponentsResource): """An Application Insights component 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -428,7 +427,7 @@ def __init__( # pylint: disable=too-many-locals self.ingestion_mode = ingestion_mode -class ApplicationInsightsComponentAnalyticsItem(_serialization.Model): +class ApplicationInsightsComponentAnalyticsItem(_serialization.Model): # pylint: disable=name-too-long """Properties that define an Analytics item that is associated to an Application Insights component. @@ -520,7 +519,7 @@ def __init__( self.properties = properties -class ApplicationInsightsComponentAnalyticsItemProperties(_serialization.Model): +class ApplicationInsightsComponentAnalyticsItemProperties(_serialization.Model): # pylint: disable=name-too-long """A set of properties that can be defined in the context of a specific item type. Each type may have its own properties. @@ -603,10 +602,10 @@ def __init__( self.linked_write_properties = linked_write_properties -class ApplicationInsightsComponentAPIKeyListResult(_serialization.Model): +class ApplicationInsightsComponentAPIKeyListResult(_serialization.Model): # pylint: disable=name-too-long """Describes the list of API Keys of an Application Insights Component. - 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 value: List of API Key definitions. Required. :vartype value: @@ -631,7 +630,7 @@ def __init__(self, *, value: List["_models.ApplicationInsightsComponentAPIKey"], self.value = value -class ApplicationInsightsComponentAvailableFeatures(_serialization.Model): +class ApplicationInsightsComponentAvailableFeatures(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component available features. Variables are only populated by the server, and will be ignored when sending a request. @@ -655,7 +654,7 @@ def __init__(self, **kwargs: Any) -> None: self.result = None -class ApplicationInsightsComponentBillingFeatures(_serialization.Model): +class ApplicationInsightsComponentBillingFeatures(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component billing features. :ivar data_volume_cap: An Application Insights component daily data volume cap. @@ -691,7 +690,7 @@ def __init__( self.current_billing_features = current_billing_features -class ApplicationInsightsComponentDataVolumeCap(_serialization.Model): +class ApplicationInsightsComponentDataVolumeCap(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component daily data volume cap. Variables are only populated by the server, and will be ignored when sending a request. @@ -754,9 +753,7 @@ def __init__( self.max_history_cap = None -class ApplicationInsightsComponentExportConfiguration( - _serialization.Model -): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponentExportConfiguration(_serialization.Model): # pylint: disable=name-too-long """Properties that define a Continuous Export configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -883,7 +880,7 @@ def __init__( self.container_name = None -class ApplicationInsightsComponentExportRequest(_serialization.Model): +class ApplicationInsightsComponentExportRequest(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component Continuous Export configuration request definition. :ivar record_types: The document types to be exported, as comma separated values. Allowed @@ -974,7 +971,7 @@ def __init__( self.destination_account_id = destination_account_id -class ApplicationInsightsComponentFavorite(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponentFavorite(_serialization.Model): """Properties that define a favorite that is associated to an Application Insights component. Variables are only populated by the server, and will be ignored when sending a request. @@ -1145,9 +1142,7 @@ def __init__(self, **kwargs: Any) -> None: self.supported_addon_features = None -class ApplicationInsightsComponentFeatureCapabilities( - _serialization.Model -): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponentFeatureCapabilities(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component feature capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -1245,7 +1240,7 @@ def __init__(self, **kwargs: Any) -> None: self.throttle_rate = None -class ApplicationInsightsComponentFeatureCapability(_serialization.Model): +class ApplicationInsightsComponentFeatureCapability(_serialization.Model): # pylint: disable=name-too-long """An Application Insights component feature capability. Variables are only populated by the server, and will be ignored when sending a request. @@ -1296,7 +1291,7 @@ def __init__(self, **kwargs: Any) -> None: class ApplicationInsightsComponentListResult(_serialization.Model): """Describes the list of Application Insights Resources. - 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 value: List of Application Insights component definitions. Required. :vartype value: @@ -1331,7 +1326,9 @@ def __init__( self.next_link = next_link -class ApplicationInsightsComponentProactiveDetectionConfiguration(_serialization.Model): +class ApplicationInsightsComponentProactiveDetectionConfiguration( + _serialization.Model +): # pylint: disable=name-too-long """Properties that define a ProactiveDetection configuration. :ivar name: The rule name. @@ -1348,17 +1345,17 @@ class ApplicationInsightsComponentProactiveDetectionConfiguration(_serialization :ivar rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). :vartype rule_definitions: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions # pylint: disable=line-too-long """ _attribute_map = { - "name": {"key": "Name", "type": "str"}, - "enabled": {"key": "Enabled", "type": "bool"}, - "send_emails_to_subscription_owners": {"key": "SendEmailsToSubscriptionOwners", "type": "bool"}, - "custom_emails": {"key": "CustomEmails", "type": "[str]"}, - "last_updated_time": {"key": "LastUpdatedTime", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "send_emails_to_subscription_owners": {"key": "sendEmailsToSubscriptionOwners", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "str"}, "rule_definitions": { - "key": "RuleDefinitions", + "key": "ruleDefinitions", "type": "ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions", }, } @@ -1391,7 +1388,7 @@ def __init__( :keyword rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). :paramtype rule_definitions: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions # pylint: disable=line-too-long """ super().__init__(**kwargs) self.name = name @@ -1402,7 +1399,9 @@ def __init__( self.rule_definitions = rule_definitions -class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions(_serialization.Model): +class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions( + _serialization.Model +): # pylint: disable=name-too-long """Static definitions of the ProactiveDetection configuration rule (same values for all components). @@ -1514,7 +1513,7 @@ def __init__(self, **kwargs: Any) -> None: self.expiration_time = None -class ApplicationInsightsComponentWebTestLocation(_serialization.Model): +class ApplicationInsightsComponentWebTestLocation(_serialization.Model): # pylint: disable=name-too-long """Properties that define a web test location available to an Application Insights Component. Variables are only populated by the server, and will be ignored when sending a request. @@ -1542,10 +1541,10 @@ def __init__(self, **kwargs: Any) -> None: self.tag = None -class ApplicationInsightsWebTestLocationsListResult(_serialization.Model): +class ApplicationInsightsWebTestLocationsListResult(_serialization.Model): # pylint: disable=name-too-long """Describes the list of web test locations available to an Application Insights Component. - 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 value: List of web test locations. Required. :vartype value: @@ -1573,7 +1572,7 @@ def __init__(self, *, value: List["_models.ApplicationInsightsComponentWebTestLo class ComponentPurgeBody(_serialization.Model): """Describes the body of a purge request for an App Insights component. - 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 table: Table from which to purge data. Required. :vartype table: str @@ -1664,7 +1663,7 @@ def __init__( class ComponentPurgeResponse(_serialization.Model): """Response containing operationId for a specific purge action. - 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 operation_id: Id to use when querying for status for a particular purge operation. Required. @@ -1692,7 +1691,7 @@ def __init__(self, *, operation_id: str, **kwargs: Any) -> None: class ComponentPurgeStatusResponse(_serialization.Model): """Response containing status for a specific purge operation. - 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 status: Status of the operation represented by the requested Id. Required. Known values are: "pending" and "completed". @@ -1898,7 +1897,7 @@ def __init__( self.tags = tags -class MyWorkbook(MyWorkbookResource): # pylint: disable=too-many-instance-attributes +class MyWorkbook(MyWorkbookResource): """An Application Insights private workbook definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2231,7 +2230,7 @@ class WebtestsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -2275,12 +2274,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class WebTest(WebtestsResource): # pylint: disable=too-many-instance-attributes +class WebTest(WebtestsResource): """An Application Insights web test 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -2445,7 +2444,7 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: class WebTestListResult(_serialization.Model): """A list of 0 or more Application Insights web test definitions. - 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 value: Set of Application Insights web test definitions. Required. :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -2542,7 +2541,7 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s self.tags = tags -class Workbook(WorkbookResource): # pylint: disable=too-many-instance-attributes +class Workbook(WorkbookResource): """An Application Insights workbook definition. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/__init__.py index 6a3cadab2ecf..a6e31fd3e1fd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/__init__.py @@ -5,27 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._annotations_operations import AnnotationsOperations -from ._api_keys_operations import APIKeysOperations -from ._export_configurations_operations import ExportConfigurationsOperations -from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations -from ._component_quota_status_operations import ComponentQuotaStatusOperations -from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations -from ._component_available_features_operations import ComponentAvailableFeaturesOperations -from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations -from ._components_operations import ComponentsOperations -from ._work_item_configurations_operations import WorkItemConfigurationsOperations -from ._favorites_operations import FavoritesOperations -from ._web_test_locations_operations import WebTestLocationsOperations -from ._web_tests_operations import WebTestsOperations -from ._analytics_items_operations import AnalyticsItemsOperations -from ._workbooks_operations import WorkbooksOperations -from ._my_workbooks_operations import MyWorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._annotations_operations import AnnotationsOperations # type: ignore +from ._api_keys_operations import APIKeysOperations # type: ignore +from ._export_configurations_operations import ExportConfigurationsOperations # type: ignore +from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations # type: ignore +from ._component_quota_status_operations import ComponentQuotaStatusOperations # type: ignore +from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations # type: ignore +from ._component_available_features_operations import ComponentAvailableFeaturesOperations # type: ignore +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._components_operations import ComponentsOperations # type: ignore +from ._work_item_configurations_operations import WorkItemConfigurationsOperations # type: ignore +from ._favorites_operations import FavoritesOperations # type: ignore +from ._web_test_locations_operations import WebTestLocationsOperations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore +from ._analytics_items_operations import AnalyticsItemsOperations # type: ignore +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._my_workbooks_operations import MyWorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -47,5 +53,5 @@ "WorkbooksOperations", "MyWorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py index f69123d9a2df..ebc09a75326f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +68,7 @@ def build_list_request( "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), } - _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") @@ -112,7 +115,7 @@ def build_get_request( "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), } - _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") @@ -157,7 +160,7 @@ def build_put_request( "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), } - _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") @@ -199,7 +202,7 @@ def build_delete_request( "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), } - _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") @@ -229,6 +232,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -262,13 +266,12 @@ def list( :param include_content: Flag indicating whether or not to return the content of each applicable item. If false, only return the item information. Default value is None. :type include_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -279,10 +282,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentAnalyticsItem]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -291,16 +294,14 @@ def list( type=type, include_content=include_content, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -309,16 +310,12 @@ def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response) + deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -347,13 +344,12 @@ def get( :param name: The name of a specific item defined in the Application Insights component. Default value is None. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,10 +360,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -375,16 +371,14 @@ def get( id=id, name=name, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +387,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item" - } + return deserialized # type: ignore @overload def put( @@ -437,7 +427,6 @@ def put( :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem @@ -450,7 +439,7 @@ def put( resource_group_name: str, resource_name: str, scope_path: Union[str, _models.ItemScopePath], - item_properties: IO, + item_properties: IO[bytes], override_item: Optional[bool] = None, *, content_type: str = "application/json", @@ -469,14 +458,13 @@ def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. Required. - :type item_properties: IO + :type item_properties: IO[bytes] :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. Default value is None. :type override_item: bool :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem @@ -489,7 +477,7 @@ def put( resource_group_name: str, resource_name: str, scope_path: Union[str, _models.ItemScopePath], - item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO], + item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO[bytes]], override_item: Optional[bool] = None, **kwargs: Any ) -> _models.ApplicationInsightsComponentAnalyticsItem: @@ -506,23 +494,19 @@ def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. Is either a ApplicationInsightsComponentAnalyticsItem type - or a IO type. Required. + or a IO[bytes] type. Required. :type item_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem or - IO + IO[bytes] :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. Default value is None. :type override_item: bool - :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: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,19 +517,19 @@ def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(item_properties, (IO, bytes)): + if isinstance(item_properties, (IOBase, bytes)): _content = item_properties else: _json = self._serialize.body(item_properties, "ApplicationInsightsComponentAnalyticsItem") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -555,16 +539,14 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,16 +555,12 @@ def put( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -611,12 +589,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param name: The name of a specific item defined in the Application Insights component. Default value is None. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -627,10 +604,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, scope_path=scope_path, @@ -638,16 +615,14 @@ def delete( # pylint: disable=inconsistent-return-statements id=id, name=name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -657,8 +632,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py index 23208a656674..3772e4764b86 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -94,7 +97,7 @@ def build_create_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -127,7 +130,7 @@ def build_delete_request( "annotationId": _SERIALIZER.url("annotation_id", annotation_id, "str"), } - _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") @@ -158,7 +161,7 @@ def build_get_request( "annotationId": _SERIALIZER.url("annotation_id", annotation_id, "str"), } - _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") @@ -187,6 +190,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -204,7 +208,6 @@ def list( :type start: str :param end: The end time to query for annotations. Required. :type end: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Annotation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] @@ -213,10 +216,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.AnnotationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,19 +230,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, start=start, end=end, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -250,14 +251,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AnnotationsListResult", pipeline_response) @@ -267,11 +267,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,10 +284,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - } - @overload def create( self, @@ -311,7 +307,6 @@ def create( :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: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +317,7 @@ def create( self, resource_group_name: str, resource_name: str, - annotation_properties: IO, + annotation_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -336,11 +331,10 @@ def create( :type resource_name: str :param annotation_properties: Properties that need to be specified to create an annotation of a Application Insights component. Required. - :type annotation_properties: IO + :type annotation_properties: 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 :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: @@ -351,7 +345,7 @@ def create( self, resource_group_name: str, resource_name: str, - annotation_properties: Union[_models.Annotation, IO], + annotation_properties: Union[_models.Annotation, IO[bytes]], **kwargs: Any ) -> List[_models.Annotation]: """Create an Annotation of an Application Insights component. @@ -362,18 +356,14 @@ def create( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param annotation_properties: Properties that need to be specified to create an annotation of a - Application Insights component. Is either a Annotation type or a IO type. Required. + Application Insights component. Is either a Annotation type or a IO[bytes] type. Required. :type annotation_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation 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 + IO[bytes] :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,19 +374,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(annotation_properties, (IO, bytes)): + if isinstance(annotation_properties, (IOBase, bytes)): _content = annotation_properties else: _json = self._serialize.body(annotation_properties, "Annotation") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -404,16 +394,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -423,16 +411,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[Annotation]", pipeline_response) + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -448,12 +432,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param annotation_id: The unique annotation ID. This is unique within a Application Insights component. Required. :type annotation_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -464,25 +447,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, annotation_id=annotation_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,11 +473,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -512,12 +489,11 @@ def get( :param annotation_id: The unique annotation ID. This is unique within a Application Insights component. Required. :type annotation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of Annotation or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,25 +504,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, annotation_id=annotation_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -556,13 +530,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[Annotation]", pipeline_response) + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py index 2a264f1c851e..481bdb81b8bc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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 +95,7 @@ def build_create_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -128,7 +131,7 @@ def build_delete_request( "keyId": _SERIALIZER.url("key_id", key_id, "str"), } - _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 +165,7 @@ def build_get_request( "keyId": _SERIALIZER.url("key_id", key_id, "str"), } - _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") @@ -191,11 +194,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> Iterable["_models.ApplicationInsightsComponentAPIKey"]: + # pylint: disable=line-too-long """Gets a list of API keys of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -203,7 +208,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: @@ -213,10 +217,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,17 +231,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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 @@ -248,14 +250,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) @@ -265,11 +266,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,10 +282,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - } - @overload def create( self, @@ -308,7 +305,6 @@ def create( :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: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: @@ -319,7 +315,7 @@ def create( self, resource_group_name: str, resource_name: str, - api_key_properties: IO, + api_key_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -333,11 +329,10 @@ def create( :type resource_name: str :param api_key_properties: Properties that need to be specified to create an API key of a Application Insights component. Required. - :type api_key_properties: IO + :type api_key_properties: 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 :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +343,7 @@ def create( self, resource_group_name: str, resource_name: str, - api_key_properties: Union[_models.APIKeyRequest, IO], + api_key_properties: Union[_models.APIKeyRequest, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentAPIKey: """Create an API Key of an Application Insights component. @@ -359,18 +354,14 @@ def create( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param api_key_properties: Properties that need to be specified to create an API key of a - Application Insights component. Is either a APIKeyRequest type or a IO type. Required. + Application Insights component. Is either a APIKeyRequest type or a IO[bytes] type. Required. :type api_key_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.APIKeyRequest 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 + IO[bytes] :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -381,19 +372,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(api_key_properties, (IO, bytes)): + if isinstance(api_key_properties, (IOBase, bytes)): _content = api_key_properties else: _json = self._serialize.body(api_key_properties, "APIKeyRequest") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -401,16 +392,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,16 +408,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - } + return deserialized # type: ignore @distributed_trace def delete( @@ -444,12 +429,11 @@ def delete( :param key_id: The API Key ID. This is unique within a Application Insights component. Required. :type key_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -460,25 +444,23 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, key_id=key_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,16 +469,12 @@ def delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -512,12 +490,11 @@ def get( :param key_id: The API Key ID. This is unique within a Application Insights component. Required. :type key_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAPIKey or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,25 +505,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, key_id=key_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -555,13 +530,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py index e644efd14780..d4c86a4db7fd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +56,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -83,6 +85,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -95,13 +98,12 @@ def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAvailableFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,24 +114,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentAvailableFeatures] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,13 +138,11 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentAvailableFeatures", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentAvailableFeatures", 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.Insights/components/{resourceName}/getavailablebillingfeatures" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py index 8ba971436140..c89159552df5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -88,7 +91,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -101,7 +104,7 @@ def build_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ComponentCurrentBillingFeaturesOperations: +class ComponentCurrentBillingFeaturesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -119,6 +122,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -131,13 +135,12 @@ def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,24 +151,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -174,16 +175,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures" - } + return deserialized # type: ignore @overload def update( @@ -209,7 +206,6 @@ def update( :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: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures @@ -221,7 +217,7 @@ def update( self, resource_group_name: str, resource_name: str, - billing_features_properties: IO, + billing_features_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -235,11 +231,10 @@ def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. Required. - :type billing_features_properties: IO + :type billing_features_properties: 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 :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures @@ -251,7 +246,7 @@ def update( self, resource_group_name: str, resource_name: str, - billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO], + billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentBillingFeatures: """Update current billing features for an Application Insights component. @@ -263,20 +258,16 @@ def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. Is either a - ApplicationInsightsComponentBillingFeatures type or a IO type. Required. + ApplicationInsightsComponentBillingFeatures type or a IO[bytes] type. Required. :type billing_features_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures - 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 + or IO[bytes] :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,19 +278,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(billing_features_properties, (IO, bytes)): + if isinstance(billing_features_properties, (IOBase, bytes)): _content = billing_features_properties else: _json = self._serialize.body(billing_features_properties, "ApplicationInsightsComponentBillingFeatures") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -307,16 +298,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,13 +314,9 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py index c55de72491f9..6244ea24f06d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +56,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -83,6 +85,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -95,13 +98,12 @@ def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFeatureCapabilities or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,24 +114,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentFeatureCapabilities] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,13 +138,11 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFeatureCapabilities", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentFeatureCapabilities", 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.Insights/components/{resourceName}/featurecapabilities" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py index 561a7d010fd5..4dc18a77d1e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +56,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -83,6 +85,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -95,13 +98,12 @@ def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentQuotaStatus or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,24 +114,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentQuotaStatus] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,13 +138,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py index ae16c9c7d3ab..aecaab74d339 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py @@ -6,6 +6,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -79,7 +83,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -109,7 +113,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -137,7 +141,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -171,7 +175,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -207,7 +211,7 @@ def build_update_tags_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -243,7 +247,7 @@ def build_purge_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -279,7 +283,7 @@ def build_get_purge_status_request( "purgeId": _SERIALIZER.url("purge_id", purge_id, "str"), } - _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") @@ -308,12 +312,12 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent"]: """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -323,10 +327,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,15 +341,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -356,14 +358,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -373,11 +374,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,8 +390,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -400,7 +399,6 @@ 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -410,10 +408,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -424,16 +422,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 @@ -444,14 +440,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -461,11 +456,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -477,10 +472,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.Insights/components" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -492,12 +483,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,24 +498,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,11 +523,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.ApplicationInsightsComponent: @@ -550,12 +534,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,24 +549,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: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,16 +573,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -628,7 +605,6 @@ def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -639,7 +615,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -654,11 +630,10 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -669,7 +644,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -681,18 +656,15 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,19 +675,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -723,16 +695,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -741,16 +711,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -774,7 +740,6 @@ def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -785,7 +750,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -798,11 +763,10 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -813,7 +777,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -824,17 +788,14 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. - :type component_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,19 +806,19 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -865,16 +826,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -883,16 +842,12 @@ def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def purge( @@ -923,7 +878,6 @@ def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -934,7 +888,7 @@ def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -954,11 +908,10 @@ def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -966,7 +919,11 @@ def purge( @distributed_trace def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -982,17 +939,13 @@ def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBody or IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1003,19 +956,19 @@ def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1023,16 +976,14 @@ def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1041,16 +992,12 @@ def purge( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace def get_purge_status( @@ -1066,12 +1013,11 @@ def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1082,25 +1028,23 @@ def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1109,13 +1053,9 @@ def get_purge_status( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py index 9155e7aa5078..da5936775fb3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -90,7 +93,7 @@ def build_create_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -126,7 +129,7 @@ def build_delete_request( "exportId": _SERIALIZER.url("export_id", export_id, "str"), } - _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") @@ -160,7 +163,7 @@ def build_get_request( "exportId": _SERIALIZER.url("export_id", export_id, "str"), } - _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") @@ -195,7 +198,7 @@ def build_update_request( "exportId": _SERIALIZER.url("export_id", export_id, "str"), } - _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") @@ -226,6 +229,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -238,13 +242,12 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,24 +258,22 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,16 +282,14 @@ def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentExportConfiguration]", pipeline_response) + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - } + return deserialized # type: ignore @overload def create( @@ -316,7 +315,6 @@ def create( :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: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] @@ -328,7 +326,7 @@ def create( self, resource_group_name: str, resource_name: str, - export_properties: IO, + export_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -342,11 +340,10 @@ def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. Required. - :type export_properties: IO + :type export_properties: 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 :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] @@ -358,7 +355,7 @@ def create( self, resource_group_name: str, resource_name: str, - export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO], + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], **kwargs: Any ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: """Create a Continuous Export configuration of an Application Insights component. @@ -370,20 +367,16 @@ def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. Is either a - ApplicationInsightsComponentExportRequest type or a IO type. Required. + ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest 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 + IO[bytes] :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,19 +387,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_properties, (IO, bytes)): + if isinstance(export_properties, (IOBase, bytes)): _content = export_properties else: _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -414,16 +407,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -432,16 +423,14 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentExportConfiguration]", pipeline_response) + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - } + return deserialized # type: ignore @distributed_trace def delete( @@ -457,13 +446,12 @@ def delete( :param export_id: The Continuous Export configuration ID. This is unique within a Application Insights component. Required. :type export_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,25 +462,23 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,16 +487,14 @@ def delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -526,13 +510,12 @@ def get( :param export_id: The Continuous Export configuration ID. This is unique within a Application Insights component. Required. :type export_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -543,25 +526,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -570,16 +551,14 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore @overload def update( @@ -609,7 +588,6 @@ def update( :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: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration @@ -622,7 +600,7 @@ def update( resource_group_name: str, resource_name: str, export_id: str, - export_properties: IO, + export_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -639,11 +617,10 @@ def update( :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export configuration. Required. - :type export_properties: IO + :type export_properties: 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 :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration @@ -656,7 +633,7 @@ def update( resource_group_name: str, resource_name: str, export_id: str, - export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO], + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentExportConfiguration: """Update the Continuous Export configuration for this export id. @@ -670,21 +647,17 @@ def update( Insights component. Required. :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export - configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO type. + configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest 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 + IO[bytes] :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -695,19 +668,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_properties, (IO, bytes)): + if isinstance(export_properties, (IOBase, bytes)): _content = export_properties else: _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, export_id=export_id, @@ -716,16 +689,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -734,13 +705,11 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentExportConfiguration", pipeline_response) + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py index ec7d4b6c382b..b8b7b47890ed 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -106,7 +109,7 @@ def build_get_request( "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), } - _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") @@ -141,7 +144,7 @@ def build_add_request( "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), } - _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") @@ -178,7 +181,7 @@ def build_update_request( "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), } - _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") @@ -211,7 +214,7 @@ def build_delete_request( "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), } - _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") @@ -237,6 +240,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -269,13 +273,12 @@ def list( :type can_fetch_content: bool :param tags: Tags that must be present on each favorite returned. Default value is None. :type tags: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,10 +289,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentFavorite]] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -298,16 +301,14 @@ def list( can_fetch_content=can_fetch_content, tags=tags, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -316,16 +317,12 @@ def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response) + deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites" - } + return deserialized # type: ignore @distributed_trace def get( @@ -341,12 +338,11 @@ def get( :param favorite_id: The Id of a specific favorite defined in the Application Insights component. Required. :type favorite_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,25 +353,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,16 +378,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", 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.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @overload def add( @@ -423,7 +413,6 @@ def add( :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: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -435,7 +424,7 @@ def add( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: IO, + favorite_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -452,11 +441,10 @@ def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. Required. - :type favorite_properties: IO + :type favorite_properties: 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 :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +456,7 @@ def add( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO], + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentFavorite: """Adds a new favorites to an Application Insights component. @@ -483,18 +471,15 @@ def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. Is either a ApplicationInsightsComponentFavorite - type or a IO type. Required. + type or a IO[bytes] type. Required. :type favorite_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite or + IO[bytes] :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,19 +490,19 @@ def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(favorite_properties, (IO, bytes)): + if isinstance(favorite_properties, (IOBase, bytes)): _content = favorite_properties else: _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") - request = build_add_request( + _request = build_add_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, @@ -526,16 +511,14 @@ def add( content_type=content_type, json=_json, content=_content, - template_url=self.add.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,16 +527,12 @@ def add( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - add.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @overload def update( @@ -583,7 +562,6 @@ def update( :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: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -595,7 +573,7 @@ def update( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: IO, + favorite_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -612,11 +590,10 @@ def update( :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing favorite. Required. - :type favorite_properties: IO + :type favorite_properties: 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 :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: @@ -628,7 +605,7 @@ def update( resource_group_name: str, resource_name: str, favorite_id: str, - favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO], + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentFavorite: """Updates a favorite that has already been added to an Application Insights component. @@ -642,18 +619,15 @@ def update( component. Required. :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing - favorite. Is either a ApplicationInsightsComponentFavorite type or a IO type. Required. + favorite. Is either a ApplicationInsightsComponentFavorite type or a IO[bytes] type. Required. :type favorite_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite or + IO[bytes] :return: ApplicationInsightsComponentFavorite or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,19 +638,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(favorite_properties, (IO, bytes)): + if isinstance(favorite_properties, (IOBase, bytes)): _content = favorite_properties else: _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, @@ -685,16 +659,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -703,16 +675,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", 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.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -728,12 +696,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param favorite_id: The Id of a specific favorite defined in the Application Insights component. Required. :type favorite_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -744,25 +711,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, favorite_id=favorite_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,8 +737,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py index c217c918ffd9..2162594476a5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -99,7 +102,7 @@ def build_list_by_subscription_request( "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["category"] = _SERIALIZER.query("category", category, "str") @@ -135,7 +138,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -168,7 +171,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -202,7 +205,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -238,7 +241,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -269,6 +272,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -293,7 +297,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook] @@ -302,10 +305,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -316,19 +319,17 @@ 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -339,14 +340,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -356,11 +356,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,10 +373,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.Insights/myWorkbooks" - } - @distributed_trace def list_by_subscription( self, @@ -396,7 +392,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook] @@ -405,10 +400,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,18 +414,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -441,14 +434,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -458,11 +450,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -475,8 +467,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks"} - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.MyWorkbook: """Get a single private workbook by its resourceName. @@ -486,12 +476,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -502,24 +491,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: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.MyWorkbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,16 +516,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -551,12 +534,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,24 +549,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -595,11 +575,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/myWorkbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -624,7 +600,6 @@ def create_or_update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -635,7 +610,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -649,11 +624,10 @@ def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -664,7 +638,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], **kwargs: Any ) -> _models.MyWorkbook: """Create a new private workbook. @@ -675,17 +649,14 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook 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 + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook or + IO[bytes] :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,19 +667,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - 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, @@ -716,16 +687,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -735,21 +704,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MyWorkbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}" - } - @overload def update( self, @@ -773,7 +734,6 @@ def update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -784,7 +744,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -798,11 +758,10 @@ def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -813,7 +772,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], **kwargs: Any ) -> _models.MyWorkbook: """Updates a private workbook that has already been added. @@ -824,17 +783,14 @@ def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook 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 + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook or + IO[bytes] :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,19 +801,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -865,16 +821,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -884,13 +838,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py index 0e0804ca28b4..2747509ead1c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,12 +75,12 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available insights REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] @@ -87,10 +89,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +103,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +119,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +135,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,5 +151,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py index 8ddb3a96892c..3b24a8e1b178 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -90,7 +93,7 @@ def build_get_request( "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), } - _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") @@ -125,7 +128,7 @@ def build_update_request( "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), } - _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") @@ -138,7 +141,7 @@ def build_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ProactiveDetectionConfigurationsOperations: +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -156,11 +159,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + # pylint: disable=line-too-long """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -168,14 +173,13 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,26 +190,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( "cls", None ) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,17 +217,13 @@ def list( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs" - } + return deserialized # type: ignore @distributed_trace def get( @@ -241,14 +239,13 @@ def get( :param configuration_id: The ProactiveDetection configuration ID. This is unique within a Application Insights component. Required. :type configuration_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -259,25 +256,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,17 +282,13 @@ def get( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore @overload def update( @@ -327,7 +318,6 @@ def update( :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: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -341,7 +331,7 @@ def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: IO, + proactive_detection_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -358,11 +348,10 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Required. - :type proactive_detection_properties: IO + :type proactive_detection_properties: 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 :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -376,7 +365,9 @@ def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: Union[_models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO], + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: """Update the ProactiveDetection configuration for this configuration id. @@ -391,21 +382,17 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Is either a - ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO type. Required. + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration - 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 + or IO[bytes] :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,21 +403,21 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(proactive_detection_properties, (IO, bytes)): + if isinstance(proactive_detection_properties, (IOBase, bytes)): _content = proactive_detection_properties else: _json = self._serialize.body( proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, @@ -439,16 +426,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,14 +443,10 @@ def update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py index 0e5cd7a9e71e..5eb9336b4763 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +60,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -87,11 +89,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> Iterable["_models.ApplicationInsightsComponentWebTestLocation"]: + # pylint: disable=line-too-long """Gets a list of web test locations available to this Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -99,7 +103,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 ApplicationInsightsComponentWebTestLocation or the result of cls(response) :rtype: @@ -109,10 +112,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.ApplicationInsightsWebTestLocationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,17 +126,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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 @@ -144,14 +145,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) @@ -161,11 +161,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,7 +176,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py index 5a5d38328f67..16aea6b4c849 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -86,7 +89,7 @@ def build_get_request(resource_group_name: str, web_test_name: str, subscription "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -120,7 +123,7 @@ def build_create_or_update_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -156,7 +159,7 @@ def build_update_tags_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -188,7 +191,7 @@ def build_delete_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -209,7 +212,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -242,7 +245,7 @@ def build_list_by_component_request( "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") @@ -271,6 +274,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WebTest"]: @@ -279,7 +283,6 @@ 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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -288,10 +291,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,16 +305,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 @@ -322,14 +323,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -339,11 +339,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +355,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.Insights/webtests" - } - @distributed_trace def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -368,12 +364,11 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,24 +379,22 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +403,12 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -444,7 +433,6 @@ def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -455,7 +443,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -469,11 +457,10 @@ def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -484,7 +471,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -495,17 +482,15 @@ def create_or_update( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. - :type web_test_definition: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest 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 + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,19 +501,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -536,16 +521,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -554,16 +537,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -587,7 +566,6 @@ def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -598,7 +576,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -611,11 +589,10 @@ def update_tags( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -626,7 +603,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -637,17 +614,14 @@ def update_tags( :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Is either a - TagsResource type or a IO type. Required. - :type web_test_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.v2015_05_01.models.TagsResource or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -658,19 +632,19 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -678,16 +652,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -696,16 +668,12 @@ def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -718,12 +686,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights webtest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -734,24 +701,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -761,17 +726,12 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: """Get all Application Insights web test alerts definitions within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -780,10 +740,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -794,15 +754,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -813,14 +771,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -830,11 +787,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -846,8 +803,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -859,7 +814,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] @@ -868,10 +822,10 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -882,17 +836,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -903,14 +855,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -920,11 +871,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -935,7 +886,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py index 490330e25c7d..451e330c6837 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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 +95,7 @@ def build_create_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -127,7 +130,7 @@ def build_get_default_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -158,7 +161,7 @@ def build_delete_request( "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), } - _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") @@ -189,7 +192,7 @@ def build_get_item_request( "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), } - _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") @@ -224,7 +227,7 @@ def build_update_item_request( "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), } - _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") @@ -255,6 +258,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -267,7 +271,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 WorkItemConfiguration or the result of cls(response) :rtype: @@ -277,10 +280,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfigurationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -291,17 +294,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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.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 @@ -312,14 +313,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) @@ -329,11 +329,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -346,10 +346,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - } - @overload def create( self, @@ -374,7 +370,6 @@ def create( :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: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -385,7 +380,7 @@ def create( self, resource_group_name: str, resource_name: str, - work_item_configuration_properties: IO, + work_item_configuration_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -399,11 +394,10 @@ def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. Required. - :type work_item_configuration_properties: IO + :type work_item_configuration_properties: 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 :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -414,7 +408,7 @@ def create( self, resource_group_name: str, resource_name: str, - work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO], + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], **kwargs: Any ) -> _models.WorkItemConfiguration: """Create a work item configuration for an Application Insights component. @@ -426,18 +420,14 @@ def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. Is either a - WorkItemCreateConfiguration type or a IO type. Required. + WorkItemCreateConfiguration type or a IO[bytes] type. Required. :type work_item_configuration_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration or IO[bytes] :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,19 +438,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(work_item_configuration_properties, (IO, bytes)): + if isinstance(work_item_configuration_properties, (IOBase, bytes)): _content = work_item_configuration_properties else: _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -468,16 +458,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -486,16 +474,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - } + return deserialized # type: ignore @distributed_trace def get_default(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkItemConfiguration: @@ -506,12 +490,11 @@ def get_default(self, resource_group_name: str, resource_name: str, **kwargs: An :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -522,24 +505,22 @@ def get_default(self, resource_group_name: str, resource_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) - request = build_get_default_request( + _request = build_get_default_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_default.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,16 +529,12 @@ def get_default(self, resource_group_name: str, resource_name: str, **kwargs: An map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -573,12 +550,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param work_item_config_id: The unique work item configuration Id. This can be either friendly name of connector as defined in connector configuration. Required. :type work_item_config_id: 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,25 +565,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -617,11 +591,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_item( @@ -637,12 +607,11 @@ def get_item( :param work_item_config_id: The unique work item configuration Id. This can be either friendly name of connector as defined in connector configuration. Required. :type work_item_config_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -653,25 +622,23 @@ def get_item( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) - request = build_get_item_request( + _request = build_get_item_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_item.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -680,16 +647,12 @@ def get_item( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_item.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return deserialized # type: ignore @overload def update_item( @@ -719,7 +682,6 @@ def update_item( :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: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -731,7 +693,7 @@ def update_item( resource_group_name: str, resource_name: str, work_item_config_id: str, - work_item_configuration_properties: IO, + work_item_configuration_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -748,11 +710,10 @@ def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. Required. - :type work_item_configuration_properties: IO + :type work_item_configuration_properties: 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 :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -764,7 +725,7 @@ def update_item( resource_group_name: str, resource_name: str, work_item_config_id: str, - work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO], + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], **kwargs: Any ) -> _models.WorkItemConfiguration: """Update a work item configuration for an Application Insights component. @@ -779,18 +740,14 @@ def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. Is either a - WorkItemCreateConfiguration type or a IO type. Required. + WorkItemCreateConfiguration type or a IO[bytes] type. Required. :type work_item_configuration_properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration 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 + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration or IO[bytes] :return: WorkItemConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -801,19 +758,19 @@ def update_item( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(work_item_configuration_properties, (IO, bytes)): + if isinstance(work_item_configuration_properties, (IOBase, bytes)): _content = work_item_configuration_properties else: _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") - request = build_update_item_request( + _request = build_update_item_request( resource_group_name=resource_group_name, resource_name=resource_name, work_item_config_id=work_item_config_id, @@ -822,16 +779,14 @@ def update_item( content_type=content_type, json=_json, content=_content, - template_url=self.update_item.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -840,13 +795,9 @@ def update_item( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkItemConfiguration", pipeline_response) + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_item.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py index ac0bec72c2e0..9e47ef9f8f60 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -99,7 +102,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -132,7 +135,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -166,7 +169,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -202,7 +205,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -233,6 +236,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -257,7 +261,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook] @@ -266,10 +269,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -280,19 +283,17 @@ 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -303,14 +304,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -320,11 +320,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -337,10 +337,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.insights/workbooks" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.Workbook: """Get a single workbook by its resourceName. @@ -350,12 +346,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -366,24 +361,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: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[_models.Workbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +386,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -415,12 +404,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,24 +419,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,11 +445,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -488,7 +470,6 @@ def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -499,7 +480,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -513,11 +494,10 @@ def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -528,7 +508,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Create a new workbook. @@ -539,17 +519,14 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook 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 + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,19 +537,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -580,16 +557,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,21 +574,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}" - } - @overload def update( self, @@ -637,7 +604,6 @@ def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +614,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -662,11 +628,10 @@ def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -677,7 +642,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -688,17 +653,14 @@ def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook 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 + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -709,19 +671,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -729,16 +691,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -748,13 +708,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py index 8a0b3a94bbf9..0d498c7b5ace 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -23,11 +26,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar ea_subscription_migrate_to_new_pricing_model: @@ -65,26 +67,44 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -104,12 +124,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py index 040e63c88e8a..28262a12e43d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-10-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json index b1dd8d44c997..8543f170cc60 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "ea_subscription_migrate_to_new_pricing_model": "EASubscriptionMigrateToNewPricingModelOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py index 4ad50ab3d067..07b1aa660827 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -23,11 +26,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar ea_subscription_migrate_to_new_pricing_model: @@ -65,26 +67,46 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-10-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -104,12 +126,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py index 29bd4fa4942d..f5e6fd7799c9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-10-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/__init__.py index 9161c63b1963..232581debd23 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/__init__.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._ea_subscription_migrate_to_new_pricing_model_operations import EASubscriptionMigrateToNewPricingModelOperations -from ._ea_subscription_rollback_to_legacy_pricing_model_operations import ( - EASubscriptionRollbackToLegacyPricingModelOperations, -) -from ._ea_subscription_list_migration_date_operations import EASubscriptionListMigrationDateOperations -from ._component_current_pricing_plan_operations import ComponentCurrentPricingPlanOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._ea_subscription_migrate_to_new_pricing_model_operations import EASubscriptionMigrateToNewPricingModelOperations # type: ignore +from ._ea_subscription_rollback_to_legacy_pricing_model_operations import EASubscriptionRollbackToLegacyPricingModelOperations # type: ignore +from ._ea_subscription_list_migration_date_operations import EASubscriptionListMigrationDateOperations # type: ignore +from ._component_current_pricing_plan_operations import ComponentCurrentPricingPlanOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -23,5 +27,5 @@ "EASubscriptionListMigrationDateOperations", "ComponentCurrentPricingPlanOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py index 91f07495688a..445e5742fee6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,20 +18,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_current_pricing_plan_operations import ( build_create_and_update_request, build_get_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -65,13 +69,12 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,24 +85,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,16 +109,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore @overload async def create_and_update( @@ -143,7 +140,6 @@ async def create_and_update( :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: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -155,7 +151,7 @@ async def create_and_update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: IO, + pricing_plan_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -169,11 +165,10 @@ async def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Required. - :type pricing_plan_properties: IO + :type pricing_plan_properties: 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 :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -185,7 +180,7 @@ async def create_and_update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO], + pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentPricingPlan: """Replace current pricing plan for an Application Insights component. @@ -197,20 +192,16 @@ async def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Is either a ApplicationInsightsComponentPricingPlan - type or a IO type. Required. + type or a IO[bytes] type. Required. :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan 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 + IO[bytes] :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,19 +212,19 @@ async def create_and_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing_plan_properties, (IO, bytes)): + if isinstance(pricing_plan_properties, (IOBase, bytes)): _content = pricing_plan_properties else: _json = self._serialize.body(pricing_plan_properties, "ApplicationInsightsComponentPricingPlan") - request = build_create_and_update_request( + _request = build_create_and_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -241,16 +232,14 @@ async def create_and_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_and_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,16 +248,12 @@ async def create_and_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_and_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore @overload async def update( @@ -294,7 +279,6 @@ async def update( :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: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -306,7 +290,7 @@ async def update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: IO, + pricing_plan_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -320,11 +304,10 @@ async def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Required. - :type pricing_plan_properties: IO + :type pricing_plan_properties: 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 :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -336,7 +319,7 @@ async def update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO], + pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentPricingPlan: """Update current pricing plan for an Application Insights component. @@ -348,20 +331,16 @@ async def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Is either a ApplicationInsightsComponentPricingPlan - type or a IO type. Required. + type or a IO[bytes] type. Required. :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan 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 + IO[bytes] :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,19 +351,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing_plan_properties, (IO, bytes)): + if isinstance(pricing_plan_properties, (IOBase, bytes)): _content = pricing_plan_properties else: _json = self._serialize.body(pricing_plan_properties, "ApplicationInsightsComponentPricingPlan") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -392,16 +371,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,13 +387,9 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", 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.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py index 9f497a53edea..56bf612abe64 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,21 +17,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._ea_subscription_list_migration_date_operations import build_post_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EASubscriptionListMigrationDateOperations: +class EASubscriptionListMigrationDateOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -49,17 +51,17 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: """list date to migrate to new pricing model. - :keyword callable cls: A custom type or function that will be passed the direct response :return: EASubscriptionMigrationDate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.EASubscriptionMigrationDate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -70,22 +72,20 @@ async def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.EASubscriptionMigrationDate] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -94,11 +94,9 @@ async def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("EASubscriptionMigrationDate", pipeline_response) + deserialized = self._deserialize("EASubscriptionMigrationDate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/listMigrationdate"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py index cd95ad916091..a565db3d0527 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,21 +17,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._ea_subscription_migrate_to_new_pricing_model_operations import build_post_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EASubscriptionMigrateToNewPricingModelOperations: +class EASubscriptionMigrateToNewPricingModelOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -49,17 +51,17 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async - async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + async def post(self, **kwargs: Any) -> None: """Enterprise Agreement Customer opted to use new pricing model. - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -70,22 +72,20 @@ async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -95,6 +95,4 @@ async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py index a82a63166072..90600ed39dd8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,21 +17,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._ea_subscription_rollback_to_legacy_pricing_model_operations import build_post_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EASubscriptionRollbackToLegacyPricingModelOperations: +class EASubscriptionRollbackToLegacyPricingModelOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -49,17 +51,17 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async - async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + async def post(self, **kwargs: Any) -> None: """Enterprise Agreement Customer roll back to use legacy pricing model. - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -70,22 +72,20 @@ async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -95,6 +95,4 @@ async def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/rollbackToLegacyPricingModel"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py index 93b0e941ebe1..1cea28d5c33a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py @@ -5,13 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ApplicationInsightsComponentPricingPlan -from ._models_py3 import CloudErrorBody -from ._models_py3 import EASubscriptionMigrationDate -from ._models_py3 import Resource +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ApplicationInsightsComponentPricingPlan, + CloudErrorBody, + EASubscriptionMigrationDate, + Resource, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -20,5 +29,5 @@ "EASubscriptionMigrationDate", "Resource", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py index 99a9a7cc9ecc..35197f8b2cf1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -13,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/__init__.py index 9161c63b1963..232581debd23 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/__init__.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._ea_subscription_migrate_to_new_pricing_model_operations import EASubscriptionMigrateToNewPricingModelOperations -from ._ea_subscription_rollback_to_legacy_pricing_model_operations import ( - EASubscriptionRollbackToLegacyPricingModelOperations, -) -from ._ea_subscription_list_migration_date_operations import EASubscriptionListMigrationDateOperations -from ._component_current_pricing_plan_operations import ComponentCurrentPricingPlanOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._ea_subscription_migrate_to_new_pricing_model_operations import EASubscriptionMigrateToNewPricingModelOperations # type: ignore +from ._ea_subscription_rollback_to_legacy_pricing_model_operations import EASubscriptionRollbackToLegacyPricingModelOperations # type: ignore +from ._ea_subscription_list_migration_date_operations import EASubscriptionListMigrationDateOperations # type: ignore +from ._component_current_pricing_plan_operations import ComponentCurrentPricingPlanOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -23,5 +27,5 @@ "EASubscriptionListMigrationDateOperations", "ComponentCurrentPricingPlanOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py index 4d615530170b..944a57019e04 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -88,7 +91,7 @@ def build_create_and_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -124,7 +127,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -155,6 +158,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -167,13 +171,12 @@ def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,24 +187,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +211,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore @overload def create_and_update( @@ -245,7 +242,6 @@ def create_and_update( :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: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -257,7 +253,7 @@ def create_and_update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: IO, + pricing_plan_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -271,11 +267,10 @@ def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Required. - :type pricing_plan_properties: IO + :type pricing_plan_properties: 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 :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -287,7 +282,7 @@ def create_and_update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO], + pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentPricingPlan: """Replace current pricing plan for an Application Insights component. @@ -299,20 +294,16 @@ def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Is either a ApplicationInsightsComponentPricingPlan - type or a IO type. Required. + type or a IO[bytes] type. Required. :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan 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 + IO[bytes] :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,19 +314,19 @@ def create_and_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing_plan_properties, (IO, bytes)): + if isinstance(pricing_plan_properties, (IOBase, bytes)): _content = pricing_plan_properties else: _json = self._serialize.body(pricing_plan_properties, "ApplicationInsightsComponentPricingPlan") - request = build_create_and_update_request( + _request = build_create_and_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -343,16 +334,14 @@ def create_and_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_and_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +350,12 @@ def create_and_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_and_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore @overload def update( @@ -396,7 +381,6 @@ def update( :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: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -408,7 +392,7 @@ def update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: IO, + pricing_plan_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -422,11 +406,10 @@ def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Required. - :type pricing_plan_properties: IO + :type pricing_plan_properties: 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 :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan @@ -438,7 +421,7 @@ def update( self, resource_group_name: str, resource_name: str, - pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO], + pricing_plan_properties: Union[_models.ApplicationInsightsComponentPricingPlan, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponentPricingPlan: """Update current pricing plan for an Application Insights component. @@ -450,20 +433,16 @@ def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. Is either a ApplicationInsightsComponentPricingPlan - type or a IO type. Required. + type or a IO[bytes] type. Required. :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan 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 + IO[bytes] :return: ApplicationInsightsComponentPricingPlan or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,19 +453,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentPricingPlan] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing_plan_properties, (IO, bytes)): + if isinstance(pricing_plan_properties, (IOBase, bytes)): _content = pricing_plan_properties else: _json = self._serialize.body(pricing_plan_properties, "ApplicationInsightsComponentPricingPlan") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -494,16 +473,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,13 +489,9 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentPricingPlan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py index 1b06d649fc01..3da0d6bfe156 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +49,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -58,7 +60,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class EASubscriptionListMigrationDateOperations: +class EASubscriptionListMigrationDateOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -76,17 +78,17 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: """list date to migrate to new pricing model. - :keyword callable cls: A custom type or function that will be passed the direct response :return: EASubscriptionMigrationDate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.EASubscriptionMigrationDate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,22 +99,20 @@ def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.EASubscriptionMigrationDate] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,11 +121,9 @@ def post(self, **kwargs: Any) -> _models.EASubscriptionMigrationDate: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("EASubscriptionMigrationDate", pipeline_response) + deserialized = self._deserialize("EASubscriptionMigrationDate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/listMigrationdate"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py index ffcdcbdfa554..e2da740cf356 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +51,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -60,7 +62,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class EASubscriptionMigrateToNewPricingModelOperations: +class EASubscriptionMigrateToNewPricingModelOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -78,17 +80,17 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Enterprise Agreement Customer opted to use new pricing model. - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,22 +101,20 @@ def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,6 +124,4 @@ def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py index e922798dbb77..fd48297f8b1b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +51,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -60,7 +62,7 @@ def build_post_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class EASubscriptionRollbackToLegacyPricingModelOperations: +class EASubscriptionRollbackToLegacyPricingModelOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -78,17 +80,17 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Enterprise Agreement Customer roll back to use legacy pricing model. - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,22 +101,20 @@ def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_post_request( + _request = build_post_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,6 +124,4 @@ def post(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - post.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/rollbackToLegacyPricingModel"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py index 756775796435..b7e41d238fa2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations @@ -57,20 +59,44 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) - self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,12 +116,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py index 6c7361f76341..eb4c196cb569 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json index efc347724655..bb796bfa1dd9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "proactive_detection_configurations": "ProactiveDetectionConfigurationsOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py index 1158800060c9..79d484096160 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations @@ -58,20 +60,46 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" + ) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) - self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,12 +119,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py index 1a567b2ae1dc..b8a7afde07af 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/__init__.py index f45e7be668e2..173ad1d7a923 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/__init__.py @@ -5,14 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations -from ._components_operations import ComponentsOperations -from ._operations import Operations -from ._web_tests_operations import WebTestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._components_operations import ComponentsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -21,5 +27,5 @@ "Operations", "WebTestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py index f2d5c16d221f..3fea8f8f8f1d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._components_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,12 +64,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -76,10 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +96,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +113,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -126,11 +129,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,18 +145,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -163,10 +164,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,16 +180,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 @@ -197,14 +198,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -214,11 +214,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,14 +230,8 @@ 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.Insights/components" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -245,12 +239,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,24 +254,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,11 +281,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -305,12 +294,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,24 +309,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,16 +335,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -383,7 +367,6 @@ async def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -394,7 +377,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -409,11 +392,10 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -424,7 +406,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -436,18 +418,16 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,19 +438,21 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -478,16 +460,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -496,21 +476,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } - @overload async def update_tags( self, @@ -533,7 +505,6 @@ async def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -544,7 +515,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -557,11 +528,10 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -572,7 +542,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -583,18 +553,14 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type component_tags: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.TagsResource - 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 + or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,19 +571,21 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -625,16 +593,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -643,21 +609,13 @@ async def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } - @overload async def purge( self, @@ -687,7 +645,6 @@ async def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -698,7 +655,7 @@ async def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -718,11 +675,10 @@ async def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -730,7 +686,11 @@ async def purge( @distributed_trace_async async def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -746,17 +706,14 @@ async def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBody or + IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,19 +724,21 @@ async def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -787,16 +746,14 @@ async def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -805,16 +762,12 @@ async def purge( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def get_purge_status( @@ -830,12 +783,11 @@ async def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -846,25 +798,25 @@ async def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -873,13 +825,9 @@ async def get_purge_status( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py index eb567892fe6d..ae977b5b2e99 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,6 +53,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -58,7 +61,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: List the available operations supported by the Microsoft.EventGrid resource provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] @@ -67,10 +69,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,14 +85,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +101,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) @@ -116,11 +117,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py index 02146477de39..52d815799137 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,25 +18,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._proactive_detection_configurations_operations import ( build_get_request, build_list_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProactiveDetectionConfigurationsOperations: +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -53,11 +56,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + # pylint: disable=line-too-long """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,14 +70,13 @@ async def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,26 +87,26 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( "cls", None ) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,22 +116,19 @@ async def list( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs" - } + return deserialized # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, configuration_id: str, **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Get the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -138,14 +139,13 @@ async def get( :param configuration_id: The ProactiveDetection configuration ID. This is unique within a Application Insights component. Required. :type configuration_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,25 +156,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,17 +184,13 @@ async def get( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore @overload async def update( @@ -207,6 +203,7 @@ async def update( content_type: str = "application/json", **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -224,7 +221,6 @@ async def update( :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: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -238,11 +234,12 @@ async def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: IO, + proactive_detection_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -255,11 +252,10 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Required. - :type proactive_detection_properties: IO + :type proactive_detection_properties: 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 :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -273,9 +269,12 @@ async def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: Union[_models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO], + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -288,21 +287,17 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Is either a - ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO type. Required. + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration - 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 + or IO[bytes] :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,21 +308,23 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(proactive_detection_properties, (IO, bytes)): + if isinstance(proactive_detection_properties, (IOBase, bytes)): _content = proactive_detection_properties else: _json = self._serialize.body( proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, @@ -336,16 +333,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,14 +350,10 @@ async def update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py index 541ee4ef2325..d055d5619d33 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._web_tests_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +37,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +63,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: @@ -68,7 +72,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -77,10 +80,12 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,16 +96,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_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 @@ -111,14 +114,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -128,11 +130,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,10 +146,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.Insights/webtests" - } - @distributed_trace_async async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -157,12 +155,11 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,24 +170,24 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,16 +196,12 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -233,7 +226,6 @@ async def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +236,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -258,11 +250,10 @@ async def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +264,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -284,18 +275,15 @@ async def create_or_update( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. :type web_test_definition: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest - 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 + or IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,19 +294,21 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -326,16 +316,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,16 +332,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -377,7 +361,6 @@ async def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +371,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -401,11 +384,10 @@ async def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -416,7 +398,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -427,18 +409,14 @@ async def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type web_test_tags: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.TagsResource 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 + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,19 +427,21 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -469,16 +449,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,21 +465,15 @@ async def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, web_test_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> None: """Deletes an Application Insights web test. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -509,12 +481,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,24 +496,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,17 +523,12 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: """Get all Application Insights web test alerts definitions within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -571,10 +537,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,15 +553,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -604,14 +570,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -621,11 +586,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,8 +602,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -650,7 +613,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -659,10 +621,12 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -673,17 +637,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -694,14 +656,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -711,11 +672,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -726,7 +687,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py index de9241d8cb84..e2752ee95e38 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py @@ -5,41 +5,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ApplicationInsightsComponent -from ._models_py3 import ApplicationInsightsComponentListResult -from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration -from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions -from ._models_py3 import ComponentPurgeBody -from ._models_py3 import ComponentPurgeBodyFilters -from ._models_py3 import ComponentPurgeResponse -from ._models_py3 import ComponentPurgeStatusResponse -from ._models_py3 import ComponentsResource -from ._models_py3 import HeaderField -from ._models_py3 import Operation -from ._models_py3 import OperationInfo -from ._models_py3 import OperationsListResult -from ._models_py3 import PrivateLinkScopedResource -from ._models_py3 import TagsResource -from ._models_py3 import WebTest -from ._models_py3 import WebTestGeolocation -from ._models_py3 import WebTestListResult -from ._models_py3 import WebTestPropertiesConfiguration -from ._models_py3 import WebTestPropertiesRequest -from ._models_py3 import WebTestPropertiesValidationRules -from ._models_py3 import WebTestPropertiesValidationRulesContentValidation -from ._models_py3 import WebtestsResource +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import ApplicationType -from ._application_insights_management_client_enums import FlowType -from ._application_insights_management_client_enums import IngestionMode -from ._application_insights_management_client_enums import PublicNetworkAccessType -from ._application_insights_management_client_enums import PurgeState -from ._application_insights_management_client_enums import RequestSource -from ._application_insights_management_client_enums import WebTestKind -from ._application_insights_management_client_enums import WebTestKindEnum +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ApplicationInsightsComponent, + ApplicationInsightsComponentListResult, + ApplicationInsightsComponentProactiveDetectionConfiguration, + ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions, + ComponentPurgeBody, + ComponentPurgeBodyFilters, + ComponentPurgeResponse, + ComponentPurgeStatusResponse, + ComponentsResource, + HeaderField, + Operation, + OperationInfo, + OperationsListResult, + PrivateLinkScopedResource, + TagsResource, + WebTest, + WebTestGeolocation, + WebTestListResult, + WebTestPropertiesConfiguration, + WebTestPropertiesRequest, + WebTestPropertiesValidationRules, + WebTestPropertiesValidationRulesContentValidation, + WebtestsResource, +) + +from ._application_insights_management_client_enums import ( # type: ignore + ApplicationType, + FlowType, + IngestionMode, + PublicNetworkAccessType, + PurgeState, + RequestSource, + WebTestKind, + WebTestKindEnum, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -75,5 +86,5 @@ "WebTestKind", "WebTestKindEnum", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py index 26c7a9083cd5..50eb767ab8b3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py @@ -1,5 +1,5 @@ -# coding=utf-8 # 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. @@ -15,10 +15,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -28,7 +27,7 @@ class ComponentsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -72,12 +71,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class ApplicationInsightsComponent(ComponentsResource): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponent(ComponentsResource): """An Application Insights component 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -299,7 +298,7 @@ def __init__( # pylint: disable=too-many-locals class ApplicationInsightsComponentListResult(_serialization.Model): """Describes the list of Application Insights Resources. - 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 value: List of Application Insights component definitions. Required. :vartype value: @@ -334,7 +333,9 @@ def __init__( self.next_link = next_link -class ApplicationInsightsComponentProactiveDetectionConfiguration(_serialization.Model): +class ApplicationInsightsComponentProactiveDetectionConfiguration( + _serialization.Model +): # pylint: disable=name-too-long """A ProactiveDetection configuration definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -361,7 +362,7 @@ class ApplicationInsightsComponentProactiveDetectionConfiguration(_serialization :ivar rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). :vartype rule_definitions: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions # pylint: disable=line-too-long """ _validation = { @@ -376,13 +377,13 @@ class ApplicationInsightsComponentProactiveDetectionConfiguration(_serialization "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "location": {"key": "location", "type": "str"}, - "name_properties_name": {"key": "properties.Name", "type": "str"}, - "enabled": {"key": "properties.Enabled", "type": "bool"}, - "send_emails_to_subscription_owners": {"key": "properties.SendEmailsToSubscriptionOwners", "type": "bool"}, - "custom_emails": {"key": "properties.CustomEmails", "type": "[str]"}, - "last_updated_time": {"key": "properties.LastUpdatedTime", "type": "str"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "send_emails_to_subscription_owners": {"key": "properties.sendEmailsToSubscriptionOwners", "type": "bool"}, + "custom_emails": {"key": "properties.customEmails", "type": "[str]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "str"}, "rule_definitions": { - "key": "properties.RuleDefinitions", + "key": "properties.ruleDefinitions", "type": "ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions", }, } @@ -415,7 +416,7 @@ def __init__( :keyword rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). :paramtype rule_definitions: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions # pylint: disable=line-too-long """ super().__init__(**kwargs) self.id = None @@ -430,7 +431,9 @@ def __init__( self.rule_definitions = rule_definitions -class ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions(_serialization.Model): +class ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions( + _serialization.Model +): # pylint: disable=name-too-long """Static definitions of the ProactiveDetection configuration rule (same values for all components). @@ -510,7 +513,7 @@ def __init__( class ComponentPurgeBody(_serialization.Model): """Describes the body of a purge request for an App Insights component. - 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 table: Table from which to purge data. Required. :vartype table: str @@ -601,7 +604,7 @@ def __init__( class ComponentPurgeResponse(_serialization.Model): """Response containing operationId for a specific purge action. - 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 operation_id: Id to use when querying for status for a particular purge operation. Required. @@ -629,7 +632,7 @@ def __init__(self, *, operation_id: str, **kwargs: Any) -> None: class ComponentPurgeStatusResponse(_serialization.Model): """Response containing status for a specific purge operation. - 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 status: Status of the operation represented by the requested Id. Required. Known values are: "pending" and "completed". @@ -854,7 +857,7 @@ class WebtestsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -898,12 +901,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class WebTest(WebtestsResource): # pylint: disable=too-many-instance-attributes +class WebTest(WebtestsResource): """An Application Insights WebTest 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -1089,7 +1092,7 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: class WebTestListResult(_serialization.Model): """A list of 0 or more Application Insights WebTest definitions. - 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 value: Set of Application Insights WebTest definitions. Required. :vartype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -1260,7 +1263,7 @@ def __init__( self.ignore_https_status_code = ignore_https_status_code -class WebTestPropertiesValidationRulesContentValidation(_serialization.Model): +class WebTestPropertiesValidationRulesContentValidation(_serialization.Model): # pylint: disable=name-too-long """The collection of content validation properties. :ivar content_match: Content to look for in the return of the WebTest. Must not be null or diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/__init__.py index f45e7be668e2..173ad1d7a923 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/__init__.py @@ -5,14 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations -from ._components_operations import ComponentsOperations -from ._operations import Operations -from ._web_tests_operations import WebTestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._components_operations import ComponentsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -21,5 +27,5 @@ "Operations", "WebTestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py index 9b52efe646f7..1cfe5fdde6ad 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py @@ -6,6 +6,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -79,7 +83,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -109,7 +113,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -137,7 +141,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -171,7 +175,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -207,7 +211,7 @@ def build_update_tags_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -243,7 +247,7 @@ def build_purge_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -279,7 +283,7 @@ def build_get_purge_status_request( "purgeId": _SERIALIZER.url("purge_id", purge_id, "str"), } - _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") @@ -308,12 +312,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -323,10 +328,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,15 +344,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -356,14 +361,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -373,11 +377,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,18 +393,16 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> Iterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -410,10 +412,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -424,16 +428,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 @@ -444,14 +446,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -461,11 +462,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -477,10 +478,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.Insights/components" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -492,12 +489,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,24 +504,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,11 +531,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.ApplicationInsightsComponent: @@ -550,12 +542,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,24 +557,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,16 +583,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -628,7 +615,6 @@ def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -639,7 +625,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -654,11 +640,10 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -669,7 +654,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -681,18 +666,16 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,19 +686,21 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -723,16 +708,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -741,21 +724,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } - @overload def update_tags( self, @@ -778,7 +753,6 @@ def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -789,7 +763,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -802,11 +776,10 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -817,7 +790,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -828,18 +801,14 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type component_tags: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.TagsResource - 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 + or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -850,19 +819,21 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -870,16 +841,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -888,21 +857,13 @@ def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } - @overload def purge( self, @@ -932,7 +893,6 @@ def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -943,7 +903,7 @@ def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +923,10 @@ def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -975,7 +934,11 @@ def purge( @distributed_trace def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -991,17 +954,14 @@ def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBody or + IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1012,19 +972,21 @@ def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1032,16 +994,14 @@ def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1050,16 +1010,12 @@ def purge( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace def get_purge_status( @@ -1075,12 +1031,11 @@ def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1091,25 +1046,25 @@ def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1118,13 +1073,9 @@ def get_purge_status( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py index 7f0244771668..b392df616157 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,6 +75,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -80,7 +83,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: List the available operations supported by the Microsoft.EventGrid resource provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] @@ -89,10 +91,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,14 +107,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +123,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) @@ -138,11 +139,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py index e5ac7ad94439..ee76a5951dc3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -90,7 +93,7 @@ def build_get_request( "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), } - _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") @@ -125,7 +128,7 @@ def build_update_request( "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), } - _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") @@ -138,7 +141,7 @@ def build_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ProactiveDetectionConfigurationsOperations: +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -156,11 +159,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + # pylint: disable=line-too-long """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -168,14 +173,13 @@ def list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,26 +190,26 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( "cls", None ) - request = build_list_request( + _request = build_list_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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,22 +219,19 @@ def list( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs" - } + return deserialized # type: ignore @distributed_trace def get( self, resource_group_name: str, resource_name: str, configuration_id: str, **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Get the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -241,14 +242,13 @@ def get( :param configuration_id: The ProactiveDetection configuration ID. This is unique within a Application Insights component. Required. :type configuration_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -259,25 +259,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,17 +287,13 @@ def get( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", 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.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore @overload def update( @@ -310,6 +306,7 @@ def update( content_type: str = "application/json", **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -327,7 +324,6 @@ def update( :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: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -341,11 +337,12 @@ def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: IO, + proactive_detection_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -358,11 +355,10 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Required. - :type proactive_detection_properties: IO + :type proactive_detection_properties: 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 :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: @@ -376,9 +372,12 @@ def update( resource_group_name: str, resource_name: str, configuration_id: str, - proactive_detection_properties: Union[_models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO], + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], **kwargs: Any ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + # pylint: disable=line-too-long """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -391,21 +390,17 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. Is either a - ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO type. Required. + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration - 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 + or IO[bytes] :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,21 +411,23 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(proactive_detection_properties, (IO, bytes)): + if isinstance(proactive_detection_properties, (IOBase, bytes)): _content = proactive_detection_properties else: _json = self._serialize.body( proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, configuration_id=configuration_id, @@ -439,16 +436,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,14 +453,10 @@ def update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( - "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py index 0c87f4145b72..ea39abb2eb4e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -86,7 +89,7 @@ def build_get_request(resource_group_name: str, web_test_name: str, subscription "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -120,7 +123,7 @@ def build_create_or_update_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -156,7 +159,7 @@ def build_update_tags_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -188,7 +191,7 @@ def build_delete_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -209,7 +212,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -242,7 +245,7 @@ def build_list_by_component_request( "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") @@ -271,6 +274,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WebTest"]: @@ -279,7 +283,6 @@ 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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -288,10 +291,12 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,16 +307,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 @@ -322,14 +325,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -339,11 +341,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +357,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.Insights/webtests" - } - @distributed_trace def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -368,12 +366,11 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,24 +381,24 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +407,12 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", 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.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -444,7 +437,6 @@ def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -455,7 +447,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -469,11 +461,10 @@ def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -484,7 +475,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -495,18 +486,15 @@ def create_or_update( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. :type web_test_definition: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest - 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 + or IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -517,19 +505,21 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -537,16 +527,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -555,16 +543,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -588,7 +572,6 @@ def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -599,7 +582,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -612,11 +595,10 @@ def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -627,7 +609,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -638,18 +620,14 @@ def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to set into the web test instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type web_test_tags: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.TagsResource 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 + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -660,19 +638,21 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -680,16 +660,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -698,16 +676,12 @@ def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -720,12 +694,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,24 +709,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -763,17 +736,12 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: """Get all Application Insights web test alerts definitions within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -782,10 +750,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -796,15 +766,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -815,14 +783,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -832,11 +799,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -848,8 +815,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -861,7 +826,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] @@ -870,10 +834,12 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") + ) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -884,17 +850,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -905,14 +869,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -922,11 +885,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -937,7 +900,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py index 6fee78f16538..3d58b376f910 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import Operations, WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -51,16 +53,38 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-06-17-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2018-06-17-preview" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -80,12 +104,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py index 176ebe6f1890..60a6f8f1db99 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-06-17-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json index ca447c4f3578..0701b49fba20 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbooks": "WorkbooksOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py index 5f07aaadf6b2..2b8d5a91521d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import Operations, WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -52,16 +54,40 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-06-17-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2018-06-17-preview" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +107,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py index e6d078c1d887..ebb20b2f7a0c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-06-17-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/__init__.py index 17683fb02d0a..aed9fd104c66 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/__init__.py @@ -5,17 +5,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._operations import Operations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", "Operations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py index 67ff4a7c08ae..bab7445155b1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,12 +53,12 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available insights REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] @@ -65,10 +67,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,14 +83,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,14 +99,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -114,11 +115,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,5 +131,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py index 79674dcdd98d..2ff7640aef77 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,6 +61,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -85,7 +89,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] @@ -94,10 +97,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,7 +113,7 @@ 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, category=category, @@ -116,12 +121,10 @@ def prepare_request(next_link=None): tags=tags, can_fetch_content=can_fetch_content, 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 @@ -132,14 +135,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -149,11 +151,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,10 +168,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.insights/workbooks" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.Workbook: """Get a single workbook by its resourceName. @@ -179,12 +177,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,24 +192,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.Workbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,21 +219,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -244,12 +235,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,24 +250,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,11 +278,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -320,7 +306,6 @@ async def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -332,7 +317,7 @@ async def create_or_update( resource_group_name: str, resource_name: str, source_id: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -348,11 +333,10 @@ async def create_or_update( :type source_id: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +348,7 @@ async def create_or_update( resource_group_name: str, resource_name: str, source_id: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Create a new workbook. @@ -377,18 +361,14 @@ async def create_or_update( :param source_id: Azure Resource Id that will fetch all related workbooks. Required. :type source_id: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. + either a Workbook type or a IO[bytes] type. Required. :type workbook_properties: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook - 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 + or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,19 +379,21 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -420,16 +402,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -439,21 +419,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}" - } - @overload async def update( self, @@ -481,7 +453,6 @@ async def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -493,7 +464,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: str, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -509,11 +480,10 @@ async def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -525,7 +495,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: str, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -538,18 +508,15 @@ async def update( :param source_id: Azure Resource Id that will fetch all related workbooks. Required. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,14 +527,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -575,7 +544,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -584,16 +553,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -603,13 +570,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py index 58f2962a7a8f..fdcf4a98ff35 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py @@ -5,22 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ErrorFieldContract -from ._models_py3 import ErrorResponse -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Resource -from ._models_py3 import Workbook -from ._models_py3 import WorkbookError -from ._models_py3 import WorkbookUpdateParameters -from ._models_py3 import WorkbooksListResult +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import CategoryType -from ._application_insights_management_client_enums import SharedTypeKind +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ErrorFieldContract, + ErrorResponse, + Operation, + OperationDisplay, + OperationListResult, + Resource, + Workbook, + WorkbookError, + WorkbookUpdateParameters, + WorkbooksListResult, +) + +from ._application_insights_management_client_enums import ( # type: ignore + CategoryType, + SharedTypeKind, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -37,5 +48,5 @@ "CategoryType", "SharedTypeKind", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py index b3767399a4ec..ff5ee1f4f9bb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -12,7 +11,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -178,7 +176,7 @@ class Resource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -239,12 +237,12 @@ def __init__( self.tags = tags -class Workbook(Resource): # pylint: disable=too-many-instance-attributes +class Workbook(Resource): """An Application Insights workbook 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/__init__.py index 17683fb02d0a..aed9fd104c66 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/__init__.py @@ -5,17 +5,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._operations import Operations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", "Operations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py index a0d920a50366..4605ceac4130 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,12 +75,12 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available insights REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] @@ -87,10 +89,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +137,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,5 +153,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py index 7305237bc9aa..69631014c504 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -101,7 +104,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -134,7 +137,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -168,7 +171,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["sourceId"] = _SERIALIZER.query("source_id", source_id, "str") @@ -205,7 +208,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["sourceId"] = _SERIALIZER.query("source_id", source_id, "str") @@ -237,6 +240,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -264,7 +268,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] @@ -273,10 +276,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,7 +292,7 @@ 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, category=category, @@ -295,12 +300,10 @@ def prepare_request(next_link=None): tags=tags, can_fetch_content=can_fetch_content, 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 @@ -311,14 +314,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -328,11 +330,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -345,10 +347,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.insights/workbooks" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.Workbook: """Get a single workbook by its resourceName. @@ -358,12 +356,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,24 +371,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[_models.Workbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,16 +398,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -423,12 +416,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -439,24 +431,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -467,11 +459,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -499,7 +487,6 @@ def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -511,7 +498,7 @@ def create_or_update( resource_group_name: str, resource_name: str, source_id: str, - workbook_properties: IO, + workbook_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -527,11 +514,10 @@ def create_or_update( :type source_id: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -543,7 +529,7 @@ def create_or_update( resource_group_name: str, resource_name: str, source_id: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], **kwargs: Any ) -> _models.Workbook: """Create a new workbook. @@ -556,18 +542,14 @@ def create_or_update( :param source_id: Azure Resource Id that will fetch all related workbooks. Required. :type source_id: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. + either a Workbook type or a IO[bytes] type. Required. :type workbook_properties: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook - 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 + or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,19 +560,21 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -599,16 +583,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,21 +600,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}" - } - @overload def update( self, @@ -660,7 +634,6 @@ def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -672,7 +645,7 @@ def update( resource_group_name: str, resource_name: str, source_id: str, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -688,11 +661,10 @@ def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -704,7 +676,7 @@ def update( resource_group_name: str, resource_name: str, source_id: str, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -717,18 +689,15 @@ def update( :param source_id: Azure Resource Id that will fetch all related workbooks. Required. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters or + IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,14 +708,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2018-06-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -754,7 +725,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -763,16 +734,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -782,13 +751,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.insights/workbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py index c95697b8c715..c35836402858 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbookTemplatesOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations @@ -49,17 +51,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-10-17-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py index d6fa8c7e7e47..2868684a3faf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-10-17-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json index c0105c8ddfe5..1667298e6a0b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbook_templates": "WorkbookTemplatesOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py index b5370f6d4494..4bb8ff6cc81d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbookTemplatesOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations @@ -49,17 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-10-17-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py index 6048256fb69f..2d50da57ae30 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-10-17-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/__init__.py index 272f3eb3be4e..aa730bc20e57 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbook_templates_operations import WorkbookTemplatesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbookTemplatesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py index 982d9bbf9074..5ce0bed5c3fa 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbook_templates_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,18 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.WorkbookTemplate"]: + # pylint: disable=line-too-long """Get all Workbook templates defined within a specified 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 WorkbookTemplate or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] @@ -77,10 +81,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,16 +97,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 @@ -111,14 +115,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) @@ -128,11 +131,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,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.insights/workbooktemplates" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: """Get a single workbook template by its resourceName. @@ -158,12 +157,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,24 +172,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[_models.WorkbookTemplate] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,21 +199,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -223,12 +215,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,24 +230,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,11 +258,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooktemplates/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -297,7 +284,6 @@ async def create_or_update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +294,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: IO, + workbook_template_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -322,11 +308,10 @@ async def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_template_properties: IO + :type workbook_template_properties: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -337,7 +322,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: Union[_models.WorkbookTemplate, IO], + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], **kwargs: Any ) -> _models.WorkbookTemplate: """Create a new workbook template. @@ -348,18 +333,14 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new - workbook. Is either a WorkbookTemplate type or a IO type. Required. + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. :type workbook_template_properties: - ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate 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 + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate or IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -370,19 +351,21 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_properties, (IO, bytes)): + if isinstance(workbook_template_properties, (IOBase, bytes)): _content = workbook_template_properties else: _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") - 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, @@ -390,16 +373,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -409,21 +390,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}" - } - @overload async def update( self, @@ -448,7 +421,6 @@ async def update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -459,7 +431,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[IO] = None, + workbook_template_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -473,11 +445,10 @@ async def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. Default value is None. - :type workbook_template_update_parameters: IO + :type workbook_template_update_parameters: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -488,7 +459,9 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[Union[_models.WorkbookTemplateUpdateParameters, IO]] = None, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, **kwargs: Any ) -> _models.WorkbookTemplate: """Updates a workbook template that has already been added. @@ -499,20 +472,16 @@ async def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a - workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO type. Default - value is None. + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. + Default value is None. :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters 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 + IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,14 +492,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_update_parameters, (IO, bytes)): + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): _content = workbook_template_update_parameters else: if workbook_template_update_parameters is not None: @@ -538,7 +509,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -546,16 +517,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -565,13 +534,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py index 662abbcc8a98..9624ccdad420 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py @@ -5,17 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ErrorFieldContract -from ._models_py3 import WorkbookError -from ._models_py3 import WorkbookTemplate -from ._models_py3 import WorkbookTemplateGallery -from ._models_py3 import WorkbookTemplateLocalizedGallery -from ._models_py3 import WorkbookTemplateResource -from ._models_py3 import WorkbookTemplateUpdateParameters -from ._models_py3 import WorkbookTemplatesListResult +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ErrorFieldContract, + WorkbookError, + WorkbookTemplate, + WorkbookTemplateGallery, + WorkbookTemplateLocalizedGallery, + WorkbookTemplateResource, + WorkbookTemplateUpdateParameters, + WorkbookTemplatesListResult, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -28,5 +37,5 @@ "WorkbookTemplateUpdateParameters", "WorkbookTemplatesListResult", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py index 317175a5b2d3..7e0564463243 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -15,10 +14,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -105,7 +103,7 @@ class WorkbookTemplateResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -154,7 +152,7 @@ class WorkbookTemplate(WorkbookTemplateResource): Variables are 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: Azure resource Id. :vartype id: str diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/__init__.py index 272f3eb3be4e..aa730bc20e57 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbook_templates_operations import WorkbookTemplatesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbookTemplatesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py index 88a2d1a189fb..7c203ffa823c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,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") @@ -86,7 +89,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -119,7 +122,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -153,7 +156,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -189,7 +192,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -220,6 +223,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WorkbookTemplate"]: @@ -228,7 +232,6 @@ 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 WorkbookTemplate or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] @@ -237,10 +240,12 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,16 +256,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 @@ -271,14 +274,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) @@ -288,11 +290,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,10 +307,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.insights/workbooktemplates" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: """Get a single workbook template by its resourceName. @@ -318,12 +316,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,24 +331,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[_models.WorkbookTemplate] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +358,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -383,12 +376,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,24 +391,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -427,11 +419,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.insights/workbooktemplates/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -457,7 +445,6 @@ def create_or_update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +455,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: IO, + workbook_template_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -482,11 +469,10 @@ def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_template_properties: IO + :type workbook_template_properties: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -497,7 +483,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: Union[_models.WorkbookTemplate, IO], + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], **kwargs: Any ) -> _models.WorkbookTemplate: """Create a new workbook template. @@ -508,18 +494,14 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new - workbook. Is either a WorkbookTemplate type or a IO type. Required. + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. :type workbook_template_properties: - ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate 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 + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate or IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,19 +512,21 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_properties, (IO, bytes)): + if isinstance(workbook_template_properties, (IOBase, bytes)): _content = workbook_template_properties else: _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") - 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, @@ -550,16 +534,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,21 +551,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}" - } - @overload def update( self, @@ -608,7 +582,6 @@ def update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -619,7 +592,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[IO] = None, + workbook_template_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -633,11 +606,10 @@ def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. Default value is None. - :type workbook_template_update_parameters: IO + :type workbook_template_update_parameters: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +620,9 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[Union[_models.WorkbookTemplateUpdateParameters, IO]] = None, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, **kwargs: Any ) -> _models.WorkbookTemplate: """Updates a workbook template that has already been added. @@ -659,20 +633,16 @@ def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a - workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO type. Default - value is None. + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. + Default value is None. :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters 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 + IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,14 +653,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-10-17-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_update_parameters, (IO, bytes)): + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): _content = workbook_template_update_parameters else: if workbook_template_update_parameters is not None: @@ -698,7 +670,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -706,16 +678,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,13 +695,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_application_insights_management_client.py index 5e4d3236e265..5d5f12bd518c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations @@ -48,15 +50,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-02-02" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -76,12 +98,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_configuration.py index 910e711de51e..cab35e5f60ba 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-02-02") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_metadata.json index 68023292e4a9..2bf8416ee624 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "components": "ComponentsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_application_insights_management_client.py index 5116ade7cbec..e0f5fab12a82 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-02-02" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_configuration.py index 4f505ae939ed..1fa965f54c79 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-02-02") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/__init__.py index 36d27862f7bc..ab50c30fbaac 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._components_operations import ComponentsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/_components_operations.py index 0c2669ffafe5..e85a6212d15e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/aio/operations/_components_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._components_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,12 +64,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -76,10 +80,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +94,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +111,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -126,11 +127,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,18 +144,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -164,10 +163,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,16 +177,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 @@ -198,14 +195,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -215,11 +211,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,14 +228,8 @@ 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.Insights/components" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -247,12 +237,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,24 +252,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,11 +278,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -308,12 +291,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +306,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +331,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -387,7 +363,6 @@ async def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -398,7 +373,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,11 +388,10 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -428,7 +402,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -440,18 +414,15 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -462,19 +433,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -482,16 +453,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,16 +470,12 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -534,7 +499,6 @@ async def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -545,7 +509,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -558,11 +522,10 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -573,7 +536,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -584,17 +547,14 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. - :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02.models.TagsResource or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,19 +565,19 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -625,16 +585,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -644,16 +602,12 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def purge( @@ -688,7 +642,6 @@ async def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -699,7 +652,7 @@ async def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -723,11 +676,10 @@ async def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -735,7 +687,11 @@ async def purge( @distributed_trace_async async def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -755,17 +711,13 @@ async def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeBody or IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,19 +728,19 @@ async def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -796,16 +748,14 @@ async def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -815,16 +765,12 @@ async def purge( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def get_purge_status( @@ -840,12 +786,11 @@ async def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -856,25 +801,23 @@ async def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -884,13 +827,9 @@ async def get_purge_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/__init__.py index dcfd926ee5d5..3970e25b69c3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/__init__.py @@ -5,27 +5,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ApplicationInsightsComponent -from ._models_py3 import ApplicationInsightsComponentListResult -from ._models_py3 import ComponentPurgeBody -from ._models_py3 import ComponentPurgeBodyFilters -from ._models_py3 import ComponentPurgeResponse -from ._models_py3 import ComponentPurgeStatusResponse -from ._models_py3 import ComponentsResource -from ._models_py3 import ErrorResponseComponents -from ._models_py3 import ErrorResponseComponentsError -from ._models_py3 import PrivateLinkScopedResource -from ._models_py3 import TagsResource +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import ApplicationType -from ._application_insights_management_client_enums import FlowType -from ._application_insights_management_client_enums import IngestionMode -from ._application_insights_management_client_enums import PublicNetworkAccessType -from ._application_insights_management_client_enums import PurgeState -from ._application_insights_management_client_enums import RequestSource +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ApplicationInsightsComponent, + ApplicationInsightsComponentListResult, + ComponentPurgeBody, + ComponentPurgeBodyFilters, + ComponentPurgeResponse, + ComponentPurgeStatusResponse, + ComponentsResource, + ErrorResponseComponents, + ErrorResponseComponentsError, + PrivateLinkScopedResource, + TagsResource, +) + +from ._application_insights_management_client_enums import ( # type: ignore + ApplicationType, + FlowType, + IngestionMode, + PublicNetworkAccessType, + PurgeState, + RequestSource, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -47,5 +58,5 @@ "PurgeState", "RequestSource", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/_models_py3.py index e98f2118daf8..e07a96f32fcf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -12,7 +11,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -21,7 +19,7 @@ class ComponentsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -65,12 +63,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class ApplicationInsightsComponent(ComponentsResource): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponent(ComponentsResource): """An Application Insights component 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -335,7 +333,7 @@ def __init__( # pylint: disable=too-many-locals class ApplicationInsightsComponentListResult(_serialization.Model): """Describes the list of Application Insights Resources. - 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 value: List of Application Insights component definitions. Required. :vartype value: @@ -373,7 +371,7 @@ def __init__( class ComponentPurgeBody(_serialization.Model): """Describes the body of a purge request for an App Insights component. - 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 table: Table from which to purge data. Required. :vartype table: str @@ -464,7 +462,7 @@ def __init__( class ComponentPurgeResponse(_serialization.Model): """Response containing operationId for a specific purge action. - 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 operation_id: Id to use when querying for status for a particular purge operation. Required. @@ -492,7 +490,7 @@ def __init__(self, *, operation_id: str, **kwargs: Any) -> None: class ComponentPurgeStatusResponse(_serialization.Model): """Response containing status for a specific purge operation. - 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 status: Status of the operation represented by the requested Id. Required. Known values are: "pending" and "completed". diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/__init__.py index 36d27862f7bc..ab50c30fbaac 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._components_operations import ComponentsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/_components_operations.py index 8e39e9d3186b..19b80a730ca9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02/operations/_components_operations.py @@ -6,6 +6,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -79,7 +83,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -112,7 +116,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -143,7 +147,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -177,7 +181,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -213,7 +217,7 @@ def build_update_tags_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -249,7 +253,7 @@ def build_purge_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -285,7 +289,7 @@ def build_get_purge_status_request( "purgeId": _SERIALIZER.url("purge_id", purge_id, "str"), } - _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") @@ -314,12 +318,12 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent"]: """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -329,10 +333,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,15 +347,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -362,14 +364,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -379,11 +380,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -396,8 +397,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -407,7 +406,6 @@ 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -417,10 +415,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,16 +429,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 @@ -451,14 +447,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -468,11 +463,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,10 +480,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.Insights/components" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -500,12 +491,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,24 +506,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,11 +532,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.ApplicationInsightsComponent: @@ -559,12 +543,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,24 +558,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: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,16 +583,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -638,7 +615,6 @@ def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -649,7 +625,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -664,11 +640,10 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -679,7 +654,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -691,18 +666,15 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,19 +685,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -733,16 +705,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -752,16 +722,12 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -785,7 +751,6 @@ def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -796,7 +761,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -809,11 +774,10 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -824,7 +788,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -835,17 +799,14 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. - :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02.models.TagsResource 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 + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02.models.TagsResource or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -856,19 +817,19 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -876,16 +837,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,16 +854,12 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def purge( @@ -939,7 +894,6 @@ def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -950,7 +904,7 @@ def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -974,11 +928,10 @@ def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -986,7 +939,11 @@ def purge( @distributed_trace def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -1006,17 +963,13 @@ def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeBody or IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1027,19 +980,19 @@ def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1047,16 +1000,14 @@ def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1066,16 +1017,12 @@ def purge( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace def get_purge_status( @@ -1091,12 +1038,11 @@ def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1107,25 +1053,23 @@ def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-02-02")) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1135,13 +1079,9 @@ def get_purge_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py index 6cf130a75002..9480fbc4faf1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations @@ -49,15 +51,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-02-02-preview" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py index 57a82f205d54..4ef9e7f06170 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-02-02-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json index 4c9cbec7780f..4e46f84a680a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "components": "ComponentsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py index 5e0d8e47a53b..f7bafa498293 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-02-02-preview" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py index 608a37ea3dac..5a78dded50df 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-02-02-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/__init__.py index 36d27862f7bc..ab50c30fbaac 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._components_operations import ComponentsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py index 2779db85e19d..175b94de06bb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._components_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,12 +64,13 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -76,10 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +96,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationInsightsCompo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +113,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -126,11 +129,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,18 +146,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -164,10 +165,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,16 +181,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 @@ -198,14 +199,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -215,11 +215,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,14 +232,8 @@ 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.Insights/components" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -247,12 +241,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,24 +256,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,11 +284,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -308,12 +297,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +312,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +339,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -387,7 +371,6 @@ async def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -398,7 +381,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,11 +396,10 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -428,7 +410,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -440,18 +422,16 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -462,19 +442,21 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -482,16 +464,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,16 +481,12 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -534,7 +510,6 @@ async def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -545,7 +520,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -558,11 +533,10 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -573,7 +547,7 @@ async def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -584,18 +558,14 @@ async def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.TagsResource - 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 + or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,19 +576,21 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -626,16 +598,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,16 +615,12 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload async def purge( @@ -685,7 +651,6 @@ async def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -696,7 +661,7 @@ async def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -716,11 +681,10 @@ async def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -728,7 +692,11 @@ async def purge( @distributed_trace_async async def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -744,17 +712,14 @@ async def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBody or + IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -765,19 +730,21 @@ async def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -785,16 +752,14 @@ async def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -804,16 +769,12 @@ async def purge( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def get_purge_status( @@ -829,12 +790,11 @@ async def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,25 +805,25 @@ async def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -873,13 +833,9 @@ async def get_purge_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py index 8309ba1be313..1b67924f17b2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py @@ -5,28 +5,39 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ApplicationInsightsComponent -from ._models_py3 import ApplicationInsightsComponentListResult -from ._models_py3 import ComponentPurgeBody -from ._models_py3 import ComponentPurgeBodyFilters -from ._models_py3 import ComponentPurgeResponse -from ._models_py3 import ComponentPurgeStatusResponse -from ._models_py3 import ComponentsResource -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import PrivateLinkScopedResource -from ._models_py3 import TagsResource +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import ApplicationType -from ._application_insights_management_client_enums import FlowType -from ._application_insights_management_client_enums import IngestionMode -from ._application_insights_management_client_enums import PublicNetworkAccessType -from ._application_insights_management_client_enums import PurgeState -from ._application_insights_management_client_enums import RequestSource +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ApplicationInsightsComponent, + ApplicationInsightsComponentListResult, + ComponentPurgeBody, + ComponentPurgeBodyFilters, + ComponentPurgeResponse, + ComponentPurgeStatusResponse, + ComponentsResource, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + PrivateLinkScopedResource, + TagsResource, +) + +from ._application_insights_management_client_enums import ( # type: ignore + ApplicationType, + FlowType, + IngestionMode, + PublicNetworkAccessType, + PurgeState, + RequestSource, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -49,5 +60,5 @@ "PurgeState", "RequestSource", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py index 18f4ba7c76f3..51472df526e5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -12,7 +11,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -21,7 +19,7 @@ class ComponentsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -65,12 +63,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class ApplicationInsightsComponent(ComponentsResource): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsComponent(ComponentsResource): """An Application Insights component 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -334,7 +332,7 @@ def __init__( # pylint: disable=too-many-locals class ApplicationInsightsComponentListResult(_serialization.Model): """Describes the list of Application Insights Resources. - 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 value: List of Application Insights component definitions. Required. :vartype value: @@ -372,7 +370,7 @@ def __init__( class ComponentPurgeBody(_serialization.Model): """Describes the body of a purge request for an App Insights component. - 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 table: Table from which to purge data. Required. :vartype table: str @@ -463,7 +461,7 @@ def __init__( class ComponentPurgeResponse(_serialization.Model): """Response containing operationId for a specific purge action. - 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 operation_id: Id to use when querying for status for a particular purge operation. Required. @@ -491,7 +489,7 @@ def __init__(self, *, operation_id: str, **kwargs: Any) -> None: class ComponentPurgeStatusResponse(_serialization.Model): """Response containing status for a specific purge operation. - 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 status: Status of the operation represented by the requested Id. Required. Known values are: "pending" and "completed". diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/__init__.py index 36d27862f7bc..ab50c30fbaac 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._components_operations import ComponentsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py index 228ecb24fb0f..b65cceb85a34 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py @@ -6,6 +6,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -79,7 +83,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -112,7 +116,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -143,7 +147,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -177,7 +181,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -213,7 +217,7 @@ def build_update_tags_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -249,7 +253,7 @@ def build_purge_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -285,7 +289,7 @@ def build_get_purge_status_request( "purgeId": _SERIALIZER.url("purge_id", purge_id, "str"), } - _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") @@ -314,12 +318,13 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of all Application Insights components within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -329,10 +334,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,15 +350,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplicationInsightsComponent" def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -362,14 +367,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -379,11 +383,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -396,18 +400,16 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> Iterable["_models.ApplicationInsightsComponent"]: + # pylint: disable=line-too-long """Gets a list of Application Insights components within a 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 ApplicationInsightsComponent or the result of cls(response) :rtype: @@ -417,10 +419,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,16 +435,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 @@ -451,14 +453,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) @@ -468,11 +469,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,10 +486,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.Insights/components" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -500,12 +497,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,24 +512,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,11 +540,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/components/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.ApplicationInsightsComponent: @@ -559,12 +551,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,24 +566,24 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ApplicationInsightsComponent] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,16 +593,12 @@ 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("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", 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.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -638,7 +625,6 @@ def create_or_update( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -649,7 +635,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: IO, + insight_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -664,11 +650,10 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. Required. - :type insight_properties: IO + :type insight_properties: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -679,7 +664,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - insight_properties: Union[_models.ApplicationInsightsComponent, IO], + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Creates (or updates) an Application Insights component. Note: You cannot specify a different @@ -691,18 +676,16 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application - Insights component. Is either a ApplicationInsightsComponent type or a IO type. Required. + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. :type insight_properties: - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent 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 + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent or + IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,19 +696,21 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(insight_properties, (IO, bytes)): + if isinstance(insight_properties, (IOBase, bytes)): _content = insight_properties else: _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") - 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, @@ -733,16 +718,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -752,16 +735,12 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -785,7 +764,6 @@ def update_tags( :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: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -796,7 +774,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: IO, + component_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -809,11 +787,10 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Required. - :type component_tags: IO + :type component_tags: 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 :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: @@ -824,7 +801,7 @@ def update_tags( self, resource_group_name: str, resource_name: str, - component_tags: Union[_models.TagsResource, IO], + component_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.ApplicationInsightsComponent: """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. @@ -835,18 +812,14 @@ def update_tags( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param component_tags: Updated tag information to set into the component instance. Is either a - TagsResource type or a IO type. Required. + TagsResource type or a IO[bytes] type. Required. :type component_tags: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.TagsResource - 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 + or IO[bytes] :return: ApplicationInsightsComponent or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,19 +830,21 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(component_tags, (IO, bytes)): + if isinstance(component_tags, (IOBase, bytes)): _content = component_tags else: _json = self._serialize.body(component_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -877,16 +852,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -896,16 +869,12 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - } + return deserialized # type: ignore @overload def purge( @@ -936,7 +905,6 @@ def purge( :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: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -947,7 +915,7 @@ def purge( self, resource_group_name: str, resource_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -967,11 +935,10 @@ def purge( :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application Insights component. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +946,11 @@ def purge( @distributed_trace def purge( - self, resource_group_name: str, resource_name: str, body: Union[_models.ComponentPurgeBody, IO], **kwargs: Any + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any ) -> _models.ComponentPurgeResponse: """Purges data in an Application Insights component by a set of user-defined filters. @@ -995,17 +966,14 @@ def purge( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param body: Describes the body of a request to purge data in a single table of an Application - Insights component. Is either a ComponentPurgeBody type or a IO type. Required. - :type body: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBody 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 + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBody or + IO[bytes] :return: ComponentPurgeResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1016,19 +984,21 @@ def purge( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "ComponentPurgeBody") - request = build_purge_request( + _request = build_purge_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1036,16 +1006,14 @@ def purge( content_type=content_type, json=_json, content=_content, - template_url=self.purge.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1055,16 +1023,12 @@ def purge( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - purge.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - } + return deserialized # type: ignore @distributed_trace def get_purge_status( @@ -1080,12 +1044,11 @@ def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. Required. :type purge_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPurgeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1096,25 +1059,25 @@ def get_purge_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-02-02-preview") + ) cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) - request = build_get_purge_status_request( + _request = build_get_purge_status_request( resource_group_name=resource_group_name, resource_name=resource_name, purge_id=purge_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_purge_status.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1124,13 +1087,9 @@ def get_purge_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response) + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_purge_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py index b5d57d9784c6..b5aef775e4d3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentLinkedStorageAccountsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations @@ -49,17 +51,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py index 1018d128c574..4181f083d7d7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-03-01-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json index c1a1cfba6ac2..80b343503203 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "component_linked_storage_accounts": "ComponentLinkedStorageAccountsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py index 3c90650e8347..7d3e08ba76de 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import ComponentLinkedStorageAccountsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations @@ -49,17 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py index 6c356ce6a5d3..56ba811f6736 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-03-01-preview") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/__init__.py index e9bbe941e284..674336f5dd75 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentLinkedStorageAccountsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py index 6720f8ddc4ff..da6bd671884d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._component_linked_storage_accounts_operations import ( build_create_and_update_request, build_delete_request, @@ -32,6 +31,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -70,13 +74,12 @@ async def get( storage account. "ServiceProfiler" Required. :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,25 +90,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,16 +118,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", 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.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @overload async def create_and_update( @@ -155,7 +154,6 @@ async def create_and_update( :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: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -168,7 +166,7 @@ async def create_and_update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: IO, + linked_storage_accounts_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -186,11 +184,10 @@ async def create_and_update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. Required. - :type linked_storage_accounts_properties: IO + :type linked_storage_accounts_properties: 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 :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -203,7 +200,7 @@ async def create_and_update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO[bytes]], **kwargs: Any ) -> _models.ComponentLinkedStorageAccounts: """Replace current linked storage account for an Application Insights component. @@ -219,19 +216,16 @@ async def create_and_update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. Is either a - ComponentLinkedStorageAccounts type or a IO type. Required. + ComponentLinkedStorageAccounts type or a IO[bytes] type. Required. :type linked_storage_accounts_properties: - ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts 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 + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts or + IO[bytes] :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,19 +236,21 @@ async def create_and_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(linked_storage_accounts_properties, (IO, bytes)): + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): _content = linked_storage_accounts_properties else: _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccounts") - request = build_create_and_update_request( + _request = build_create_and_update_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, @@ -263,16 +259,14 @@ async def create_and_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_and_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,16 +276,12 @@ async def create_and_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_and_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @overload async def update( @@ -322,7 +312,6 @@ async def update( :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: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -335,7 +324,7 @@ async def update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: IO, + linked_storage_accounts_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -353,11 +342,10 @@ async def update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. Required. - :type linked_storage_accounts_properties: IO + :type linked_storage_accounts_properties: 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 :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -370,7 +358,7 @@ async def update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO[bytes]], **kwargs: Any ) -> _models.ComponentLinkedStorageAccounts: """Update linked storage accounts for an Application Insights component. @@ -386,20 +374,16 @@ async def update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. Is either a - ComponentLinkedStorageAccountsPatch type or a IO type. Required. + ComponentLinkedStorageAccountsPatch type or a IO[bytes] type. Required. :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch - 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 + or IO[bytes] :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,19 +394,21 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(linked_storage_accounts_properties, (IO, bytes)): + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): _content = linked_storage_accounts_properties else: _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccountsPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, @@ -431,16 +417,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -450,19 +434,15 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", 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.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], **kwargs: Any ) -> None: """Delete linked storage accounts for an Application Insights component. @@ -476,12 +456,11 @@ async def delete( # pylint: disable=inconsistent-return-statements storage account. "ServiceProfiler" Required. :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -492,25 +471,25 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,8 +500,4 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py index 2595b54497b6..5289496d8064 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py @@ -5,17 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ComponentLinkedStorageAccounts -from ._models_py3 import ComponentLinkedStorageAccountsPatch -from ._models_py3 import ErrorResponseLinkedStorage -from ._models_py3 import ErrorResponseLinkedStorageError -from ._models_py3 import ProxyResource -from ._models_py3 import Resource +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import StorageType +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ComponentLinkedStorageAccounts, + ComponentLinkedStorageAccountsPatch, + ErrorResponseLinkedStorage, + ErrorResponseLinkedStorageError, + ProxyResource, + Resource, +) + +from ._application_insights_management_client_enums import ( # type: ignore + StorageType, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -27,5 +38,5 @@ "Resource", "StorageType", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py index 9ed2227e61be..600f20312e31 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -12,7 +11,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -22,7 +20,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,7 +56,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 @@ -67,22 +65,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 ComponentLinkedStorageAccounts(ProxyResource): """An Application Insights component linked storage accounts. @@ -90,7 +72,7 @@ class ComponentLinkedStorageAccounts(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 diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/__init__.py index e9bbe941e284..674336f5dd75 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "ComponentLinkedStorageAccountsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py index d8b3032fb3af..c6caca8c1120 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +64,7 @@ def build_get_request( "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), } - _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") @@ -100,7 +103,7 @@ def build_create_and_update_request( "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), } - _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") @@ -141,7 +144,7 @@ def build_update_request( "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), } - _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") @@ -181,7 +184,7 @@ def build_delete_request( "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), } - _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") @@ -210,6 +213,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -226,13 +230,12 @@ def get( storage account. "ServiceProfiler" Required. :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,25 +246,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -271,16 +274,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", 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.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @overload def create_and_update( @@ -311,7 +310,6 @@ def create_and_update( :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: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -324,7 +322,7 @@ def create_and_update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: IO, + linked_storage_accounts_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -342,11 +340,10 @@ def create_and_update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. Required. - :type linked_storage_accounts_properties: IO + :type linked_storage_accounts_properties: 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 :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -359,7 +356,7 @@ def create_and_update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO[bytes]], **kwargs: Any ) -> _models.ComponentLinkedStorageAccounts: """Replace current linked storage account for an Application Insights component. @@ -375,19 +372,16 @@ def create_and_update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. Is either a - ComponentLinkedStorageAccounts type or a IO type. Required. + ComponentLinkedStorageAccounts type or a IO[bytes] type. Required. :type linked_storage_accounts_properties: - ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts 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 + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts or + IO[bytes] :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,19 +392,21 @@ def create_and_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(linked_storage_accounts_properties, (IO, bytes)): + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): _content = linked_storage_accounts_properties else: _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccounts") - request = build_create_and_update_request( + _request = build_create_and_update_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, @@ -419,16 +415,14 @@ def create_and_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_and_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,16 +432,12 @@ def create_and_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_and_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @overload def update( @@ -478,7 +468,6 @@ def update( :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: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -491,7 +480,7 @@ def update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: IO, + linked_storage_accounts_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -509,11 +498,10 @@ def update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. Required. - :type linked_storage_accounts_properties: IO + :type linked_storage_accounts_properties: 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 :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts @@ -526,7 +514,7 @@ def update( resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], - linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO[bytes]], **kwargs: Any ) -> _models.ComponentLinkedStorageAccounts: """Update linked storage accounts for an Application Insights component. @@ -542,20 +530,16 @@ def update( ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. Is either a - ComponentLinkedStorageAccountsPatch type or a IO type. Required. + ComponentLinkedStorageAccountsPatch type or a IO[bytes] type. Required. :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch - 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 + or IO[bytes] :return: ComponentLinkedStorageAccounts or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,19 +550,21 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(linked_storage_accounts_properties, (IO, bytes)): + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): _content = linked_storage_accounts_properties else: _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccountsPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, @@ -587,16 +573,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -606,16 +590,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response) + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -632,12 +612,11 @@ def delete( # pylint: disable=inconsistent-return-statements storage account. "ServiceProfiler" Required. :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType - :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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,25 +627,25 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-03-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, storage_type=storage_type, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -677,8 +656,4 @@ def delete( # pylint: disable=inconsistent-return-statements 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.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py index 8b35f9a26497..0db01fa2ff79 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import LiveTokenOperations, Operations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations @@ -43,16 +45,38 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2020-06-02-preview" + ) + self.live_token = LiveTokenOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-06-02-preview" + ) + + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,12 +96,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py index c1481e69f65d..ddd65955a856 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +31,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-06-02-preview") if credential is None: @@ -43,6 +40,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +49,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json index d8fb893b7ea4..ed9b2d4294f4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py index b1d0c3f023a6..13aad0232787 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import LiveTokenOperations, Operations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations @@ -44,16 +46,40 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2020-06-02-preview" + ) + self.live_token = LiveTokenOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-06-02-preview" + ) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py index b54289891f14..e80d7e94bb7b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +31,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-06-02-preview") if credential is None: @@ -43,6 +40,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +49,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/__init__.py index 2b29270be7d2..a0f09b210fc1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/__init__.py @@ -5,17 +5,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._live_token_operations import LiveTokenOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._live_token_operations import LiveTokenOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "LiveTokenOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py index 426b55642ebb..9d9d3f4530f1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._live_token_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: @@ -56,12 +59,11 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LiveTokenResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.LiveTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -72,22 +74,22 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-06-02-preview") + ) cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -97,11 +99,9 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LiveTokenResponse", pipeline_response) + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/generatelivetoken"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py index 5dd93f3a9a9b..53bb7532bb68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,14 +53,15 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationLive"]: + # pylint: disable=line-too-long """List available operations. List the available operations supported by the resource provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationLive or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] @@ -67,10 +70,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationLive"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-06-02-preview") + ) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,14 +86,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationLive"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) @@ -116,11 +118,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/microsoft.insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py index 12b113aab624..04eb8d951dbb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py @@ -5,15 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ErrorResponseLinkedStorage -from ._models_py3 import ErrorResponseLinkedStorageError -from ._models_py3 import LiveTokenResponse -from ._models_py3 import OperationInfo -from ._models_py3 import OperationLive -from ._models_py3 import OperationsListResult +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ErrorResponseLinkedStorage, + ErrorResponseLinkedStorageError, + LiveTokenResponse, + OperationInfo, + OperationLive, + OperationsListResult, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -24,5 +33,5 @@ "OperationLive", "OperationsListResult", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py index 319e56b4fc32..d83bc3b11047 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -15,10 +14,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/__init__.py index 2b29270be7d2..a0f09b210fc1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/__init__.py @@ -5,17 +5,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._live_token_operations import LiveTokenOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._live_token_operations import LiveTokenOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "LiveTokenOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py index e837ea1a79bd..1d1c7a22f637 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +49,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _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") @@ -76,6 +78,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: @@ -83,12 +86,11 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LiveTokenResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.LiveTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,22 +101,22 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-06-02-preview") + ) cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,11 +126,9 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LiveTokenResponse", pipeline_response) + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/generatelivetoken"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py index e208b8057826..5034cb54d8ec 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,6 +75,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.OperationLive"]: @@ -80,7 +83,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationLive"]: List the available operations supported by the resource provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationLive or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] @@ -89,10 +91,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationLive"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-02-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-06-02-preview") + ) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,14 +107,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationLive"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +123,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) @@ -138,11 +139,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/microsoft.insights/operations"} diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py index 7fc883d8f339..1cb97ff73744 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbookTemplatesOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations @@ -49,17 +51,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-11-20" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py index a3e1e3266b3c..75adee93872a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-11-20") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json index 57466949b9f2..5d989bb692cc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbook_templates": "WorkbookTemplatesOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py index 27af2a651683..b46fff191813 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbookTemplatesOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations @@ -49,17 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-11-20" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py index 4f9ff954254a..9f0ec438c476 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-11-20") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/__init__.py index 272f3eb3be4e..aa730bc20e57 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbook_templates_operations import WorkbookTemplatesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbookTemplatesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py index 3a2abc70ea01..e895c7238918 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbook_templates_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,6 +61,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -68,7 +72,6 @@ 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 WorkbookTemplate or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] @@ -77,10 +80,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,16 +94,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 @@ -111,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) @@ -128,11 +128,11 @@ async def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +145,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.Insights/workbooktemplates" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: """Get a single workbook template by its resourceName. @@ -158,12 +154,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,24 +169,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: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[_models.WorkbookTemplate] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,21 +194,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.Insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -223,12 +210,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,24 +225,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,11 +251,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooktemplates/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -297,7 +277,6 @@ async def create_or_update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +287,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: IO, + workbook_template_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -322,11 +301,10 @@ async def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_template_properties: IO + :type workbook_template_properties: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -337,7 +315,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: Union[_models.WorkbookTemplate, IO], + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], **kwargs: Any ) -> _models.WorkbookTemplate: """Create a new workbook template. @@ -348,18 +326,14 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new - workbook. Is either a WorkbookTemplate type or a IO type. Required. + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. :type workbook_template_properties: - ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate 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 + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate or IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -370,19 +344,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_properties, (IO, bytes)): + if isinstance(workbook_template_properties, (IOBase, bytes)): _content = workbook_template_properties else: _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") - 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, @@ -390,16 +364,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -409,21 +381,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}" - } - @overload async def update( self, @@ -448,7 +412,6 @@ async def update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -459,7 +422,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[IO] = None, + workbook_template_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -473,11 +436,10 @@ async def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. Default value is None. - :type workbook_template_update_parameters: IO + :type workbook_template_update_parameters: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -488,7 +450,9 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[Union[_models.WorkbookTemplateUpdateParameters, IO]] = None, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, **kwargs: Any ) -> _models.WorkbookTemplate: """Updates a workbook template that has already been added. @@ -499,19 +463,16 @@ async def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a - workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO type. Default - value is None. - :type workbook_template_update_parameters: - ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters or + IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -522,14 +483,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_update_parameters, (IO, bytes)): + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): _content = workbook_template_update_parameters else: if workbook_template_update_parameters is not None: @@ -537,7 +498,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -545,16 +506,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,13 +523,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.Insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py index 8897c975b74a..9bfd87c9013b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py @@ -5,18 +5,27 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import WorkbookTemplate -from ._models_py3 import WorkbookTemplateError -from ._models_py3 import WorkbookTemplateErrorBody -from ._models_py3 import WorkbookTemplateErrorFieldContract -from ._models_py3 import WorkbookTemplateGallery -from ._models_py3 import WorkbookTemplateLocalizedGallery -from ._models_py3 import WorkbookTemplateResource -from ._models_py3 import WorkbookTemplateUpdateParameters -from ._models_py3 import WorkbookTemplatesListResult +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + WorkbookTemplate, + WorkbookTemplateError, + WorkbookTemplateErrorBody, + WorkbookTemplateErrorFieldContract, + WorkbookTemplateGallery, + WorkbookTemplateLocalizedGallery, + WorkbookTemplateResource, + WorkbookTemplateUpdateParameters, + WorkbookTemplatesListResult, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -30,5 +39,5 @@ "WorkbookTemplateUpdateParameters", "WorkbookTemplatesListResult", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py index a7d3a1e9fe6c..71a335273109 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -15,10 +14,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -28,7 +26,7 @@ class WorkbookTemplateResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -77,7 +75,7 @@ class WorkbookTemplate(WorkbookTemplateResource): Variables are 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: Azure resource Id. :vartype id: str diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/__init__.py index 272f3eb3be4e..aa730bc20e57 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbook_templates_operations import WorkbookTemplatesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbookTemplatesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py index 52712c13c455..d22bc0473ad7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,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") @@ -86,7 +89,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -119,7 +122,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -153,7 +156,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -189,7 +192,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -220,6 +223,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WorkbookTemplate"]: @@ -228,7 +232,6 @@ 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 WorkbookTemplate or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] @@ -237,10 +240,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,16 +254,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 @@ -271,14 +272,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) @@ -288,11 +288,11 @@ def extract_data(pipeline_response): return 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,10 +305,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.Insights/workbooktemplates" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: """Get a single workbook template by its resourceName. @@ -318,12 +314,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,24 +329,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: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[_models.WorkbookTemplate] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +354,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.Insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -383,12 +372,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,24 +387,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -427,11 +413,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooktemplates/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -457,7 +439,6 @@ def create_or_update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +449,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: IO, + workbook_template_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -482,11 +463,10 @@ def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_template_properties: IO + :type workbook_template_properties: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -497,7 +477,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_template_properties: Union[_models.WorkbookTemplate, IO], + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], **kwargs: Any ) -> _models.WorkbookTemplate: """Create a new workbook template. @@ -508,18 +488,14 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new - workbook. Is either a WorkbookTemplate type or a IO type. Required. + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. :type workbook_template_properties: - ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate 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 + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate or IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,19 +506,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_properties, (IO, bytes)): + if isinstance(workbook_template_properties, (IOBase, bytes)): _content = workbook_template_properties else: _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") - 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, @@ -550,16 +526,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,21 +543,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}" - } - @overload def update( self, @@ -608,7 +574,6 @@ def update( :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: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -619,7 +584,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[IO] = None, + workbook_template_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -633,11 +598,10 @@ def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. Default value is None. - :type workbook_template_update_parameters: IO + :type workbook_template_update_parameters: 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 :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +612,9 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_template_update_parameters: Optional[Union[_models.WorkbookTemplateUpdateParameters, IO]] = None, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, **kwargs: Any ) -> _models.WorkbookTemplate: """Updates a workbook template that has already been added. @@ -659,19 +625,16 @@ def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a - workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO type. Default - value is None. - :type workbook_template_update_parameters: - ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters or + IO[bytes] :return: WorkbookTemplate or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -682,14 +645,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-11-20")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_template_update_parameters, (IO, bytes)): + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): _content = workbook_template_update_parameters else: if workbook_template_update_parameters is not None: @@ -697,7 +660,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -705,16 +668,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -724,13 +685,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkbookTemplate", pipeline_response) + deserialized = self._deserialize("WorkbookTemplate", 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.Insights/workbooktemplates/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py index 7ddcf1fd7e6e..68d540679095 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import MyWorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar my_workbooks: MyWorkbooksOperations operations @@ -49,15 +51,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.my_workbooks = MyWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-08" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py index 7a7b7204ff41..7434f5aae2c8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-03-08") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json index 09b0671b9881..9423e1d6bf54 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "my_workbooks": "MyWorkbooksOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py index afd5ab658896..ea58f8581082 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import MyWorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar my_workbooks: MyWorkbooksOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.my_workbooks = MyWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-08" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py index 1728130daab4..5ec00e58979d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-03-08") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/__init__.py index 53e6f0e8bfbb..05ffdf9526ba 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._my_workbooks_operations import MyWorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._my_workbooks_operations import MyWorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "MyWorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py index a26477fc4c3d..fa8f1107a9c2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._my_workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,6 +62,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -87,7 +91,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] @@ -96,10 +99,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,7 +113,7 @@ 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, category=category, @@ -118,12 +121,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -134,14 +135,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -151,11 +151,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -168,10 +168,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.Insights/myWorkbooks" - } - @distributed_trace def list_by_subscription( self, @@ -191,7 +187,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] @@ -200,10 +195,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -214,18 +209,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -236,14 +229,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -253,11 +245,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,8 +262,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks"} - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.MyWorkbook: """Get a single private workbook by its resourceName. @@ -281,12 +271,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,24 +286,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: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,21 +311,15 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -346,12 +327,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,24 +342,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,11 +368,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/myWorkbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -423,7 +397,6 @@ async def create_or_update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -434,7 +407,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -449,14 +422,13 @@ async def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -467,7 +439,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.MyWorkbook: @@ -479,20 +451,17 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or IO + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,19 +472,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - 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, @@ -524,16 +493,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -543,21 +510,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MyWorkbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}" - } - @overload async def update( self, @@ -585,7 +544,6 @@ async def update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -596,7 +554,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -611,14 +569,13 @@ async def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -629,7 +586,7 @@ async def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.MyWorkbook: @@ -641,20 +598,17 @@ async def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or IO + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -665,19 +619,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -686,16 +640,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -705,13 +657,9 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py index 9ccfaf4cf8e1..7ff21bf3e6ae 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py @@ -5,23 +5,34 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ErrorDefinition -from ._models_py3 import InnerErrorTrace -from ._models_py3 import MyWorkbook -from ._models_py3 import MyWorkbookError -from ._models_py3 import MyWorkbookManagedIdentity -from ._models_py3 import MyWorkbookResource -from ._models_py3 import MyWorkbookUserAssignedIdentities -from ._models_py3 import MyWorkbooksListResult -from ._models_py3 import SystemData +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import CategoryType -from ._application_insights_management_client_enums import CreatedByType -from ._application_insights_management_client_enums import Kind -from ._application_insights_management_client_enums import MyWorkbookManagedIdentityType +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ErrorDefinition, + InnerErrorTrace, + MyWorkbook, + MyWorkbookError, + MyWorkbookManagedIdentity, + MyWorkbookResource, + MyWorkbookUserAssignedIdentities, + MyWorkbooksListResult, + SystemData, +) + +from ._application_insights_management_client_enums import ( # type: ignore + CategoryType, + CreatedByType, + Kind, + MyWorkbookManagedIdentityType, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -39,5 +50,5 @@ "Kind", "MyWorkbookManagedIdentityType", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py index 72d3ff98416e..039465a46e6f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -13,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -141,7 +139,7 @@ def __init__( self.etag = etag -class MyWorkbook(MyWorkbookResource): # pylint: disable=too-many-instance-attributes +class MyWorkbook(MyWorkbookResource): """An Application Insights private workbook definition. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/__init__.py index 53e6f0e8bfbb..05ffdf9526ba 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._my_workbooks_operations import MyWorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._my_workbooks_operations import MyWorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "MyWorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py index 28caa57ec73f..ad72c2362277 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -102,7 +105,7 @@ def build_list_by_subscription_request( "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["category"] = _SERIALIZER.query("category", category, "str") @@ -138,7 +141,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -171,7 +174,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -210,7 +213,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -253,7 +256,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -286,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group( @@ -314,7 +318,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] @@ -323,10 +326,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,7 +340,7 @@ 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, category=category, @@ -345,12 +348,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -361,14 +362,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -378,11 +378,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,10 +395,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.Insights/myWorkbooks" - } - @distributed_trace def list_by_subscription( self, @@ -418,7 +414,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MyWorkbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] @@ -427,10 +422,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,18 +436,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -463,14 +456,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) @@ -480,11 +472,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,8 +489,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks"} - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.MyWorkbook: """Get a single private workbook by its resourceName. @@ -508,12 +498,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,24 +513,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: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[_models.MyWorkbook] = 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -551,16 +538,12 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -573,12 +556,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,24 +571,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -617,11 +597,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/myWorkbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -650,7 +626,6 @@ def create_or_update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +636,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -676,14 +651,13 @@ def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -694,7 +668,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.MyWorkbook: @@ -706,20 +680,17 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or IO + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -730,19 +701,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - 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, @@ -751,16 +722,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -770,21 +739,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MyWorkbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}" - } - @overload def update( self, @@ -812,7 +773,6 @@ def update( :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -823,7 +783,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -838,14 +798,13 @@ def update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: @@ -856,7 +815,7 @@ def update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.MyWorkbook, IO], + workbook_properties: Union[_models.MyWorkbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.MyWorkbook: @@ -868,20 +827,17 @@ def update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new private - workbook. Is either a MyWorkbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or IO + workbook. Is either a MyWorkbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: MyWorkbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -892,19 +848,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-08")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MyWorkbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "MyWorkbook") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -913,16 +869,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -932,13 +886,9 @@ def update( error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MyWorkbook", pipeline_response) + deserialized = self._deserialize("MyWorkbook", 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.Insights/myWorkbooks/{resourceName}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py index 8768e9249548..7beb488a8822 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -48,15 +50,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-08-01" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -76,12 +98,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py index dec40266d428..27f9f7203bfa 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-08-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json index 5598d848cd9a..799a2485cc16 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbooks": "WorkbooksOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py index 521be975273a..5c6abd5c61e2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-08-01" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py index 855e358d554c..54cc4d527903 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-08-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/__init__.py index ac41cebc9fcd..244af54256b7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py index 4c7adfef1eed..a4078e15167a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +64,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -81,7 +85,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -90,10 +93,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,18 +107,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -126,14 +127,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -143,11 +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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,8 +160,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks"} - @distributed_trace def list_by_resource_group( self, @@ -189,7 +187,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -198,10 +195,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,7 +209,7 @@ 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, category=category, @@ -220,12 +217,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -236,14 +231,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -253,11 +247,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,10 +264,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.Insights/workbooks" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any @@ -289,12 +279,11 @@ async def get( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,25 +294,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Workbook] = 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, can_fetch_content=can_fetch_content, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,21 +320,15 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.Insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -355,12 +336,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,24 +351,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -399,11 +377,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -432,7 +406,6 @@ async def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -443,7 +416,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -458,14 +431,13 @@ async def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +448,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.Workbook: @@ -488,20 +460,17 @@ async def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook or IO + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,19 +481,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -533,16 +502,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,21 +519,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @overload async def update( self, @@ -595,7 +554,6 @@ async def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -607,7 +565,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -624,11 +582,10 @@ async def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +597,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -654,18 +611,14 @@ async def update( None. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -676,14 +629,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -691,7 +644,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -700,16 +653,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -719,21 +670,13 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @distributed_trace def revisions_list( self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -745,7 +688,6 @@ def revisions_list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -754,10 +696,10 @@ def revisions_list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -768,17 +710,15 @@ def revisions_list( def prepare_request(next_link=None): if not next_link: - request = build_revisions_list_request( + _request = build_revisions_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revisions_list.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 @@ -789,14 +729,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -806,11 +745,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -823,10 +762,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - revisions_list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions" - } - @distributed_trace_async async def revision_get( self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any @@ -840,12 +775,11 @@ async def revision_get( :type resource_name: str :param revision_id: The id of the workbook's revision. Required. :type revision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -856,25 +790,23 @@ async def revision_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) - request = build_revision_get_request( + _request = build_revision_get_request( resource_group_name=resource_group_name, resource_name=resource_name, revision_id=revision_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revision_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -884,13 +816,9 @@ async def revision_get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - revision_get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py index e592b28040ea..68da5baea7a6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py @@ -5,28 +5,39 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ManagedServiceIdentity -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import Workbook -from ._models_py3 import WorkbookError -from ._models_py3 import WorkbookErrorDefinition -from ._models_py3 import WorkbookInnerErrorTrace -from ._models_py3 import WorkbookResource -from ._models_py3 import WorkbookResourceIdentity -from ._models_py3 import WorkbookUpdateParameters -from ._models_py3 import WorkbooksListResult +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import CategoryType -from ._application_insights_management_client_enums import CreatedByType -from ._application_insights_management_client_enums import Kind -from ._application_insights_management_client_enums import ManagedServiceIdentityType -from ._application_insights_management_client_enums import SharedTypeKind +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ManagedServiceIdentity, + Resource, + SystemData, + TrackedResource, + UserAssignedIdentity, + Workbook, + WorkbookError, + WorkbookErrorDefinition, + WorkbookInnerErrorTrace, + WorkbookResource, + WorkbookResourceIdentity, + WorkbookUpdateParameters, + WorkbooksListResult, +) + +from ._application_insights_management_client_enums import ( # type: ignore + CategoryType, + CreatedByType, + Kind, + ManagedServiceIdentityType, + SharedTypeKind, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -49,5 +60,5 @@ "ManagedServiceIdentityType", "SharedTypeKind", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py index 7003cbc463c2..df3d09c390c9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -13,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -22,7 +20,7 @@ class ManagedServiceIdentity(_serialization.Model): Variables are 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 principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -37,7 +35,7 @@ class ManagedServiceIdentity(_serialization.Model): ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] @@ -71,7 +69,7 @@ def __init__( ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] @@ -89,7 +87,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 @@ -192,10 +190,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 @@ -268,10 +266,10 @@ class WorkbookResource(TrackedResource): Variables are 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 @@ -339,15 +337,15 @@ def __init__( self.etag = etag -class Workbook(WorkbookResource): # pylint: disable=too-many-instance-attributes +class Workbook(WorkbookResource): """An Application Insights workbook 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. + 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 @@ -575,7 +573,7 @@ class WorkbookResourceIdentity(ManagedServiceIdentity): Variables are 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 principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -590,47 +588,12 @@ class WorkbookResourceIdentity(ManagedServiceIdentity): ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] """ - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or - ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] - """ - super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) - class WorkbooksListResult(_serialization.Model): """Workbook list result. diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/__init__.py index ac41cebc9fcd..244af54256b7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py index 5d76fa65a661..db1e537ae678 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py @@ -6,6 +6,8 @@ # 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, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +60,7 @@ def build_list_by_subscription_request( "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["category"] = _SERIALIZER.query("category", category, "str") @@ -100,7 +104,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -145,7 +149,7 @@ def build_get_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -180,7 +184,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -219,7 +223,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -262,7 +266,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -299,7 +303,7 @@ def build_revisions_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -333,7 +337,7 @@ def build_revision_get_request( "revisionId": _SERIALIZER.url("revision_id", revision_id, "str"), } - _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") @@ -362,6 +366,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -382,7 +387,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -391,10 +395,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,18 +409,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -427,14 +429,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -444,11 +445,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,8 +462,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks"} - @distributed_trace def list_by_resource_group( self, @@ -490,7 +489,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -499,10 +497,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,7 +511,7 @@ 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, category=category, @@ -521,12 +519,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -537,14 +533,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -554,11 +549,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,10 +566,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.Insights/workbooks" - } - @distributed_trace def get( self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any @@ -590,12 +581,11 @@ def get( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,25 +596,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Workbook] = 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, can_fetch_content=can_fetch_content, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -634,16 +622,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.Insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +640,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,24 +655,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -700,11 +681,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -733,7 +710,6 @@ def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -744,7 +720,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -759,14 +735,13 @@ def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +752,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.Workbook: @@ -789,20 +764,17 @@ def create_or_update( :param resource_name: The name of the Application Insights component resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook or IO + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -813,19 +785,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -834,16 +806,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,21 +823,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @overload def update( self, @@ -896,7 +858,6 @@ def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -908,7 +869,7 @@ def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -925,11 +886,10 @@ def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -941,7 +901,7 @@ def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -955,18 +915,14 @@ def update( None. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,14 +933,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -992,7 +948,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1001,16 +957,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,21 +974,13 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @distributed_trace def revisions_list( self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -1046,7 +992,6 @@ def revisions_list( :type resource_group_name: str :param resource_name: The name of the Application Insights component resource. 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 Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] @@ -1055,10 +1000,10 @@ def revisions_list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,17 +1014,15 @@ def revisions_list( def prepare_request(next_link=None): if not next_link: - request = build_revisions_list_request( + _request = build_revisions_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revisions_list.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 @@ -1090,14 +1033,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -1107,11 +1049,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1124,10 +1066,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - revisions_list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions" - } - @distributed_trace def revision_get( self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any @@ -1141,12 +1079,11 @@ def revision_get( :type resource_name: str :param revision_id: The id of the workbook's revision. Required. :type revision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1157,25 +1094,23 @@ def revision_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) - request = build_revision_get_request( + _request = build_revision_get_request( resource_group_name=resource_group_name, resource_name=resource_name, revision_id=revision_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revision_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1185,13 +1120,9 @@ def revision_get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - revision_get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_application_insights_management_client.py index 1859ce9c6b29..b6e8454cb5ff 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import LiveTokenOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar live_token: LiveTokenOperations operations @@ -40,15 +42,35 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-10-14" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -68,12 +90,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_configuration.py index 6dd8ca8aea14..b6f24bcc88ba 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +31,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-10-14") if credential is None: @@ -43,6 +40,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +49,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_metadata.json index a47f3e10ea49..698c50fa0b4f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "live_token": "LiveTokenOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_application_insights_management_client.py index d38ce20064d6..0768e29fe53c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import LiveTokenOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar live_token: LiveTokenOperations operations @@ -40,15 +42,37 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-10-14" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -68,12 +92,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_configuration.py index 95262db7771d..6674c6fb85f9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +31,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-10-14") if credential is None: @@ -43,6 +40,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +49,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/__init__.py index 4596cf1a7878..46b276948dcf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._live_token_operations import LiveTokenOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._live_token_operations import LiveTokenOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "LiveTokenOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/_live_token_operations.py index c5ce73f8e10d..6dad3c3eeab0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/aio/operations/_live_token_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._live_token_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: @@ -56,12 +59,11 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LiveTokenResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_10.models.LiveTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -72,22 +74,20 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-14")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-14")) cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -97,11 +97,9 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenRespon error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LiveTokenResponse", pipeline_response) + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/generatelivetoken"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/__init__.py index 12b113aab624..04eb8d951dbb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/__init__.py @@ -5,15 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ErrorResponseLinkedStorage -from ._models_py3 import ErrorResponseLinkedStorageError -from ._models_py3 import LiveTokenResponse -from ._models_py3 import OperationInfo -from ._models_py3 import OperationLive -from ._models_py3 import OperationsListResult +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ErrorResponseLinkedStorage, + ErrorResponseLinkedStorageError, + LiveTokenResponse, + OperationInfo, + OperationLive, + OperationsListResult, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -24,5 +33,5 @@ "OperationLive", "OperationsListResult", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/_models_py3.py index ee53ca2e6adc..0055b58c1b9b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -15,10 +14,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/__init__.py index 4596cf1a7878..46b276948dcf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._live_token_operations import LiveTokenOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._live_token_operations import LiveTokenOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "LiveTokenOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/_live_token_operations.py index db859621dd32..20c3dd26bf19 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_10/operations/_live_token_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -17,16 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -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 .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +49,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _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") @@ -76,6 +78,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: @@ -83,12 +86,11 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LiveTokenResponse or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_10.models.LiveTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,22 +101,20 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-14")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-14")) cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,11 +124,9 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LiveTokenResponse", pipeline_response) + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/generatelivetoken"} + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_application_insights_management_client.py index 2f8d34f2bb1b..0e2dd8e7f23a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -48,15 +50,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-01" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -76,12 +98,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_configuration.py index f68b4ed9735d..a0122c04315c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_metadata.json index 53afcd320e9d..ab1800ebae6a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbooks": "WorkbooksOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_application_insights_management_client.py index a99dd800b1fa..018e65dc1e17 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WorkbooksOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-01" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_configuration.py index 51896ca42c1f..b118e45eccca 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/__init__.py index ac41cebc9fcd..244af54256b7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/_workbooks_operations.py index b167621097b5..843cd4fffe41 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/aio/operations/_workbooks_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workbooks_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +64,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -81,7 +85,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -90,10 +93,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,18 +107,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -126,14 +127,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -143,11 +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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,8 +160,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks"} - @distributed_trace def list_by_resource_group( self, @@ -189,7 +187,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -198,10 +195,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,7 +209,7 @@ 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, category=category, @@ -220,12 +217,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -236,14 +231,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -253,11 +247,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,10 +264,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.Insights/workbooks" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any @@ -289,12 +279,11 @@ async def get( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,25 +294,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.Workbook] = 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, can_fetch_content=can_fetch_content, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,21 +320,15 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.Insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -355,12 +336,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,24 +351,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -399,11 +377,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update( @@ -432,7 +406,6 @@ async def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -443,7 +416,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -458,14 +431,13 @@ async def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +448,7 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.Workbook: @@ -488,20 +460,17 @@ async def create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook or IO + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,19 +481,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -533,16 +502,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,21 +519,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @overload async def update( self, @@ -595,7 +554,6 @@ async def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -607,7 +565,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -624,11 +582,10 @@ async def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +597,7 @@ async def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -654,18 +611,14 @@ async def update( None. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2022_04_01.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2022_04_01.models.WorkbookUpdateParameters or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -676,14 +629,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -691,7 +644,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -700,16 +653,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -719,21 +670,13 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @distributed_trace def revisions_list( self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -745,7 +688,6 @@ def revisions_list( :type resource_group_name: str :param resource_name: The name of the resource. 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 Workbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -754,10 +696,10 @@ def revisions_list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -768,17 +710,15 @@ def revisions_list( def prepare_request(next_link=None): if not next_link: - request = build_revisions_list_request( + _request = build_revisions_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revisions_list.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 @@ -789,14 +729,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -806,11 +745,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -823,10 +762,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - revisions_list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions" - } - @distributed_trace_async async def revision_get( self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any @@ -840,12 +775,11 @@ async def revision_get( :type resource_name: str :param revision_id: The id of the workbook's revision. Required. :type revision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -856,25 +790,23 @@ async def revision_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) - request = build_revision_get_request( + _request = build_revision_get_request( resource_group_name=resource_group_name, resource_name=resource_name, revision_id=revision_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revision_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -884,13 +816,9 @@ async def revision_get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - revision_get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/__init__.py index b9807ed39f9e..3ef7aa01aafc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/__init__.py @@ -5,28 +5,39 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import ManagedServiceIdentity -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import Workbook -from ._models_py3 import WorkbookError -from ._models_py3 import WorkbookErrorDefinition -from ._models_py3 import WorkbookInnerErrorTrace -from ._models_py3 import WorkbookResource -from ._models_py3 import WorkbookResourceIdentity -from ._models_py3 import WorkbookUpdateParameters -from ._models_py3 import WorkbooksListResult +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import CategoryType -from ._application_insights_management_client_enums import CreatedByType -from ._application_insights_management_client_enums import ManagedServiceIdentityType -from ._application_insights_management_client_enums import WorkbookSharedTypeKind -from ._application_insights_management_client_enums import WorkbookUpdateSharedTypeKind +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + ManagedServiceIdentity, + Resource, + SystemData, + TrackedResource, + UserAssignedIdentity, + Workbook, + WorkbookError, + WorkbookErrorDefinition, + WorkbookInnerErrorTrace, + WorkbookResource, + WorkbookResourceIdentity, + WorkbookUpdateParameters, + WorkbooksListResult, +) + +from ._application_insights_management_client_enums import ( # type: ignore + CategoryType, + CreatedByType, + ManagedServiceIdentityType, + WorkbookSharedTypeKind, + WorkbookUpdateSharedTypeKind, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -49,5 +60,5 @@ "WorkbookSharedTypeKind", "WorkbookUpdateSharedTypeKind", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/_models_py3.py index fb4e008e18c7..5904bf48325e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -13,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -22,7 +20,7 @@ class ManagedServiceIdentity(_serialization.Model): Variables are 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 principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -37,7 +35,7 @@ class ManagedServiceIdentity(_serialization.Model): ~azure.mgmt.applicationinsights.v2022_04_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2022_04_01.models.UserAssignedIdentity] @@ -71,7 +69,7 @@ def __init__( ~azure.mgmt.applicationinsights.v2022_04_01.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2022_04_01.models.UserAssignedIdentity] @@ -89,7 +87,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 @@ -192,10 +190,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 @@ -268,10 +266,10 @@ class WorkbookResource(TrackedResource): Variables are 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 @@ -338,15 +336,15 @@ def __init__( self.etag = etag -class Workbook(WorkbookResource): # pylint: disable=too-many-instance-attributes +class Workbook(WorkbookResource): """A workbook 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. + 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 @@ -573,7 +571,7 @@ class WorkbookResourceIdentity(ManagedServiceIdentity): Variables are 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 principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -588,47 +586,12 @@ class WorkbookResourceIdentity(ManagedServiceIdentity): ~azure.mgmt.applicationinsights.v2022_04_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2022_04_01.models.UserAssignedIdentity] """ - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or - ~azure.mgmt.applicationinsights.v2022_04_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.applicationinsights.v2022_04_01.models.UserAssignedIdentity] - """ - super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) - class WorkbooksListResult(_serialization.Model): """Workbook list result. diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/__init__.py index ac41cebc9fcd..244af54256b7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._workbooks_operations import WorkbooksOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._workbooks_operations import WorkbooksOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WorkbooksOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/_workbooks_operations.py index 5bae3628e549..916d395536c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_04_01/operations/_workbooks_operations.py @@ -6,6 +6,8 @@ # 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, overload import urllib.parse @@ -19,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +60,7 @@ def build_list_by_subscription_request( "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["category"] = _SERIALIZER.query("category", category, "str") @@ -100,7 +104,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["category"] = _SERIALIZER.query("category", category, "str") @@ -145,7 +149,7 @@ def build_get_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -180,7 +184,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -219,7 +223,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -262,7 +266,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if source_id is not None: @@ -299,7 +303,7 @@ def build_revisions_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _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") @@ -333,7 +337,7 @@ def build_revision_get_request( "revisionId": _SERIALIZER.url("revision_id", revision_id, "str"), } - _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") @@ -362,6 +366,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -382,7 +387,6 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -391,10 +395,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,18 +409,16 @@ def list_by_subscription( 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, category=category, tags=tags, can_fetch_content=can_fetch_content, 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 @@ -427,14 +429,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -444,11 +445,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,8 +462,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks"} - @distributed_trace def list_by_resource_group( self, @@ -490,7 +489,6 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -499,10 +497,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,7 +511,7 @@ 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, category=category, @@ -521,12 +519,10 @@ def prepare_request(next_link=None): source_id=source_id, can_fetch_content=can_fetch_content, 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 @@ -537,14 +533,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -554,11 +549,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,10 +566,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.Insights/workbooks" - } - @distributed_trace def get( self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any @@ -590,12 +581,11 @@ def get( applicable workbook. If false, only return summary content for workbooks. Default value is None. :type can_fetch_content: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,25 +596,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.Workbook] = 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, can_fetch_content=can_fetch_content, 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -634,16 +622,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", 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.Insights/workbooks/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +640,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_name: The name of the resource. Required. :type 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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,24 +655,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[None] = 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.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -700,11 +681,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Insights/workbooks/{resourceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update( @@ -733,7 +710,6 @@ def create_or_update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -744,7 +720,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: IO, + workbook_properties: IO[bytes], source_id: Optional[str] = None, *, content_type: str = "application/json", @@ -759,14 +735,13 @@ def create_or_update( :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Required. - :type workbook_properties: IO + :type workbook_properties: IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +752,7 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - workbook_properties: Union[_models.Workbook, IO], + workbook_properties: Union[_models.Workbook, IO[bytes]], source_id: Optional[str] = None, **kwargs: Any ) -> _models.Workbook: @@ -789,20 +764,17 @@ def create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param workbook_properties: Properties that need to be specified to create a new workbook. Is - either a Workbook type or a IO type. Required. - :type workbook_properties: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook or IO + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook or + IO[bytes] :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is None. :type source_id: str - :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -813,19 +785,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_properties, (IO, bytes)): + if isinstance(workbook_properties, (IOBase, bytes)): _content = workbook_properties else: _json = self._serialize.body(workbook_properties, "Workbook") - 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, @@ -834,16 +806,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,21 +823,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @overload def update( self, @@ -896,7 +858,6 @@ def update( :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: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -908,7 +869,7 @@ def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[IO] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -925,11 +886,10 @@ def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. Default value is None. - :type workbook_update_parameters: IO + :type workbook_update_parameters: 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 :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: @@ -941,7 +901,7 @@ def update( resource_group_name: str, resource_name: str, source_id: Optional[str] = None, - workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO]] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.Workbook: """Updates a workbook that has already been added. @@ -955,18 +915,14 @@ def update( None. :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new - workbook. Is either a WorkbookUpdateParameters type or a IO type. Default value is None. + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. :type workbook_update_parameters: - ~azure.mgmt.applicationinsights.v2022_04_01.models.WorkbookUpdateParameters 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 + ~azure.mgmt.applicationinsights.v2022_04_01.models.WorkbookUpdateParameters or IO[bytes] :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,14 +933,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workbook_update_parameters, (IO, bytes)): + if isinstance(workbook_update_parameters, (IOBase, bytes)): _content = workbook_update_parameters else: if workbook_update_parameters is not None: @@ -992,7 +948,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1001,16 +957,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,21 +974,13 @@ def update( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workbook", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" - } - @distributed_trace def revisions_list( self, resource_group_name: str, resource_name: str, **kwargs: Any @@ -1046,7 +992,6 @@ def revisions_list( :type resource_group_name: str :param resource_name: The name of the resource. 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 Workbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook] @@ -1055,10 +1000,10 @@ def revisions_list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,17 +1014,15 @@ def revisions_list( def prepare_request(next_link=None): if not next_link: - request = build_revisions_list_request( + _request = build_revisions_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revisions_list.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 @@ -1090,14 +1033,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkbooksListResult", pipeline_response) @@ -1107,11 +1049,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1124,10 +1066,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - revisions_list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions" - } - @distributed_trace def revision_get( self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any @@ -1141,12 +1079,11 @@ def revision_get( :type resource_name: str :param revision_id: The id of the workbook's revision. Required. :type revision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_04_01.models.Workbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1157,25 +1094,23 @@ def revision_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) - request = build_revision_get_request( + _request = build_revision_get_request( resource_group_name=resource_group_name, resource_name=resource_name, revision_id=revision_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revision_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1185,13 +1120,9 @@ def revision_get( error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workbook", pipeline_response) + deserialized = self._deserialize("Workbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - revision_get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}" - } + return deserialized # type: ignore diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/__init__.py index 4b38acab7db0..da2ffef86618 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_application_insights_management_client.py index 0ad3172df050..c7a595d3852a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WebTestsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar web_tests: WebTestsOperations operations @@ -48,15 +50,35 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **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.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-06-15" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -76,12 +98,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "ApplicationInsightsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_configuration.py index 4ebaf21c95f3..9291558e7ff0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-06-15") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_metadata.json index f197b0e1ba96..ff2f2694b844 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "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\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._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\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "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\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "web_tests": "WebTestsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_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/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/__init__.py index 33f308fcc074..52caca38e9e7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._application_insights_management_client import ApplicationInsightsManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ApplicationInsightsManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_application_insights_management_client.py index 8b411d38bef3..1477b7de208b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_application_insights_management_client.py @@ -8,9 +8,12 @@ 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.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -18,11 +21,10 @@ from .operations import WebTestsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar web_tests: WebTestsOperations operations @@ -49,15 +51,37 @@ def __init__( self._config = ApplicationInsightsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **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.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-06-15" + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + 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) -> "ApplicationInsightsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_configuration.py index 3145577aa29e..7e4f7c085df3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApplicationInsightsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +33,6 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): # pylint """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-06-15") if credential is None: @@ -48,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.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( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/__init__.py index 60d963dbb17b..87f6c44f1147 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._web_tests_operations import WebTestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._web_tests_operations import WebTestsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WebTestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/_web_tests_operations.py index 5211a36218b4..7ddd95c9d6da 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/aio/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._web_tests_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +37,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +63,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: @@ -68,7 +72,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -77,10 +80,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,16 +94,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_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 @@ -111,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -128,11 +128,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,10 +144,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.Insights/webtests" - } - @distributed_trace_async async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -157,12 +153,11 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,24 +168,22 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,16 +192,12 @@ async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", 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.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -233,7 +222,6 @@ async def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +232,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -258,11 +246,10 @@ async def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +260,7 @@ async def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -284,17 +271,15 @@ async def create_or_update( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. - :type web_test_definition: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest 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 + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,19 +290,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -325,16 +310,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -343,16 +326,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -377,7 +356,6 @@ async def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +366,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -402,11 +380,10 @@ async def update_tags( :type web_test_name: str :param web_test_tags: Updated tag information to associate with the web test resource. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +394,7 @@ async def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Updates the tags associated with an Application Insights web test. @@ -428,17 +405,14 @@ async def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to associate with the web test resource. Is - either a TagsResource type or a IO type. Required. - :type web_test_tags: ~azure.mgmt.applicationinsights.v2022_06_15.models.TagsResource 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 + either a TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.v2022_06_15.models.TagsResource or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,19 +423,19 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -469,16 +443,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,21 +459,15 @@ async def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, web_test_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> None: """Deletes an Application Insights web test. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -509,12 +475,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,24 +490,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,17 +515,12 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: """Get all Application Insights web test definitions for the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -571,10 +529,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,15 +543,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -604,14 +560,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -621,11 +576,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,8 +592,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -650,7 +603,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -659,10 +611,10 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -673,17 +625,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -694,14 +644,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -711,11 +660,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -726,7 +675,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/__init__.py index f9db8c5c6657..ade03471332c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/__init__.py @@ -5,21 +5,32 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import HeaderField -from ._models_py3 import TagsResource -from ._models_py3 import WebTest -from ._models_py3 import WebTestGeolocation -from ._models_py3 import WebTestListResult -from ._models_py3 import WebTestPropertiesConfiguration -from ._models_py3 import WebTestPropertiesRequest -from ._models_py3 import WebTestPropertiesValidationRules -from ._models_py3 import WebTestPropertiesValidationRulesContentValidation -from ._models_py3 import WebtestsResource +from typing import TYPE_CHECKING -from ._application_insights_management_client_enums import WebTestKind +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + HeaderField, + TagsResource, + WebTest, + WebTestGeolocation, + WebTestListResult, + WebTestPropertiesConfiguration, + WebTestPropertiesRequest, + WebTestPropertiesValidationRules, + WebTestPropertiesValidationRulesContentValidation, + WebtestsResource, +) + +from ._application_insights_management_client_enums import ( # type: ignore + WebTestKind, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -35,5 +46,5 @@ "WebtestsResource", "WebTestKind", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/_models_py3.py index 6f1724a04344..720407f757c8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/models/_models_py3.py @@ -1,5 +1,4 @@ # 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. @@ -12,7 +11,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -70,7 +68,7 @@ class WebtestsResource(_serialization.Model): Variables are 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: Azure resource Id. :vartype id: str @@ -114,12 +112,12 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class WebTest(WebtestsResource): # pylint: disable=too-many-instance-attributes +class WebTest(WebtestsResource): """An Application Insights WebTest 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. + All required parameters must be populated in order to send to server. :ivar id: Azure resource Id. :vartype id: str @@ -300,7 +298,7 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: class WebTestListResult(_serialization.Model): """A list of 0 or more Application Insights WebTest definitions. - 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 value: Set of Application Insights WebTest definitions. Required. :vartype value: list[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -470,7 +468,7 @@ def __init__( self.ignore_http_status_code = ignore_http_status_code -class WebTestPropertiesValidationRulesContentValidation(_serialization.Model): +class WebTestPropertiesValidationRulesContentValidation(_serialization.Model): # pylint: disable=name-too-long """The collection of content validation properties. :ivar content_match: Content to look for in the return of the WebTest. Must not be null or diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/__init__.py index 60d963dbb17b..87f6c44f1147 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._web_tests_operations import WebTestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._web_tests_operations import WebTestsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "WebTestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/_web_tests_operations.py index 5f0c35f49fda..7b40b9b0c19a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2022_06_15/operations/_web_tests_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,8 @@ # 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, Optional, TypeVar, Union, overload import urllib.parse @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "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") @@ -86,7 +89,7 @@ def build_get_request(resource_group_name: str, web_test_name: str, subscription "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -120,7 +123,7 @@ def build_create_or_update_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -156,7 +159,7 @@ def build_update_tags_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -188,7 +191,7 @@ def build_delete_request( "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), } - _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") @@ -209,7 +212,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "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") @@ -242,7 +245,7 @@ def build_list_by_component_request( "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") @@ -271,6 +274,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WebTest"]: @@ -279,7 +283,6 @@ 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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -288,10 +291,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,16 +305,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 @@ -322,14 +323,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -339,11 +339,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +355,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.Insights/webtests" - } - @distributed_trace def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: """Get a specific Application Insights web test definition. @@ -368,12 +364,11 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,24 +379,22 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, web_test_name=web_test_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +403,12 @@ def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -444,7 +433,6 @@ def create_or_update( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -455,7 +443,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: IO, + web_test_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -469,11 +457,10 @@ def create_or_update( :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an Application Insights web test definition. Required. - :type web_test_definition: IO + :type web_test_definition: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -484,7 +471,7 @@ def create_or_update( self, resource_group_name: str, web_test_name: str, - web_test_definition: Union[_models.WebTest, IO], + web_test_definition: Union[_models.WebTest, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Creates or updates an Application Insights web test definition. @@ -495,17 +482,15 @@ def create_or_update( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_definition: Properties that need to be specified to create or update an - Application Insights web test definition. Is either a WebTest type or a IO type. Required. - :type web_test_definition: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest 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 + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,19 +501,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_definition, (IO, bytes)): + if isinstance(web_test_definition, (IOBase, bytes)): _content = web_test_definition else: _json = self._serialize.body(web_test_definition, "WebTest") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -536,16 +521,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -554,16 +537,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -588,7 +567,6 @@ def update_tags( :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: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -599,7 +577,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: IO, + web_test_tags: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -613,11 +591,10 @@ def update_tags( :type web_test_name: str :param web_test_tags: Updated tag information to associate with the web test resource. Required. - :type web_test_tags: IO + :type web_test_tags: 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 :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: @@ -628,7 +605,7 @@ def update_tags( self, resource_group_name: str, web_test_name: str, - web_test_tags: Union[_models.TagsResource, IO], + web_test_tags: Union[_models.TagsResource, IO[bytes]], **kwargs: Any ) -> _models.WebTest: """Updates the tags associated with an Application Insights web test. @@ -639,17 +616,14 @@ def update_tags( :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_name: str :param web_test_tags: Updated tag information to associate with the web test resource. Is - either a TagsResource type or a IO type. Required. - :type web_test_tags: ~azure.mgmt.applicationinsights.v2022_06_15.models.TagsResource 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 + either a TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.v2022_06_15.models.TagsResource or + IO[bytes] :return: WebTest or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -660,19 +634,19 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(web_test_tags, (IO, bytes)): + if isinstance(web_test_tags, (IOBase, bytes)): _content = web_test_tags else: _json = self._serialize.body(web_test_tags, "TagsResource") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, web_test_name=web_test_name, subscription_id=self._config.subscription_id, @@ -680,16 +654,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -698,16 +670,12 @@ def update_tags( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebTest", pipeline_response) + deserialized = self._deserialize("WebTest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -720,12 +688,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param web_test_name: The name of the Application Insights WebTest resource. Required. :type web_test_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 = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,24 +703,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, web_test_name=web_test_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -763,17 +728,12 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: """Get all Application Insights web test definitions for the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -782,10 +742,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -796,15 +756,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.WebTest"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -815,14 +773,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -832,11 +789,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -848,8 +805,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests"} - @distributed_trace def list_by_component( self, component_name: str, resource_group_name: str, **kwargs: Any @@ -861,7 +816,6 @@ def list_by_component( :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 WebTest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2022_06_15.models.WebTest] @@ -870,10 +824,10 @@ def list_by_component( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-06-15")) cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -884,17 +838,15 @@ def list_by_component( def prepare_request(next_link=None): if not next_link: - request = build_list_by_component_request( + _request = build_list_by_component_request( component_name=component_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_component.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 @@ -905,14 +857,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._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 + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebTestListResult", pipeline_response) @@ -922,11 +873,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=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -937,7 +888,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_component.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" - } diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_delete.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_delete.py index 2b6ab8be3a1d..4317b398b350 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_delete.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient """ @@ -29,11 +30,10 @@ def main(): subscription_id="subid", ) - response = client.web_tests.delete( + client.web_tests.delete( resource_group_name="my-resource-group", web_test_name="my-webtest-01-mywebservice", ) - print(response) # x-ms-original-file: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestDelete.json diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_get.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_get.py index 04aa141917cb..c83989f8576d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_get.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list.py index 65f19dbf944d..cb324b01baba 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_component.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_component.py index b003d3a86f30..98c9dcc774f5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_component.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_component.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_resource_group.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_resource_group.py index e1ae99229531..d727a43caab6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_resource_group.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_samples/web_test_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/conftest.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/conftest.py new file mode 100644 index 000000000000..b29928c7983b --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + applicationinsightsmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + applicationinsightsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + applicationinsightsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + applicationinsightsmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=applicationinsightsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=applicationinsightsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=applicationinsightsmanagement_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=applicationinsightsmanagement_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/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations.py new file mode 100644 index 000000000000..b4850a5843f3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.applicationinsights import ApplicationInsightsManagementClient + +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 TestApplicationInsightsManagementWebTestsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApplicationInsightsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_list_by_resource_group(self, resource_group): + response = self.client.web_tests.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-06-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_get(self, resource_group): + response = self.client.web_tests.get( + resource_group_name=resource_group.name, + web_test_name="str", + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_create_or_update(self, resource_group): + response = self.client.web_tests.create_or_update( + resource_group_name=resource_group.name, + web_test_name="str", + web_test_definition={ + "location": "str", + "Configuration": {"WebTest": "str"}, + "Description": "str", + "Enabled": bool, + "Frequency": 300, + "Kind": "str", + "Locations": [{"Id": "str"}], + "Name": "str", + "Request": { + "FollowRedirects": bool, + "Headers": [{"key": "str", "value": "str"}], + "HttpVerb": "str", + "ParseDependentRequests": bool, + "RequestBody": "str", + "RequestUrl": "str", + }, + "RetryEnabled": bool, + "SyntheticMonitorId": "str", + "Timeout": 30, + "ValidationRules": { + "ContentValidation": {"ContentMatch": "str", "IgnoreCase": bool, "PassIfTextFound": bool}, + "ExpectedHttpStatusCode": 0, + "IgnoreHttpStatusCode": bool, + "SSLCertRemainingLifetimeCheck": 0, + "SSLCheck": bool, + }, + "id": "str", + "kind": "str", + "name": "str", + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_update_tags(self, resource_group): + response = self.client.web_tests.update_tags( + resource_group_name=resource_group.name, + web_test_name="str", + web_test_tags={"tags": {"str": "str"}}, + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_delete(self, resource_group): + response = self.client.web_tests.delete( + resource_group_name=resource_group.name, + web_test_name="str", + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_list(self, resource_group): + response = self.client.web_tests.list( + api_version="2022-06-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_tests_list_by_component(self, resource_group): + response = self.client.web_tests.list_by_component( + component_name="str", + resource_group_name=resource_group.name, + api_version="2022-06-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations_async.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations_async.py new file mode 100644 index 000000000000..78818f23b77f --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/generated_tests/test_application_insights_management_web_tests_operations_async.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.applicationinsights.aio import ApplicationInsightsManagementClient + +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 TestApplicationInsightsManagementWebTestsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApplicationInsightsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_tests_list_by_resource_group(self, resource_group): + response = self.client.web_tests.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-06-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_web_tests_get(self, resource_group): + response = await self.client.web_tests.get( + resource_group_name=resource_group.name, + web_test_name="str", + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_tests_create_or_update(self, resource_group): + response = await self.client.web_tests.create_or_update( + resource_group_name=resource_group.name, + web_test_name="str", + web_test_definition={ + "location": "str", + "Configuration": {"WebTest": "str"}, + "Description": "str", + "Enabled": bool, + "Frequency": 300, + "Kind": "str", + "Locations": [{"Id": "str"}], + "Name": "str", + "Request": { + "FollowRedirects": bool, + "Headers": [{"key": "str", "value": "str"}], + "HttpVerb": "str", + "ParseDependentRequests": bool, + "RequestBody": "str", + "RequestUrl": "str", + }, + "RetryEnabled": bool, + "SyntheticMonitorId": "str", + "Timeout": 30, + "ValidationRules": { + "ContentValidation": {"ContentMatch": "str", "IgnoreCase": bool, "PassIfTextFound": bool}, + "ExpectedHttpStatusCode": 0, + "IgnoreHttpStatusCode": bool, + "SSLCertRemainingLifetimeCheck": 0, + "SSLCheck": bool, + }, + "id": "str", + "kind": "str", + "name": "str", + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_tests_update_tags(self, resource_group): + response = await self.client.web_tests.update_tags( + resource_group_name=resource_group.name, + web_test_name="str", + web_test_tags={"tags": {"str": "str"}}, + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_tests_delete(self, resource_group): + response = await self.client.web_tests.delete( + resource_group_name=resource_group.name, + web_test_name="str", + api_version="2022-06-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_tests_list(self, resource_group): + response = self.client.web_tests.list( + api_version="2022-06-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_web_tests_list_by_component(self, resource_group): + response = self.client.web_tests.list_by_component( + component_name="str", + resource_group_name=resource_group.name, + api_version="2022-06-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/setup.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/setup.py index bf7f4f30225d..81394c2f8371 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/setup.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/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 = "Application Insights 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 :: 4 - Beta", + "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=[ - "isodate<1.0.0,>=0.6.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", )