From 080115e142dc9de922dabee31698a74afbedf5f2 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 10 Jan 2025 19:26:37 +0000 Subject: [PATCH] CodeGen from PR 31796 in Azure/azure-rest-api-specs Merge 044a83f9f8934243c8bb489bc681d340c8d9d895 into dc7fc9849b622c2a0b3ce5e10746ceb4057ad759 --- sdk/keyvault/azure-mgmt-keyvault/_meta.json | 6 +- .../keyvault/_key_vault_management_client.py | 2 +- .../azure/mgmt/keyvault/_serialization.py | 447 +++++++++++------- .../aio/_key_vault_management_client.py | 2 +- .../mgmt/keyvault/v2016_10_01/__init__.py | 12 +- .../keyvault/v2016_10_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2016_10_01/_version.py | 2 +- .../mgmt/keyvault/v2016_10_01/aio/__init__.py | 12 +- .../v2016_10_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2016_10_01/aio/operations/__init__.py | 14 +- .../v2016_10_01/aio/operations/_operations.py | 7 +- .../v2016_10_01/aio/operations/_patch.py | 6 +- .../aio/operations/_vaults_operations.py | 65 +-- .../keyvault/v2016_10_01/models/__init__.py | 79 ++-- .../v2016_10_01/models/_models_py3.py | 3 +- .../v2016_10_01/operations/__init__.py | 14 +- .../v2016_10_01/operations/_operations.py | 7 +- .../keyvault/v2016_10_01/operations/_patch.py | 5 +- .../operations/_vaults_operations.py | 62 +-- .../mgmt/keyvault/v2018_02_14/__init__.py | 12 +- .../keyvault/v2018_02_14/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2018_02_14/_version.py | 2 +- .../mgmt/keyvault/v2018_02_14/aio/__init__.py | 12 +- .../v2018_02_14/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2018_02_14/aio/operations/__init__.py | 18 +- .../v2018_02_14/aio/operations/_operations.py | 7 +- .../v2018_02_14/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2018_02_14/models/__init__.py | 107 +++-- .../v2018_02_14/models/_models_py3.py | 5 +- .../v2018_02_14/operations/__init__.py | 18 +- .../v2018_02_14/operations/_operations.py | 7 +- .../keyvault/v2018_02_14/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../operations/_vaults_operations.py | 68 ++- .../mgmt/keyvault/v2019_09_01/__init__.py | 12 +- .../keyvault/v2019_09_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2019_09_01/_version.py | 2 +- .../mgmt/keyvault/v2019_09_01/aio/__init__.py | 12 +- .../v2019_09_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2019_09_01/aio/operations/__init__.py | 20 +- .../aio/operations/_keys_operations.py | 15 +- .../v2019_09_01/aio/operations/_operations.py | 7 +- .../v2019_09_01/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2019_09_01/models/__init__.py | 133 +++--- .../v2019_09_01/models/_models_py3.py | 11 +- .../v2019_09_01/operations/__init__.py | 20 +- .../operations/_keys_operations.py | 15 +- .../v2019_09_01/operations/_operations.py | 7 +- .../keyvault/v2019_09_01/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../operations/_vaults_operations.py | 68 ++- .../keyvault/v2020_04_01_preview/__init__.py | 12 +- .../v2020_04_01_preview/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../keyvault/v2020_04_01_preview/_version.py | 2 +- .../v2020_04_01_preview/aio/__init__.py | 12 +- .../v2020_04_01_preview/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../aio/operations/__init__.py | 24 +- .../aio/operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 57 ++- .../aio/operations/_operations.py | 7 +- .../aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../v2020_04_01_preview/models/__init__.py | 173 +++---- .../v2020_04_01_preview/models/_models_py3.py | 11 +- .../operations/__init__.py | 24 +- .../operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 57 ++- .../operations/_operations.py | 7 +- .../v2020_04_01_preview/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 27 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../keyvault/v2021_04_01_preview/__init__.py | 12 +- .../v2021_04_01_preview/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../keyvault/v2021_04_01_preview/_version.py | 2 +- .../v2021_04_01_preview/aio/__init__.py | 12 +- .../v2021_04_01_preview/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../aio/operations/__init__.py | 24 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 31 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../aio/operations/_operations.py | 7 +- .../aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 30 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_vaults_operations.py | 71 ++- .../v2021_04_01_preview/models/__init__.py | 169 +++---- .../v2021_04_01_preview/models/_models_py3.py | 13 +- .../operations/__init__.py | 24 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_operations.py | 7 +- .../v2021_04_01_preview/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_vaults_operations.py | 68 ++- .../keyvault/v2021_06_01_preview/__init__.py | 12 +- .../v2021_06_01_preview/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../keyvault/v2021_06_01_preview/_version.py | 2 +- .../v2021_06_01_preview/aio/__init__.py | 12 +- .../v2021_06_01_preview/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../aio/operations/__init__.py | 28 +- .../aio/operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 31 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../aio/operations/_operations.py | 7 +- .../aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 30 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../v2021_06_01_preview/models/__init__.py | 217 +++++---- .../v2021_06_01_preview/models/_models_py3.py | 15 +- .../operations/__init__.py | 28 +- .../operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_operations.py | 7 +- .../v2021_06_01_preview/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../mgmt/keyvault/v2021_10_01/__init__.py | 12 +- .../keyvault/v2021_10_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2021_10_01/_version.py | 2 +- .../mgmt/keyvault/v2021_10_01/aio/__init__.py | 12 +- .../v2021_10_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2021_10_01/aio/operations/__init__.py | 28 +- .../aio/operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../v2021_10_01/aio/operations/_operations.py | 7 +- .../v2021_10_01/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2021_10_01/models/__init__.py | 203 ++++---- .../v2021_10_01/models/_models_py3.py | 15 +- .../v2021_10_01/operations/__init__.py | 28 +- .../operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 71 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../v2021_10_01/operations/_operations.py | 7 +- .../keyvault/v2021_10_01/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../mgmt/keyvault/v2022_07_01/__init__.py | 12 +- .../keyvault/v2022_07_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2022_07_01/_version.py | 2 +- .../mgmt/keyvault/v2022_07_01/aio/__init__.py | 12 +- .../v2022_07_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2022_07_01/aio/operations/__init__.py | 28 +- .../aio/operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../v2022_07_01/aio/operations/_operations.py | 7 +- .../v2022_07_01/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2022_07_01/models/__init__.py | 225 ++++----- .../v2022_07_01/models/_models_py3.py | 15 +- .../v2022_07_01/operations/__init__.py | 28 +- .../operations/_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../v2022_07_01/operations/_operations.py | 7 +- .../keyvault/v2022_07_01/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../mgmt/keyvault/v2023_02_01/__init__.py | 12 +- .../keyvault/v2023_02_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2023_02_01/_version.py | 2 +- .../mgmt/keyvault/v2023_02_01/aio/__init__.py | 12 +- .../v2023_02_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2023_02_01/aio/operations/__init__.py | 32 +- .../aio/operations/_keys_operations.py | 15 +- .../_managed_hsm_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_mhsm_regions_operations.py | 7 +- .../v2023_02_01/aio/operations/_operations.py | 7 +- .../v2023_02_01/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2023_02_01/models/__init__.py | 255 +++++----- .../v2023_02_01/models/_models_py3.py | 17 +- .../v2023_02_01/operations/__init__.py | 32 +- .../operations/_keys_operations.py | 15 +- .../_managed_hsm_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_mhsm_regions_operations.py | 7 +- .../v2023_02_01/operations/_operations.py | 7 +- .../keyvault/v2023_02_01/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../mgmt/keyvault/v2023_07_01/__init__.py | 12 +- .../keyvault/v2023_07_01/_configuration.py | 3 +- .../_key_vault_management_client.py | 3 +- .../mgmt/keyvault/v2023_07_01/_version.py | 2 +- .../mgmt/keyvault/v2023_07_01/aio/__init__.py | 12 +- .../v2023_07_01/aio/_configuration.py | 3 +- .../aio/_key_vault_management_client.py | 3 +- .../v2023_07_01/aio/operations/__init__.py | 32 +- .../aio/operations/_keys_operations.py | 15 +- .../_managed_hsm_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_mhsm_regions_operations.py | 7 +- .../v2023_07_01/aio/operations/_operations.py | 7 +- .../v2023_07_01/aio/operations/_patch.py | 6 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../aio/operations/_secrets_operations.py | 25 +- .../aio/operations/_vaults_operations.py | 71 ++- .../keyvault/v2023_07_01/models/__init__.py | 261 +++++----- .../v2023_07_01/models/_models_py3.py | 19 +- .../v2023_07_01/operations/__init__.py | 32 +- .../operations/_keys_operations.py | 15 +- .../_managed_hsm_keys_operations.py | 15 +- .../operations/_managed_hsms_operations.py | 72 +-- ...private_endpoint_connections_operations.py | 29 +- ..._mhsm_private_link_resources_operations.py | 7 +- .../operations/_mhsm_regions_operations.py | 7 +- .../v2023_07_01/operations/_operations.py | 7 +- .../keyvault/v2023_07_01/operations/_patch.py | 5 +- ...private_endpoint_connections_operations.py | 29 +- .../_private_link_resources_operations.py | 7 +- .../operations/_secrets_operations.py | 25 +- .../operations/_vaults_operations.py | 68 ++- .../check_vault_name_availability.py | 2 - .../generated_samples/create_key.py | 2 - .../generated_samples/create_secret.py | 2 - .../generated_samples/create_vault.py | 2 - .../create_vault_with_network_acls.py | 2 - ...anaged_hsm_check_mhsm_name_availability.py | 2 - .../managed_hsm_create_key.py | 2 - .../managed_hsm_create_or_update.py | 2 - ...ged_hsm_put_private_endpoint_connection.py | 2 - .../generated_samples/managed_hsm_update.py | 2 - .../put_private_endpoint_connection.py | 2 - .../update_access_policies_add.py | 5 - .../generated_samples/update_secret.py | 2 - .../generated_samples/update_vault.py | 2 - .../generated_tests/conftest.py | 2 +- ...st_key_vault_management_keys_operations.py | 10 +- ..._vault_management_keys_operations_async.py | 10 +- ..._management_managed_hsm_keys_operations.py | 10 +- ...ement_managed_hsm_keys_operations_async.py | 10 +- ...ault_management_managed_hsms_operations.py | 20 +- ...anagement_managed_hsms_operations_async.py | 20 +- ...private_endpoint_connections_operations.py | 8 +- ...e_endpoint_connections_operations_async.py | 8 +- ..._mhsm_private_link_resources_operations.py | 2 +- ...private_link_resources_operations_async.py | 2 +- ...ault_management_mhsm_regions_operations.py | 2 +- ...anagement_mhsm_regions_operations_async.py | 2 +- .../test_key_vault_management_operations.py | 2 +- ...t_key_vault_management_operations_async.py | 2 +- ...private_endpoint_connections_operations.py | 8 +- ...e_endpoint_connections_operations_async.py | 8 +- ...ement_private_link_resources_operations.py | 2 +- ...private_link_resources_operations_async.py | 2 +- ...key_vault_management_secrets_operations.py | 8 +- ...ult_management_secrets_operations_async.py | 8 +- ..._key_vault_management_vaults_operations.py | 24 +- ...ault_management_vaults_operations_async.py | 24 +- 319 files changed, 3924 insertions(+), 3852 deletions(-) diff --git a/sdk/keyvault/azure-mgmt-keyvault/_meta.json b/sdk/keyvault/azure-mgmt-keyvault/_meta.json index 5626ca9b8bd7..7df126dc9a98 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/_meta.json +++ b/sdk/keyvault/azure-mgmt-keyvault/_meta.json @@ -1,12 +1,12 @@ { - "commit": "2608e811fafd18657b224a0d59e1c3924a534adb", + "commit": "24080288953959c4c13457cf39da10c12bb0f8ab", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.15.0", + "@autorest/python@6.27.4", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/keyvault/resource-manager/readme.md --generate-sample=True --generate-test=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.15.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/keyvault/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/keyvault/resource-manager/readme.md", "package-2019-09": "2021-07-15 01:23:27 -0700 4fe5435a25386ee460ba89817465c7deba818284 Microsoft.KeyVault/stable/2019-09-01/keyvault.json", "package-2018-02": "2020-11-03 15:27:00 -0500 111dab2fbec96b208a78b36bb8dcefd958036476 Microsoft.KeyVault/preview/2018-02-14-preview/keyvault.json", diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py index 96b72dbd700b..b568935ce51d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py @@ -95,7 +95,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(KeyVaultManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_serialization.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_serialization.py index 59f1fcf71bc9..a94487cbf17a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_serialization.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_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: @@ -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: @@ -155,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 @@ -184,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) @@ -206,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): @@ -235,24 +255,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + 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): @@ -300,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: @@ -326,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: @@ -346,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) # type: ignore + 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. @@ -382,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) # type: ignore + 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): @@ -397,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 @@ -410,6 +456,7 @@ 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) # type: ignore @@ -428,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 @@ -450,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: @@ -503,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"} @@ -542,7 +597,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -562,13 +617,16 @@ def __init__(self, classes: Optional[Mapping[str, type]]=None): 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) @@ -594,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"] == "": @@ -635,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 @@ -666,17 +727,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + 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 @@ -705,7 +766,7 @@ 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 SerializationError("Unable to build a model: " + str(err)) from err @@ -714,9 +775,11 @@ def body(self, 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 """ @@ -730,27 +793,26 @@ def url(self, name, data, data_type, **kwargs): 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. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - do_quote = not kwargs.get('skip_quote', False) + 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 @@ -761,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]"]: @@ -782,21 +845,20 @@ 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") @@ -807,7 +869,7 @@ def serialize_data(self, data, data_type, **kwargs): 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 @@ -823,11 +885,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + 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 @@ -843,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 @@ -873,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. @@ -884,15 +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'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -909,12 +970,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): 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 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] @@ -951,9 +1008,8 @@ 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 = {} @@ -977,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 @@ -985,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 @@ -1009,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: @@ -1040,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) @@ -1097,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) @@ -1111,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], @@ -1147,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) @@ -1178,13 +1244,14 @@ def serialize_iso(attr, **kwargs): 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 @@ -1192,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 @@ -1217,7 +1284,9 @@ def rest_key_extractor(attr, attr_desc, data): 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 @@ -1238,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) @@ -1285,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 @@ -1337,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: @@ -1360,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. @@ -1369,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]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1409,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 @@ -1422,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) @@ -1446,13 +1528,13 @@ def _deserialize(self, target_obj, data): 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 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"... @@ -1482,9 +1564,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + 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: @@ -1511,6 +1592,8 @@ 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 @@ -1522,7 +1605,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + 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 @@ -1537,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 ) @@ -1558,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", {}) @@ -1585,24 +1672,35 @@ def _unpack_content(raw_data, content_type=None): 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(): @@ -1611,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 @@ -1633,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) @@ -1653,14 +1756,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + 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: @@ -1677,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): @@ -1687,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. """ @@ -1726,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 @@ -1738,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. """ @@ -1749,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, str): + 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): @@ -1774,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, @@ -1787,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): @@ -1800,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: @@ -1810,9 +1915,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. 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: @@ -1828,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. """ @@ -1840,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. """ @@ -1855,8 +1962,9 @@ 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 @@ -1871,6 +1979,7 @@ 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. """ @@ -1883,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. """ @@ -1893,14 +2003,14 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + 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. """ @@ -1916,6 +2026,7 @@ 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. """ @@ -1930,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. """ @@ -1945,14 +2057,14 @@ def deserialize_rfc(attr): except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + 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. """ @@ -1982,8 +2094,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1991,6 +2102,7 @@ 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 """ @@ -2002,5 +2114,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py index 93cfdd3ab632..9f1f143aefc0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py @@ -95,7 +95,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(KeyVaultManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_configuration.py index 1321a318a4ae..07aaed1b979a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_key_vault_management_client.py index c992d41375db..cce3c6ca0cd1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_key_vault_management_client.py @@ -21,11 +21,10 @@ from .operations import Operations, VaultsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_configuration.py index 731e354e718b..27f8c949be48 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_key_vault_management_client.py index 7c3aa2e658a3..ab19a5f0e773 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/_key_vault_management_client.py @@ -21,11 +21,10 @@ from .operations import Operations, VaultsOperations if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/__init__.py index 34a990d46881..7c6c816c2cda 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/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 ._vaults_operations import VaultsOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # 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__ = [ "VaultsOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_operations.py index a01ecd78ae0c..319b67116970 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_vaults_operations.py index b70b55fb66b3..039560033b6c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -164,7 +165,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,11 +212,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -298,7 +295,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,11 +342,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -357,9 +350,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -371,7 +362,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +413,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -553,7 +544,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -601,11 +592,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -634,7 +621,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -712,7 +699,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,7 +775,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -860,7 +847,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -903,7 +890,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -927,6 +914,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -935,15 +923,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1024,7 +1011,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1136,7 +1123,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/__init__.py index b5ca82e4f2f1..e66a4a07a7b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/__init__.py @@ -5,42 +5,53 @@ # 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 AccessPolicyEntry -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import LogSpecification -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + CheckNameAvailabilityResult, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + LogSpecification, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + Resource, + ResourceListResult, + ServiceSpecification, + Sku, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + CertificatePermissions, + CreateMode, + KeyPermissions, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, +) 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__ = [ @@ -77,5 +88,5 @@ "SkuName", "StoragePermissions", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/_models_py3.py index 1eac911264b8..8147abc97882 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_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. @@ -12,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/__init__.py index 34a990d46881..7c6c816c2cda 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/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 ._vaults_operations import VaultsOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # 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__ = [ "VaultsOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_operations.py index 6ef1fd4eae18..27629e5f8b09 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_patch.py index d6256c7691f8..334f35c7eee1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_vaults_operations.py index f4e5081651d4..3962d539183d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -491,7 +493,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,11 +540,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -625,7 +623,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,11 +670,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -698,7 +692,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -749,7 +743,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -880,7 +874,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -928,11 +922,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -961,7 +951,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1039,7 +1029,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1114,7 +1104,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-10-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1186,7 +1176,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1229,7 +1219,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,6 +1243,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1261,15 +1252,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1349,7 +1339,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1461,7 +1451,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2016_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/__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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_configuration.py index 2ef15d16eb57..183f574cc6fd 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_key_vault_management_client.py index a19e272f1cbc..9dc7d94f0da9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_key_vault_management_client.py @@ -26,11 +26,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_configuration.py index b2cc1057bf38..93831fbaaa6f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_key_vault_management_client.py index ca0ddc6d90d9..f6235743e379 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/_key_vault_management_client.py @@ -26,11 +26,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/__init__.py index cab449d09e5b..b10ccd36b2b4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # 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__ = [ @@ -21,5 +27,5 @@ "PrivateLinkResourcesOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_operations.py index 71dd672b281d..ef63f7594e6f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_endpoint_connections_operations.py index 79670fbb3790..0c05a6ad11ec 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -36,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +79,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,7 +208,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +272,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,6 +297,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -304,22 +306,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_link_resources_operations.py index a8f0271562ad..6bafffe5f8ae 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_vaults_operations.py index 7af173be952b..693584b3f0b0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/__init__.py index 16908785dba6..6d90da5b1de4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/__init__.py @@ -5,56 +5,67 @@ # 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 AccessPolicyEntry -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import IPRule -from ._models_py3 import LogSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + IPRule, + LogSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + ServiceSpecification, + Sku, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + CertificatePermissions, + CreateMode, + KeyPermissions, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, +) 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__ = [ @@ -105,5 +116,5 @@ "SkuName", "StoragePermissions", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/_models_py3.py index d02bdd742ee9..31b0bd7cfa85 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/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. @@ -12,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -1326,7 +1325,7 @@ def __init__( self.network_acls = network_acls -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/__init__.py index cab449d09e5b..b10ccd36b2b4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # 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__ = [ @@ -21,5 +27,5 @@ "PrivateLinkResourcesOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_operations.py index fd2835d74db8..3ea98e4c77db 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_patch.py index 2bd66104efdb..bc4e0c3b01f6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_endpoint_connections_operations.py index cdc1d03f1766..17bc1620db43 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -32,7 +33,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -194,7 +195,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +324,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,7 +388,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -412,6 +413,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -420,22 +422,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_link_resources_operations.py index e01e1fc771f7..a9372ce29ecf 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_vaults_operations.py index 91437b9b286a..f1585e2ecf0d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2018_02_14/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -421,7 +423,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,6 +459,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -465,15 +468,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -680,7 +682,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -727,11 +729,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -753,7 +751,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -804,7 +802,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -935,7 +933,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -983,11 +981,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1016,7 +1010,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1094,7 +1088,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1169,7 +1163,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-14")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1241,7 +1235,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1284,7 +1278,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1308,6 +1302,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1316,15 +1311,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1404,7 +1398,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1516,7 +1510,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2018_02_14.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_configuration.py index 363bc89188eb..28d4b3fef04d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_key_vault_management_client.py index 704c698ed731..4be0b0a0ca8f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_key_vault_management_client.py @@ -27,11 +27,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_configuration.py index 8524844e2996..4a3089ad261e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_key_vault_management_client.py index db5a6d7417c1..c102ec2cd0e1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/_key_vault_management_client.py @@ -27,11 +27,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword +class KeyVaultManagementClient: """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/__init__.py index d2cbc6d10784..a6cdfdf4f9a2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations -from ._keys_operations import KeysOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._keys_operations import KeysOperations # 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 +29,5 @@ "Operations", "KeysOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_keys_operations.py index 5a610ee46932..d94c31b15648 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -155,7 +154,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,7 +224,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,7 +286,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +368,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -437,7 +436,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_operations.py index fbf2685f8ee3..514d191039fe 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_endpoint_connections_operations.py index c408816451a4..4c231d32f642 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -36,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +79,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +210,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,7 +274,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,6 +299,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -306,22 +308,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_link_resources_operations.py index 83025885917e..b2880cd0f44b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_vaults_operations.py index 9a7cdde5c242..7ed06499047c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/__init__.py index d69986848e28..4275c53e4ecb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/__init__.py @@ -5,69 +5,80 @@ # 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 AccessPolicyEntry -from ._models_py3 import Attributes -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import LogSpecification -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Attributes, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + LogSpecification, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + ServiceSpecification, + Sku, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -131,5 +142,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/_models_py3.py index 05f470487da4..d98d70d85a23 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_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. @@ -12,7 +12,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -433,7 +432,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -722,7 +721,7 @@ def __init__( self.blob_duration = blob_duration -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1712,7 +1711,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -1849,7 +1848,7 @@ def __init__( self.network_acls = network_acls -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/__init__.py index d2cbc6d10784..a6cdfdf4f9a2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations -from ._keys_operations import KeysOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._keys_operations import KeysOperations # 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 +29,5 @@ "Operations", "KeysOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_keys_operations.py index 33819f6c39f8..61536b591b2f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -312,7 +311,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,7 +381,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,7 +443,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -526,7 +525,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -594,7 +593,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_operations.py index 2f45c5b92f46..706d823b2760 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_patch.py index 9c719e411990..0534f6f58a01 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_endpoint_connections_operations.py index 935ce01821c8..124a45e0295c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -32,7 +33,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -194,7 +195,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +326,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,7 +390,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -414,6 +415,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -422,22 +424,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_link_resources_operations.py index a466f79ce405..965ad6ee44b6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_vaults_operations.py index a042afe5031b..2623dc0a4885 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2019_09_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,6 +471,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -477,15 +480,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -692,7 +694,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,11 +741,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -765,7 +763,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +814,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -947,7 +945,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,11 +993,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1028,7 +1022,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1100,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1175,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-09-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1247,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1296,7 +1290,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1320,6 +1314,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1328,15 +1323,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1416,7 +1410,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1528,7 +1522,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2019_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_configuration.py index 5121986ee3c6..bfd14eeb26da 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_key_vault_management_client.py index cfba0db201b9..c7d46ea2ac4a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_key_vault_management_client.py @@ -29,11 +29,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_configuration.py index 8da4798046cf..db9995195c23 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_key_vault_management_client.py index e9786903cee8..2b0027fafdf6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/_key_vault_management_client.py @@ -29,11 +29,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/__init__.py index a86b1e14cf52..78141d881e37 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_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 ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations -from ._managed_hsms_operations import ManagedHsmsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # 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__ = [ @@ -27,5 +33,5 @@ "SecretsOperations", "ManagedHsmsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_keys_operations.py index 5045779820d9..70a556cc2178 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -156,7 +155,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +227,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -295,7 +294,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,7 +376,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list_versions( ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_managed_hsms_operations.py index ea6d0233544f..da504a5494a0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -42,7 +43,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +71,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,6 +109,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -116,16 +118,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -262,7 +263,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -300,6 +301,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -308,19 +310,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -455,7 +457,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,6 +483,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -489,19 +492,15 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -576,7 +575,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,7 +647,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -731,7 +730,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_operations.py index 9184299d7d14..faa2f3510275 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_endpoint_connections_operations.py index 680b54a3c35b..f5adfa3f716c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -36,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +79,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,7 +212,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,6 +305,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -312,22 +314,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_link_resources_operations.py index 63c08ce81443..4f9c5b698113 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_secrets_operations.py index c168374c3094..ef22f0b757ae 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -156,7 +155,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,11 +205,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -309,7 +304,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,7 +450,7 @@ def list( ) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_vaults_operations.py index 710c72d9c145..c40ee0eb3466 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,6 +133,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -140,15 +142,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -361,7 +362,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,11 +411,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -422,9 +419,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -436,7 +431,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -489,7 +484,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +620,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,11 +670,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -711,7 +702,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -792,7 +783,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -870,7 +861,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,7 +933,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -987,7 +978,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1013,6 +1004,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1021,15 +1013,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1112,7 +1103,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1226,7 +1217,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/__init__.py index 8f174a876738..68a70220022e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/__init__.py @@ -5,89 +5,100 @@ # 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 AccessPolicyEntry -from ._models_py3 import Attributes -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import LogSpecification -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmSku -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Attributes, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + LogSpecification, + ManagedHsm, + ManagedHsmError, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmSku, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -171,5 +182,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/_models_py3.py index 27e86b5dd8ba..63c52055b1c4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_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. @@ -13,7 +13,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -458,7 +457,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1106,7 +1105,7 @@ def __init__( self.name = name -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -2443,7 +2442,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -2582,7 +2581,7 @@ def __init__( self.network_acls = network_acls -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/__init__.py index a86b1e14cf52..78141d881e37 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_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 ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations -from ._managed_hsms_operations import ManagedHsmsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # 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__ = [ @@ -27,5 +33,5 @@ "SecretsOperations", "ManagedHsmsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_keys_operations.py index 58cd36ac49d8..776c63d81156 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -313,7 +312,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,7 +384,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,7 +450,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,7 +532,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,7 +604,7 @@ def list_versions( ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_managed_hsms_operations.py index 7b11f1b4676e..2347bda61ceb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_managed_hsms_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -249,7 +250,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,6 +288,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -295,16 +297,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -438,7 +439,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,6 +477,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -484,19 +486,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -628,7 +630,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -654,6 +656,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -662,19 +665,15 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -749,7 +748,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -821,7 +820,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -904,7 +903,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_operations.py index ae2e030544fa..9b77bc313def 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_patch.py index b9604571fae0..c6f0479d93d2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_endpoint_connections_operations.py index 469692561b83..4956a93a46ab 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,6 +15,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -32,7 +33,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -194,7 +195,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,7 +328,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,7 +394,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -420,6 +421,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -428,22 +430,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_link_resources_operations.py index b2bcf473a0f3..ea91e9beffa9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_secrets_operations.py index 0d8f33ba27c5..363096f3ef16 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -288,7 +287,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,11 +337,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -441,7 +436,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,7 +581,7 @@ def list( ) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_vaults_operations.py index 1123b44bc032..f36650625450 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2020_04_01_preview/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,6 +473,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -479,15 +482,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -697,7 +699,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,11 +748,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -772,7 +770,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,7 +823,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -961,7 +959,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1011,11 +1009,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1046,7 +1040,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1126,7 +1120,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1204,7 +1198,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1276,7 +1270,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1321,7 +1315,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,6 +1341,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1355,15 +1350,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1445,7 +1439,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1559,7 +1553,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2020_04_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_configuration.py index 008624abb447..469a30ecfeb0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_key_vault_management_client.py index e66f9071093b..9b8f55ec8d0d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_key_vault_management_client.py @@ -29,11 +29,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_configuration.py index 76f3883d5487..6df9edb3bbb5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_key_vault_management_client.py index 98a9eebfb200..5a99c3c093d9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/_key_vault_management_client.py @@ -29,11 +29,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/__init__.py index 1415b7f904e4..4abe6c3f847e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # 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__ = [ @@ -27,5 +33,5 @@ "MHSMPrivateLinkResourcesOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_managed_hsms_operations.py index 5f64c7827057..a744f37e4749 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -45,7 +47,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +75,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,6 +113,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -119,16 +122,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -265,7 +267,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,6 +305,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -311,19 +314,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -458,7 +461,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,6 +487,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -492,22 +496,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -582,7 +583,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -654,7 +655,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -737,7 +738,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -817,7 +818,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs ) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -890,7 +891,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,7 +937,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -962,6 +963,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -970,7 +972,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -978,7 +983,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py index 2c6ad04f6cce..ca0a502211fb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,6 +70,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_resource( self, resource_group_name: str, name: str, **kwargs: Any ) -> AsyncIterable["_models.MHSMPrivateEndpointConnection"]: + # pylint: disable=line-too-long """The List operation gets information about the private endpoint connections associated with the managed HSM Pool. @@ -91,7 +93,7 @@ def list_by_resource( ) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,7 +174,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +309,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +375,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,6 +402,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -408,22 +411,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -434,6 +434,7 @@ async def _delete_initial( async def begin_delete( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.MHSMPrivateEndpointConnection]: + # pylint: disable=line-too-long """Deletes the specified private endpoint connection associated with the managed hsm pool. :param resource_group_name: Name of the resource group that contains the managed HSM pool. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_link_resources_operations.py index 5d994dbd02c7..8313a6bbd429 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_operations.py index 68f7925ed707..03479fa2f972 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_endpoint_connections_operations.py index 1af19f3c4b5e..88223d8b6f68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -215,7 +216,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +282,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,6 +309,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -316,22 +318,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -408,6 +407,7 @@ def get_long_running_output(pipeline_response): def list_by_resource( self, resource_group_name: str, vault_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + # pylint: disable=line-too-long """The List operation gets information about the private endpoint connections associated with the vault. @@ -429,7 +429,7 @@ def list_by_resource( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_link_resources_operations.py index 68e899255350..7ea7dfe60b46 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_vaults_operations.py index edf1cabfc73b..267c9aae399a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,6 +133,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -140,15 +142,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -361,7 +362,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,11 +411,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -422,9 +419,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -436,7 +431,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -489,7 +484,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +620,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,11 +670,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -711,7 +702,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -792,7 +783,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -870,7 +861,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,7 +933,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -987,7 +978,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1013,6 +1004,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1021,15 +1013,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1112,7 +1103,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1226,7 +1217,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/__init__.py index ca7b9e0635de..5dd70c251455 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/__init__.py @@ -5,87 +5,98 @@ # 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 AccessPolicyEntry -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmSku -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + LogSpecification, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMVirtualNetworkRule, + ManagedHsm, + ManagedHsmError, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmSku, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + ServiceSpecification, + Sku, + SystemData, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + CertificatePermissions, + CreateMode, + IdentityType, + KeyPermissions, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -167,5 +178,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/_models_py3.py index 43ab135d4f36..d39ec7b4c930 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_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. @@ -13,7 +13,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -703,7 +702,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -881,7 +880,7 @@ def __init__( self.name = name -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1091,7 +1090,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2517,7 +2516,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -2656,7 +2655,7 @@ def __init__( self.network_acls = network_acls -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/__init__.py index 1415b7f904e4..4abe6c3f847e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_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 ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # 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__ = [ @@ -27,5 +33,5 @@ "MHSMPrivateLinkResourcesOperations", "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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_managed_hsms_operations.py index 0cf1cb18fe3b..027a6c64069d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -331,7 +333,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,6 +371,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -377,16 +380,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -520,7 +522,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,6 +560,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -566,19 +569,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -710,7 +713,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,6 +739,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -744,22 +748,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -834,7 +835,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -906,7 +907,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,7 +990,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,7 +1070,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: ) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1142,7 +1143,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1188,7 +1189,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1214,6 +1215,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1222,7 +1224,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1230,7 +1235,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_endpoint_connections_operations.py index d6db9b6b6955..a3ab9c918101 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -224,7 +225,7 @@ def list_by_resource( ) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,7 +306,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +441,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,7 +507,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,6 +534,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -541,22 +543,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_link_resources_operations.py index e1286da13709..80db9557e19b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_operations.py index 36bc35ff04fb..6edb13e6d974 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_patch.py index c87ec9bc212c..0961c17ca279 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_endpoint_connections_operations.py index f4a1afdfbc1e..3783c828a8d8 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +361,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,7 +427,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -453,6 +454,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -461,22 +463,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -574,7 +573,7 @@ def list_by_resource( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_link_resources_operations.py index dbadbb38eaca..5e473997a6c4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_vaults_operations.py index 69532ee5fdc3..1f62cd0a496b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_04_01_preview/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,6 +473,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -479,15 +482,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -697,7 +699,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,11 +748,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -772,7 +770,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,7 +823,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -961,7 +959,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1011,11 +1009,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1046,7 +1040,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1126,7 +1120,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1204,7 +1198,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1276,7 +1270,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1321,7 +1315,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,6 +1341,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1355,15 +1350,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1445,7 +1439,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1559,7 +1553,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_04_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_configuration.py index ea186512723f..1eb8efe80381 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_key_vault_management_client.py index 63989610714b..9424d7bb1c99 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_configuration.py index 10df2b59a14f..a82f7ad4b83e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_key_vault_management_client.py index 587c5b7270e4..453da6f214cb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_keys_operations.py index be7f039bf6f2..d67f23062eab 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -156,7 +155,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +227,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -295,7 +294,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,7 +376,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list_versions( ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_managed_hsms_operations.py index 35e378469b86..9c285e06fd90 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -45,7 +47,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +75,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,6 +113,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -119,16 +122,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -265,7 +267,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,6 +305,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -311,19 +314,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -458,7 +461,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,6 +487,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -492,22 +496,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -582,7 +583,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -654,7 +655,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -737,7 +738,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -817,7 +818,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs ) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -890,7 +891,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,7 +937,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -962,6 +963,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -970,7 +972,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -978,7 +983,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py index fca8423fb71b..87483fd0c2a2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,6 +70,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_resource( self, resource_group_name: str, name: str, **kwargs: Any ) -> AsyncIterable["_models.MHSMPrivateEndpointConnection"]: + # pylint: disable=line-too-long """The List operation gets information about the private endpoint connections associated with the managed HSM Pool. @@ -91,7 +93,7 @@ def list_by_resource( ) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,7 +174,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +309,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +375,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,6 +402,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -408,22 +411,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -434,6 +434,7 @@ async def _delete_initial( async def begin_delete( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.MHSMPrivateEndpointConnection]: + # pylint: disable=line-too-long """Deletes the specified private endpoint connection associated with the managed hsm pool. :param resource_group_name: Name of the resource group that contains the managed HSM pool. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_link_resources_operations.py index 4fd7c27adf26..f71342fd7ff3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_operations.py index 4adfcd68c39c..94926971615c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py index ebf0660e1551..4c645e0dc6a0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -215,7 +216,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +282,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,6 +309,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -316,22 +318,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -408,6 +407,7 @@ def get_long_running_output(pipeline_response): def list_by_resource( self, resource_group_name: str, vault_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + # pylint: disable=line-too-long """The List operation gets information about the private endpoint connections associated with the vault. @@ -429,7 +429,7 @@ def list_by_resource( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py index 76b60c6aa528..6d770ccf1ad6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_secrets_operations.py index 613e5496793b..5297f228957e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -156,7 +155,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,11 +205,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -309,7 +304,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,7 +450,7 @@ def list( ) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_vaults_operations.py index 9519d34e55f7..7a7ca29a6762 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,6 +133,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -140,15 +142,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -361,7 +362,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,11 +411,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -422,9 +419,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -436,7 +431,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -489,7 +484,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +620,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,11 +670,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -711,7 +702,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -792,7 +783,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -870,7 +861,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,7 +933,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -987,7 +978,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1013,6 +1004,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1021,15 +1013,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1112,7 +1103,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1226,7 +1217,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/__init__.py index f495cfaa2d9e..fda219aaf597 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/__init__.py @@ -5,111 +5,122 @@ # 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 AccessPolicyEntry -from ._models_py3 import Action -from ._models_py3 import Attributes -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import KeyReleasePolicy -from ._models_py3 import KeyRotationPolicyAttributes -from ._models_py3 import LifetimeAction -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmSku -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import RotationPolicy -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Trigger -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import KeyRotationPolicyActionType -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Action, + Attributes, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + KeyReleasePolicy, + KeyRotationPolicyAttributes, + LifetimeAction, + LogSpecification, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMVirtualNetworkRule, + ManagedHsm, + ManagedHsmError, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmSku, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + RotationPolicy, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Trigger, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + KeyRotationPolicyActionType, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -215,5 +226,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/_models_py3.py index 3f0b919e83bd..bf5ee81a7fdb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_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. @@ -13,7 +13,6 @@ from ... import _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -606,7 +605,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1258,7 +1257,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -1436,7 +1435,7 @@ def __init__( self.name = name -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1646,7 +1645,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3353,7 +3352,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -3505,7 +3504,7 @@ def __init__( self.public_network_access = public_network_access -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_keys_operations.py index f6c4ad85128e..847dc8bb4ef0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -313,7 +312,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,7 +384,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,7 +450,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,7 +532,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,7 +604,7 @@ def list_versions( ) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_managed_hsms_operations.py index abcecea18485..93da615db4c7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -331,7 +333,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,6 +371,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -377,16 +380,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -520,7 +522,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,6 +560,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -566,19 +569,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -710,7 +713,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,6 +739,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -744,22 +748,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -834,7 +835,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -906,7 +907,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,7 +990,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,7 +1070,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: ) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1142,7 +1143,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1188,7 +1189,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1214,6 +1215,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1222,7 +1224,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1230,7 +1235,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_endpoint_connections_operations.py index 00024e43b0cf..e03d430b4180 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -224,7 +225,7 @@ def list_by_resource( ) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,7 +306,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +441,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,7 +507,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,6 +534,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -541,22 +543,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_link_resources_operations.py index 54cee2af8845..845e9ce1e6ae 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_operations.py index c65db3a6d7b4..97e64b230a18 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_patch.py index 133abf6d2e10..a3b3695ec50b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py index cf25d184b920..1acfffe8b4a9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +361,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,7 +427,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -453,6 +454,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -461,22 +463,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -574,7 +573,7 @@ def list_by_resource( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_link_resources_operations.py index f7fdb7e0eac5..d515d503300c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_secrets_operations.py index 16ce75faa4d5..41d41807816d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -288,7 +287,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,11 +337,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -441,7 +436,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,7 +581,7 @@ def list( ) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_vaults_operations.py index e636cb6a7169..af985d18482d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_06_01_preview/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,6 +473,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -479,15 +482,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -697,7 +699,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,11 +748,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -772,7 +770,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,7 +823,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -961,7 +959,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1011,11 +1009,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1046,7 +1040,7 @@ def list_by_resource_group( ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1126,7 +1120,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter ) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1204,7 +1198,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: ) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1276,7 +1270,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1321,7 +1315,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,6 +1341,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1355,15 +1350,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1445,7 +1439,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1559,7 +1553,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_06_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_configuration.py index 01a34d3114d6..d49aaf50f6be 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_key_vault_management_client.py index 79f944d9a3c5..379791dbe2aa 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_configuration.py index 6f0e19d157e0..26444b9bbff0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_key_vault_management_client.py index 75eef2ec996d..29bd8ed1e4a2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_keys_operations.py index bd07a8359a00..c0a370ab283b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,7 +230,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -293,7 +292,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +374,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +442,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_managed_hsms_operations.py index 7fbe368a1ed7..548465d16682 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -45,7 +47,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +75,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,6 +111,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -117,16 +120,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -258,7 +260,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,6 +296,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -302,19 +305,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -444,7 +447,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -468,6 +471,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -476,22 +480,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +565,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -632,7 +633,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +714,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +792,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -864,7 +865,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -908,7 +909,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -932,6 +933,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -940,7 +942,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -948,7 +953,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_endpoint_connections_operations.py index 088be29afcf1..2a9a173e92b1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +90,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +171,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +368,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,6 +393,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -400,22 +402,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_link_resources_operations.py index c3df2ee1e4b3..7ee642df4dc9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_operations.py index 69930eec13c7..212a22d4da31 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_endpoint_connections_operations.py index d467a5d4dbdb..78220b304840 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +214,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,6 +303,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -310,22 +312,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -419,7 +418,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_link_resources_operations.py index fcdf64fdc1aa..f633ab6888cd 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_secrets_operations.py index dca59c833418..742d7c73fcfa 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,11 +208,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -311,7 +306,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,7 +445,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_vaults_operations.py index 5ea6b06ed3f2..56f9352fc015 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/__init__.py index 335f8a2a6621..8ab6e3591dec 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/__init__.py @@ -5,104 +5,115 @@ # 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 AccessPolicyEntry -from ._models_py3 import Attributes -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmSku -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Attributes, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + LogSpecification, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMVirtualNetworkRule, + ManagedHsm, + ManagedHsmError, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmSku, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -201,5 +212,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/_models_py3.py index 9fdaac3f821b..71e788c69a1e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_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 @@ -578,7 +577,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1094,7 +1093,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -1271,7 +1270,7 @@ def __init__( self.name = name -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1476,7 +1475,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3089,7 +3088,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -3239,7 +3238,7 @@ def __init__( self.public_network_access = public_network_access -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_keys_operations.py index a00f136aa09b..9ab4d3f2f7bb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -318,7 +317,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,7 +531,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +599,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_managed_hsms_operations.py index a6c98a8b83fa..6b8c00eaa7d9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -331,7 +333,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,6 +369,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -375,16 +378,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -513,7 +515,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -549,6 +551,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -557,19 +560,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -696,7 +699,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,6 +723,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -728,22 +732,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -816,7 +817,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -883,7 +884,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -963,7 +964,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1040,7 +1041,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1113,7 +1114,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1157,7 +1158,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,6 +1182,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1189,7 +1191,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1197,7 +1202,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_endpoint_connections_operations.py index 615cc5a3bd93..c3cc512a6487 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -222,7 +223,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +437,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +501,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,6 +526,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -533,22 +535,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_link_resources_operations.py index 00df9aa91832..7718c3071ef0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_operations.py index ff133038b63d..4feb96aae326 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_patch.py index 2badf5aafe89..e372624ad84a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_endpoint_connections_operations.py index 65330873e921..0870e427628d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +359,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +423,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,6 +448,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -455,22 +457,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +563,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_link_resources_operations.py index c8e217ffdaa8..4d250905a992 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_secrets_operations.py index 1fe7769c14d4..7ddcbb4865b5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -293,7 +292,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,11 +340,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -443,7 +438,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,7 +577,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_vaults_operations.py index 85e44172334e..e69990881e7e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2021_10_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,6 +471,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -477,15 +480,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -692,7 +694,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,11 +741,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -765,7 +763,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +814,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -947,7 +945,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,11 +993,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1028,7 +1022,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1100,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1175,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1247,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1296,7 +1290,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1320,6 +1314,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1328,15 +1323,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1416,7 +1410,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1528,7 +1522,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2021_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_configuration.py index e48638f3dcb1..f1c4b3dd7672 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_key_vault_management_client.py index eb2254db7524..4bb29657f252 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_configuration.py index 8d5da4f2c90f..f464f98dec2a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_key_vault_management_client.py index 7bf15edee181..52ed33fc64c9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/_key_vault_management_client.py @@ -31,11 +31,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_keys_operations.py index 5e430b5afcc5..440c678f2879 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,7 +230,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -293,7 +292,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +374,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +442,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_managed_hsms_operations.py index a23f5a087cf6..738580d30fa2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -46,7 +48,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +76,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,6 +112,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -118,19 +121,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -262,7 +265,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,6 +301,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -306,19 +310,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -448,7 +452,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,6 +476,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -480,22 +485,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -568,7 +570,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -636,7 +638,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -717,7 +719,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,7 +797,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,7 +870,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,7 +914,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,6 +938,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -944,7 +947,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -952,7 +958,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1061,7 +1067,7 @@ async def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py index 742711d02002..c84ebe4c3680 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +90,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +171,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +368,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,6 +393,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -400,21 +402,18 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_link_resources_operations.py index a41899a61155..6180efe1a309 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_operations.py index e6c90bd9da0d..b003ec96d968 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_endpoint_connections_operations.py index 7bc332a7d5fc..61ee03c06cca 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +214,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,6 +303,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -310,22 +312,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -419,7 +418,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_link_resources_operations.py index 5772d49d71a3..f780519aa6f4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_secrets_operations.py index f78d5ab1520b..13aa6c481cd6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,11 +208,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -311,7 +306,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,7 +445,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_vaults_operations.py index 494551048ce5..c1b1d0c753a3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/__init__.py index a84a0c24d4db..39da6a5501a4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/__init__.py @@ -5,115 +5,126 @@ # 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 AccessPolicyEntry -from ._models_py3 import Action -from ._models_py3 import Attributes -from ._models_py3 import CheckMhsmNameAvailabilityParameters -from ._models_py3 import CheckMhsmNameAvailabilityResult -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import KeyReleasePolicy -from ._models_py3 import KeyRotationPolicyAttributes -from ._models_py3 import LifetimeAction -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHSMSecurityDomainProperties -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmSku -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import RotationPolicy -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Trigger -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import ActivationStatus -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import KeyRotationPolicyActionType -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Action, + Attributes, + CheckMhsmNameAvailabilityParameters, + CheckMhsmNameAvailabilityResult, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + KeyReleasePolicy, + KeyRotationPolicyAttributes, + LifetimeAction, + LogSpecification, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMVirtualNetworkRule, + ManagedHSMSecurityDomainProperties, + ManagedHsm, + ManagedHsmError, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmSku, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + Resource, + ResourceListResult, + RotationPolicy, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Trigger, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + ActivationStatus, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + KeyRotationPolicyActionType, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -223,5 +234,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/_models_py3.py index 3a1d0fd50dd1..450306d79ae3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_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 @@ -664,7 +663,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1309,7 +1308,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -1521,7 +1520,7 @@ def __init__( self.name = name -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1726,7 +1725,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3403,7 +3402,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -3553,7 +3552,7 @@ def __init__( self.public_network_access = public_network_access -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/__init__.py index 224be3f73e55..be92f4ca71b3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/__init__.py @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._keys_operations import KeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -31,5 +37,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_keys_operations.py index 9074753c578e..f216f0e80424 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -318,7 +317,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,7 +531,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +599,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_managed_hsms_operations.py index 86438a5dd1f8..3066a4b2f6a2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -362,7 +364,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,6 +400,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -406,19 +409,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -547,7 +550,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,6 +586,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -591,19 +595,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -730,7 +734,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,6 +758,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -762,22 +767,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +852,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -917,7 +919,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,7 +999,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1074,7 +1076,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1147,7 +1149,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1193,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,6 +1217,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1223,7 +1226,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1231,7 +1237,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1340,7 +1346,7 @@ def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_endpoint_connections_operations.py index 8d36793e5eb8..80efa1c35ff8 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -222,7 +223,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +437,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +501,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,6 +526,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -533,21 +535,18 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_link_resources_operations.py index 254741865519..e5f5c80410f4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_operations.py index 02fa637fda73..f11f2e60a203 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_patch.py index 00994f70077d..1afbb447275d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_endpoint_connections_operations.py index 954e368c4943..50a9da5669a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +359,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +423,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,6 +448,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -455,22 +457,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +563,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_link_resources_operations.py index c1e0215f2c8f..ef4d0a93048c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_secrets_operations.py index 29aa2ca5a50c..58875954e6a4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -293,7 +292,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,11 +340,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -443,7 +438,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,7 +577,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_vaults_operations.py index ce0d14042d26..b19d047cd8a4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2022_07_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,6 +471,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -477,15 +480,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -692,7 +694,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,11 +741,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -765,7 +763,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +814,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -947,7 +945,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,11 +993,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1028,7 +1022,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1100,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1175,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-07-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1247,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1296,7 +1290,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1320,6 +1314,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1328,15 +1323,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1416,7 +1410,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1528,7 +1522,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2022_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_configuration.py index 5d5c3612bf26..a4ab4811d622 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_key_vault_management_client.py index a08e40f12be4..3556865920e2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_key_vault_management_client.py @@ -33,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_configuration.py index 626ed6cd7f71..6c84999365c9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_key_vault_management_client.py index 2137a7d64ca6..87521af71836 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/_key_vault_management_client.py @@ -33,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/__init__.py index 5f02a0a74b92..2c20c64a2fa5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/__init__.py @@ -5,21 +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 ._keys_operations import KeysOperations -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._mhsm_regions_operations import MHSMRegionsOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -35,5 +41,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_keys_operations.py index 2d3fd1723356..8b222eb2a3b5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,7 +230,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -293,7 +292,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +374,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +442,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsm_keys_operations.py index 5faea30e084d..860232957bec 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsm_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -162,7 +161,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,7 +233,7 @@ async def get(self, resource_group_name: str, name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,7 +296,7 @@ def list(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncItera api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -380,7 +379,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsms_operations.py index 43ab889e79cd..cb0c685866d7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -46,7 +48,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +76,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,6 +112,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -118,19 +121,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -262,7 +265,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,6 +301,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -306,19 +310,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -448,7 +452,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,6 +476,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -480,22 +485,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -568,7 +570,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -636,7 +638,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -717,7 +719,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,7 +797,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,7 +870,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,7 +914,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,6 +938,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -944,7 +947,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -952,7 +958,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1061,7 +1067,7 @@ async def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_endpoint_connections_operations.py index 4a0fcd73392c..ea77aa75953d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +90,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +171,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +368,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,6 +393,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -400,21 +402,18 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_link_resources_operations.py index 649f70c4ebe1..05cd256e2da5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_regions_operations.py index 6e1c4ee010e7..dd22e8d79480 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_mhsm_regions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +78,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.MHSMRegionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_operations.py index 6b03ecf7d890..5f496caa1225 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_endpoint_connections_operations.py index a511134a04bf..dbbf3b1344df 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +214,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,6 +303,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -310,22 +312,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -419,7 +418,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_link_resources_operations.py index 626a7d4cf237..85a3dcfb0a32 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_secrets_operations.py index 73359761cad9..1a6dac4376df 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,11 +208,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -311,7 +306,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,7 +445,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_vaults_operations.py index a449a47e5a69..533b4237fba9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/__init__.py index eff496572923..aee96ad439fd 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/__init__.py @@ -5,130 +5,141 @@ # 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 AccessPolicyEntry -from ._models_py3 import Action -from ._models_py3 import Attributes -from ._models_py3 import CheckMhsmNameAvailabilityParameters -from ._models_py3 import CheckMhsmNameAvailabilityResult -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import KeyReleasePolicy -from ._models_py3 import KeyRotationPolicyAttributes -from ._models_py3 import LifetimeAction -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMGeoReplicatedRegion -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMRegionsListResult -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHSMSecurityDomainProperties -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmAction -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmKey -from ._models_py3 import ManagedHsmKeyAttributes -from ._models_py3 import ManagedHsmKeyCreateParameters -from ._models_py3 import ManagedHsmKeyListResult -from ._models_py3 import ManagedHsmKeyProperties -from ._models_py3 import ManagedHsmKeyReleasePolicy -from ._models_py3 import ManagedHsmKeyRotationPolicyAttributes -from ._models_py3 import ManagedHsmLifetimeAction -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmRotationPolicy -from ._models_py3 import ManagedHsmSku -from ._models_py3 import ManagedHsmTrigger -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import ProxyResourceWithoutSystemData -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import RotationPolicy -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Trigger -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import ActivationStatus -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import GeoReplicationRegionProvisioningState -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import KeyRotationPolicyActionType -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Action, + Attributes, + CheckMhsmNameAvailabilityParameters, + CheckMhsmNameAvailabilityResult, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + KeyReleasePolicy, + KeyRotationPolicyAttributes, + LifetimeAction, + LogSpecification, + MHSMGeoReplicatedRegion, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMRegionsListResult, + MHSMVirtualNetworkRule, + ManagedHSMSecurityDomainProperties, + ManagedHsm, + ManagedHsmAction, + ManagedHsmError, + ManagedHsmKey, + ManagedHsmKeyAttributes, + ManagedHsmKeyCreateParameters, + ManagedHsmKeyListResult, + ManagedHsmKeyProperties, + ManagedHsmKeyReleasePolicy, + ManagedHsmKeyRotationPolicyAttributes, + ManagedHsmLifetimeAction, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmRotationPolicy, + ManagedHsmSku, + ManagedHsmTrigger, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + ProxyResourceWithoutSystemData, + Resource, + ResourceListResult, + RotationPolicy, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Trigger, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + ActivationStatus, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + GeoReplicationRegionProvisioningState, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + KeyRotationPolicyActionType, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -253,5 +264,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/_models_py3.py index 16f4acba1b83..5e0b179c5da7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_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 @@ -664,7 +663,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1347,7 +1346,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class ManagedHsmKey(ProxyResourceWithoutSystemData): # pylint: disable=too-many-instance-attributes +class ManagedHsmKey(ProxyResourceWithoutSystemData): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1804,7 +1803,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -2091,7 +2090,7 @@ def __init__( self.time_before_expiry = time_before_expiry -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -2336,7 +2335,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4045,7 +4044,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -4195,7 +4194,7 @@ def __init__( self.public_network_access = public_network_access -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/__init__.py index 5f02a0a74b92..2c20c64a2fa5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/__init__.py @@ -5,21 +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 ._keys_operations import KeysOperations -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._mhsm_regions_operations import MHSMRegionsOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -35,5 +41,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_keys_operations.py index 286092974128..ebebe26bb779 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -318,7 +317,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,7 +531,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +599,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsm_keys_operations.py index fe06c26a064c..794862e729ee 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsm_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -339,7 +338,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +410,7 @@ def get(self, resource_group_name: str, name: str, key_name: str, **kwargs: Any) :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,7 +472,7 @@ def list(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterable[" api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,7 +555,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +624,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsms_operations.py index 8e8a56459c1c..307e5e360f23 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -362,7 +364,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,6 +400,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -406,19 +409,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -547,7 +550,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,6 +586,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -591,19 +595,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -730,7 +734,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,6 +758,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -762,22 +767,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +852,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -917,7 +919,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,7 +999,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1074,7 +1076,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1147,7 +1149,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1193,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,6 +1217,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1223,7 +1226,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1231,7 +1237,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1340,7 +1346,7 @@ def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_endpoint_connections_operations.py index 0fabfdc46d5f..9735590214c1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -222,7 +223,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +437,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +501,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,6 +526,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -533,21 +535,18 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_link_resources_operations.py index 16aec130c9e2..8643effc3f05 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_regions_operations.py index 5ad97fc01907..020547eff595 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_mhsm_regions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -113,7 +112,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.MHSMRegionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_operations.py index b27bd571d68d..a9151a716181 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_patch.py index 59bec6bbc7f5..d81ad1a571ba 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_endpoint_connections_operations.py index f948531314d9..24bcb15582d1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +359,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +423,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,6 +448,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -455,22 +457,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +563,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_link_resources_operations.py index 200436074208..38a5ddb7e041 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_secrets_operations.py index d6480ccb30a9..4559b1bfd06d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -293,7 +292,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,11 +340,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -443,7 +438,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,7 +577,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_vaults_operations.py index 85ae57ea45a2..493d18171e7b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_02_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,6 +471,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -477,15 +480,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -692,7 +694,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,11 +741,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -765,7 +763,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +814,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -947,7 +945,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,11 +993,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1028,7 +1022,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1100,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1175,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-02-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1247,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1296,7 +1290,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1320,6 +1314,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1328,15 +1323,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1416,7 +1410,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1528,7 +1522,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/__init__.py index 6bb4b7c63a45..a60631755701 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_configuration.py index da014f6a75a7..9c6ee9f52637 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_key_vault_management_client.py index 4aac36e62ace..5fcf6ee434e7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_key_vault_management_client.py @@ -33,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_version.py index 3b99a1418535..e5754a47ce68 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.3.1" +VERSION = "1.0.0b1" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/__init__.py index 6ba0c5a05353..30acffb8c4a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_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 ._key_vault_management_client import KeyVaultManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._key_vault_management_client import KeyVaultManagementClient # 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__ = [ "KeyVaultManagementClient", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_configuration.py index f2d369cf48d8..fe67de68d837 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for KeyVaultManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_key_vault_management_client.py index 0f7ca3922ec9..4e9aa74972ae 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/_key_vault_management_client.py @@ -33,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KeyVaultManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/__init__.py index 5f02a0a74b92..2c20c64a2fa5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/__init__.py @@ -5,21 +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 ._keys_operations import KeysOperations -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._mhsm_regions_operations import MHSMRegionsOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -35,5 +41,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_keys_operations.py index 2624e2025992..30c7e6690777 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,7 +230,7 @@ async def get(self, resource_group_name: str, vault_name: str, key_name: str, ** :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -293,7 +292,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +374,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +442,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsm_keys_operations.py index 61cce69b15d7..ff85ea7f9000 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsm_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,7 +38,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -162,7 +161,7 @@ async def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,7 +233,7 @@ async def get(self, resource_group_name: str, name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,7 +296,7 @@ def list(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncItera api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -380,7 +379,7 @@ async def get_version( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsms_operations.py index 5ee61b04f44b..970f32712784 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -46,7 +48,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +76,7 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,6 +112,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -118,19 +121,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -262,7 +265,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,6 +301,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -306,19 +310,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -448,7 +452,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,6 +476,7 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -480,22 +485,19 @@ async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -568,7 +570,7 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optio :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -636,7 +638,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -717,7 +719,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,7 +797,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedManagedHs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,7 +870,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,7 +914,7 @@ async def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,6 +938,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -944,7 +947,10 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -952,7 +958,7 @@ async def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1061,7 +1067,7 @@ async def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py index 16c169a8eaa0..3ec761f7af7c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +90,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +171,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +368,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,6 +393,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -400,21 +402,18 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_link_resources_operations.py index bcf59d1bc169..eb3f949e7cc5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +68,7 @@ async def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_regions_operations.py index e165553dbdd1..a081f8b99cce 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_mhsm_regions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +78,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.MHSMRegionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_operations.py index fb823e464576..977affb1f51c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_patch.py index 9b4f32f151b7..a22e2c723f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_patch.py @@ -38,6 +38,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace @@ -57,9 +58,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -124,6 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + __all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py index 1f1a9bb4d5cb..581f94fc6bf0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -40,7 +41,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +83,7 @@ async def get( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +214,7 @@ async def put( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,7 @@ async def put( async def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,6 +303,7 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -310,22 +312,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -419,7 +418,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_link_resources_operations.py index 15aba3e1a8be..9b2c1c89dadd 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +67,7 @@ async def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_secrets_operations.py index f9e5860b05d5..5203523604cb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,7 +37,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +160,7 @@ async def create_or_update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,11 +208,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -311,7 +306,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,11 +354,7 @@ async def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -386,7 +377,7 @@ async def get(self, resource_group_name: str, vault_name: str, secret_name: str, :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,7 +445,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_vaults_operations.py index e79f3577f704..811a331c4c55 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/aio/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,7 +17,6 @@ IO, Literal, Optional, - Type, TypeVar, Union, cast, @@ -32,6 +31,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -62,7 +63,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +95,7 @@ async def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,6 +131,7 @@ async def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -138,15 +140,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,7 +354,7 @@ async def update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,11 +401,7 @@ async def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -412,9 +409,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: """Deletes the specified Azure key vault. :param resource_group_name: The name of the Resource Group to which the vault belongs. @@ -426,7 +421,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +472,7 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -608,7 +603,7 @@ async def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,11 +651,7 @@ async def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -689,7 +680,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +758,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +834,7 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +906,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +949,7 @@ async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _m return deserialized # type: ignore async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,6 +973,7 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -990,15 +982,14 @@ async def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1079,7 +1070,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1182,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/__init__.py index 18597b59b436..6ce51a3e2eec 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/__init__.py @@ -5,133 +5,144 @@ # 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 AccessPolicyEntry -from ._models_py3 import Action -from ._models_py3 import Attributes -from ._models_py3 import CheckMhsmNameAvailabilityParameters -from ._models_py3 import CheckMhsmNameAvailabilityResult -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CloudErrorBody -from ._models_py3 import DeletedManagedHsm -from ._models_py3 import DeletedManagedHsmListResult -from ._models_py3 import DeletedManagedHsmProperties -from ._models_py3 import DeletedVault -from ._models_py3 import DeletedVaultListResult -from ._models_py3 import DeletedVaultProperties -from ._models_py3 import DimensionProperties -from ._models_py3 import Error -from ._models_py3 import IPRule -from ._models_py3 import Key -from ._models_py3 import KeyAttributes -from ._models_py3 import KeyCreateParameters -from ._models_py3 import KeyListResult -from ._models_py3 import KeyProperties -from ._models_py3 import KeyReleasePolicy -from ._models_py3 import KeyRotationPolicyAttributes -from ._models_py3 import LifetimeAction -from ._models_py3 import LogSpecification -from ._models_py3 import MHSMGeoReplicatedRegion -from ._models_py3 import MHSMIPRule -from ._models_py3 import MHSMNetworkRuleSet -from ._models_py3 import MHSMPrivateEndpoint -from ._models_py3 import MHSMPrivateEndpointConnection -from ._models_py3 import MHSMPrivateEndpointConnectionItem -from ._models_py3 import MHSMPrivateEndpointConnectionsListResult -from ._models_py3 import MHSMPrivateLinkResource -from ._models_py3 import MHSMPrivateLinkResourceListResult -from ._models_py3 import MHSMPrivateLinkServiceConnectionState -from ._models_py3 import MHSMRegionsListResult -from ._models_py3 import MHSMVirtualNetworkRule -from ._models_py3 import ManagedHSMSecurityDomainProperties -from ._models_py3 import ManagedHsm -from ._models_py3 import ManagedHsmAction -from ._models_py3 import ManagedHsmError -from ._models_py3 import ManagedHsmKey -from ._models_py3 import ManagedHsmKeyAttributes -from ._models_py3 import ManagedHsmKeyCreateParameters -from ._models_py3 import ManagedHsmKeyListResult -from ._models_py3 import ManagedHsmKeyProperties -from ._models_py3 import ManagedHsmKeyReleasePolicy -from ._models_py3 import ManagedHsmKeyRotationPolicyAttributes -from ._models_py3 import ManagedHsmLifetimeAction -from ._models_py3 import ManagedHsmListResult -from ._models_py3 import ManagedHsmProperties -from ._models_py3 import ManagedHsmResource -from ._models_py3 import ManagedHsmRotationPolicy -from ._models_py3 import ManagedHsmSku -from ._models_py3 import ManagedHsmTrigger -from ._models_py3 import ManagedServiceIdentity -from ._models_py3 import MetricSpecification -from ._models_py3 import NetworkRuleSet -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Permissions -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionItem -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import ProxyResourceWithoutSystemData -from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import RotationPolicy -from ._models_py3 import Secret -from ._models_py3 import SecretAttributes -from ._models_py3 import SecretCreateOrUpdateParameters -from ._models_py3 import SecretListResult -from ._models_py3 import SecretPatchParameters -from ._models_py3 import SecretPatchProperties -from ._models_py3 import SecretProperties -from ._models_py3 import ServiceSpecification -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import Trigger -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import Vault -from ._models_py3 import VaultAccessPolicyParameters -from ._models_py3 import VaultAccessPolicyProperties -from ._models_py3 import VaultCheckNameAvailabilityParameters -from ._models_py3 import VaultCreateOrUpdateParameters -from ._models_py3 import VaultListResult -from ._models_py3 import VaultPatchParameters -from ._models_py3 import VaultPatchProperties -from ._models_py3 import VaultProperties -from ._models_py3 import VirtualNetworkRule +from typing import TYPE_CHECKING -from ._key_vault_management_client_enums import AccessPolicyUpdateKind -from ._key_vault_management_client_enums import ActionsRequired -from ._key_vault_management_client_enums import ActivationStatus -from ._key_vault_management_client_enums import CertificatePermissions -from ._key_vault_management_client_enums import CreateMode -from ._key_vault_management_client_enums import DeletionRecoveryLevel -from ._key_vault_management_client_enums import GeoReplicationRegionProvisioningState -from ._key_vault_management_client_enums import IdentityType -from ._key_vault_management_client_enums import JsonWebKeyCurveName -from ._key_vault_management_client_enums import JsonWebKeyOperation -from ._key_vault_management_client_enums import JsonWebKeyType -from ._key_vault_management_client_enums import KeyPermissions -from ._key_vault_management_client_enums import KeyRotationPolicyActionType -from ._key_vault_management_client_enums import ManagedHsmSkuFamily -from ._key_vault_management_client_enums import ManagedHsmSkuName -from ._key_vault_management_client_enums import ManagedServiceIdentityType -from ._key_vault_management_client_enums import NetworkRuleAction -from ._key_vault_management_client_enums import NetworkRuleBypassOptions -from ._key_vault_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._key_vault_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._key_vault_management_client_enums import ProvisioningState -from ._key_vault_management_client_enums import PublicNetworkAccess -from ._key_vault_management_client_enums import Reason -from ._key_vault_management_client_enums import SecretPermissions -from ._key_vault_management_client_enums import SkuFamily -from ._key_vault_management_client_enums import SkuName -from ._key_vault_management_client_enums import StoragePermissions -from ._key_vault_management_client_enums import VaultProvisioningState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessPolicyEntry, + Action, + Attributes, + CheckMhsmNameAvailabilityParameters, + CheckMhsmNameAvailabilityResult, + CheckNameAvailabilityResult, + CloudErrorBody, + DeletedManagedHsm, + DeletedManagedHsmListResult, + DeletedManagedHsmProperties, + DeletedVault, + DeletedVaultListResult, + DeletedVaultProperties, + DimensionProperties, + Error, + IPRule, + Key, + KeyAttributes, + KeyCreateParameters, + KeyListResult, + KeyProperties, + KeyReleasePolicy, + KeyRotationPolicyAttributes, + LifetimeAction, + LogSpecification, + MHSMGeoReplicatedRegion, + MHSMIPRule, + MHSMNetworkRuleSet, + MHSMPrivateEndpoint, + MHSMPrivateEndpointConnection, + MHSMPrivateEndpointConnectionItem, + MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateLinkResource, + MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkServiceConnectionState, + MHSMRegionsListResult, + MHSMVirtualNetworkRule, + ManagedHSMSecurityDomainProperties, + ManagedHsm, + ManagedHsmAction, + ManagedHsmError, + ManagedHsmKey, + ManagedHsmKeyAttributes, + ManagedHsmKeyCreateParameters, + ManagedHsmKeyListResult, + ManagedHsmKeyProperties, + ManagedHsmKeyReleasePolicy, + ManagedHsmKeyRotationPolicyAttributes, + ManagedHsmLifetimeAction, + ManagedHsmListResult, + ManagedHsmProperties, + ManagedHsmResource, + ManagedHsmRotationPolicy, + ManagedHsmSku, + ManagedHsmTrigger, + ManagedServiceIdentity, + MetricSpecification, + NetworkRuleSet, + Operation, + OperationDisplay, + OperationListResult, + Permissions, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionItem, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + ProxyResourceWithoutSystemData, + Resource, + ResourceListResult, + RotationPolicy, + Secret, + SecretAttributes, + SecretCreateOrUpdateParameters, + SecretListResult, + SecretPatchParameters, + SecretPatchProperties, + SecretProperties, + ServiceSpecification, + Sku, + SystemData, + Trigger, + UserAssignedIdentity, + Vault, + VaultAccessPolicyParameters, + VaultAccessPolicyProperties, + VaultCheckNameAvailabilityParameters, + VaultCreateOrUpdateParameters, + VaultListResult, + VaultPatchParameters, + VaultPatchProperties, + VaultProperties, + VirtualNetworkRule, +) + +from ._key_vault_management_client_enums import ( # type: ignore + AccessPolicyUpdateKind, + ActionsRequired, + ActivationStatus, + CertificatePermissions, + CreateMode, + DeletionRecoveryLevel, + GeoReplicationRegionProvisioningState, + IdentityType, + JsonWebKeyCurveName, + JsonWebKeyOperation, + JsonWebKeyType, + KeyPermissions, + KeyRotationPolicyActionType, + ManagedHsmSkuFamily, + ManagedHsmSkuName, + ManagedServiceIdentityType, + NetworkRuleAction, + NetworkRuleBypassOptions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + Reason, + SecretPermissions, + SkuFamily, + SkuName, + StoragePermissions, + VaultProvisioningState, +) 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__ = [ @@ -259,5 +270,5 @@ "StoragePermissions", "VaultProvisioningState", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/_models_py3.py index faea8e40fdc7..0b2028c3f78d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/models/_models_py3.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_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 @@ -662,7 +661,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class Key(Resource): # pylint: disable=too-many-instance-attributes +class Key(Resource): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1356,7 +1355,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class ManagedHsmKey(ProxyResourceWithoutSystemData): # pylint: disable=too-many-instance-attributes +class ManagedHsmKey(ProxyResourceWithoutSystemData): """The key resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1813,7 +1812,7 @@ def __init__( self.next_link = next_link -class ManagedHsmProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ManagedHsmProperties(_serialization.Model): """Properties of the managed HSM Pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -2164,7 +2163,7 @@ def __init__( self.user_assigned_identities = user_assigned_identities -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -2409,7 +2408,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class MHSMPrivateEndpointConnection(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateEndpointConnection(ManagedHsmResource): """Private endpoint connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2604,7 +2603,7 @@ def __init__( self.next_link = next_link -class MHSMPrivateLinkResource(ManagedHsmResource): # pylint: disable=too-many-instance-attributes +class MHSMPrivateLinkResource(ManagedHsmResource): """A private link resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4158,7 +4157,7 @@ def __init__( self.properties = properties -class VaultPatchProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultPatchProperties(_serialization.Model): """Properties of the vault. :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating @@ -4308,7 +4307,7 @@ def __init__( self.public_network_access = public_network_access -class VaultProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VaultProperties(_serialization.Model): """Properties of the vault. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/__init__.py index 5f02a0a74b92..2c20c64a2fa5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/__init__.py @@ -5,21 +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 ._keys_operations import KeysOperations -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations -from ._vaults_operations import VaultsOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._managed_hsms_operations import ManagedHsmsOperations -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations -from ._mhsm_regions_operations import MHSMRegionsOperations -from ._operations import Operations -from ._secrets_operations import SecretsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._keys_operations import KeysOperations # type: ignore +from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore +from ._vaults_operations import VaultsOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore +from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore +from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._secrets_operations import SecretsOperations # 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__ = [ @@ -35,5 +41,5 @@ "Operations", "SecretsOperations", ] -__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/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_keys_operations.py index 8bb70ef3a986..3655f687ee4a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -318,7 +317,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,7 @@ def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +449,7 @@ def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,7 +531,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +599,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsm_keys_operations.py index a1dbe935cb26..f42e43565f54 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsm_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -339,7 +338,7 @@ def create_if_not_exist( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +410,7 @@ def get(self, resource_group_name: str, name: str, key_name: str, **kwargs: Any) :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,7 +472,7 @@ def list(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterable[" api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,7 +555,7 @@ def get_version( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsmKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +624,7 @@ def list_versions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmKeyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsms_operations.py index e68cce8862df..24764e9678b9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_managed_hsms_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -362,7 +364,7 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,6 +400,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -406,19 +409,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -547,7 +550,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,6 +586,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -591,19 +595,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -730,7 +734,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,6 +758,7 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -762,22 +767,19 @@ def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +852,7 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_m :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.ManagedHsm or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -917,7 +919,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,7 +999,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.ManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1074,7 +1076,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedManagedHsm"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.DeletedManagedHsmListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1147,7 +1149,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.DeletedManagedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1191,7 +1193,7 @@ def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.Delete return deserialized # type: ignore def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,6 +1217,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1223,7 +1226,10 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response = pipeline_response.http_response if response.status_code not in [202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1231,7 +1237,7 @@ def _purge_deleted_initial(self, name: str, location: str, **kwargs: Any) -> Ite response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1340,7 +1346,7 @@ def check_mhsm_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.CheckMhsmNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_endpoint_connections_operations.py index 1a9d3215ed28..08a8ed3c862c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -222,7 +223,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.MHSMPrivateEndpointConnectionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +304,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +437,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +501,7 @@ def put( def _delete_initial( self, resource_group_name: str, name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,6 +526,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -533,21 +535,18 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_link_resources_operations.py index 9d1a1af1668f..b3c51448ee8d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +102,7 @@ def list_by_mhsm_resource( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.MHSMPrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_regions_operations.py index fdd53047bf43..4022d9207a45 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_mhsm_regions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -113,7 +112,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.MHSMRegionsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_operations.py index 6b8ae4259517..f43757c909f2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -31,7 +30,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_patch.py index 944d9d4d8c8f..889bbdef75ec 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_patch.py @@ -37,6 +37,7 @@ else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + class VaultsOperations(_VaultsOperations): @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Resource"]: @@ -54,9 +55,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") ) - api_version: Literal["2015-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", "2015-11-01") - ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_endpoint_connections_operations.py index 56c8937d8b4a..ce6bf5d849c6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +16,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +35,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,7 +228,7 @@ def get( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +359,7 @@ def put( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +423,7 @@ def put( def _delete_initial( self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,6 +448,7 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -455,22 +457,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 204: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +563,7 @@ def list_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_link_resources_operations.py index a17c97c2ccd6..17d29b758d8d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,7 +28,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +101,7 @@ def list_by_vault( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_secrets_operations.py index 2bf4784fb4ec..5e12db4585b6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -32,7 +31,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -293,7 +292,7 @@ def create_or_update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,11 +340,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -443,7 +438,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,11 +486,7 @@ def 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("Secret", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response.http_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -518,7 +509,7 @@ def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwa :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,7 +577,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_vaults_operations.py index 3b0f81eb790b..2fef0326774a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/v2023_07_01/operations/_vaults_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,6 +17,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -34,7 +36,7 @@ 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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -433,7 +435,7 @@ def _create_or_update_initial( parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,6 +471,7 @@ def _create_or_update_initial( ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -477,15 +480,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 201: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -692,7 +694,7 @@ def update( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,11 +741,7 @@ def 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("Vault", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("Vault", pipeline_response.http_response) + deserialized = self._deserialize("Vault", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -765,7 +763,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +814,7 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.Vault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -947,7 +945,7 @@ def update_access_policy( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.VaultAccessPolicyParameters :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,11 +993,7 @@ def update_access_policy( 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("VaultAccessPolicyParameters", pipeline_response.http_response) - - if response.status_code == 201: - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) + deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1028,7 +1022,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1100,7 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.VaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1175,7 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedVault"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) cls: ClsType[_models.DeletedVaultListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1247,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.DeletedVault :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1296,7 +1290,7 @@ def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models. return deserialized # type: ignore def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1320,6 +1314,7 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) ) _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1328,15 +1323,14 @@ def _purge_deleted_initial(self, vault_name: str, location: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = response.stream_download(self._client._pipeline) - - if response.status_code == 202: - deserialized = response.stream_download(self._client._pipeline) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1416,7 +1410,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Re ) cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1528,7 +1522,7 @@ def check_name_availability( :rtype: ~azure.mgmt.keyvault.v2023_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py index 73e3fe9046a4..ac93ce63f7dc 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py index a5f708baa948..3d2becb92aba 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py index c35cd2777c29..e950b4ac3095 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py index 878a935af216..715c514cdd1f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py index 3d08446a7015..2fceefb02b1d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py index ffa8dc0de2e2..fe9013923545 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py index 93b804b7d63a..67e673753135 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py index 3eca084fcf3c..272c29431aa1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py index 2bd33ca45449..fb523379c873 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py index 5cd878666142..ed546294a530 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py index f0b4b81cfbdc..e4a71e8a9ffb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py index a93563149aad..009fd7762c4e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py index 7ea4eec33d89..8d2426c3759d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py index ed5c070aa322..ea07bebdaf48 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.keyvault import KeyVaultManagementClient diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py index 2f33a97f09c7..924599a32089 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py @@ -18,7 +18,7 @@ load_dotenv() -# aovid record sensitive identity information in recordings +# For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): keyvaultmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py index 83bbe9b58423..055ca75a6f8c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_create_if_not_exist(self, resource_group): + def test_keys_create_if_not_exist(self, resource_group): response = self.client.keys.create_if_not_exist( resource_group_name=resource_group.name, vault_name="str", @@ -66,7 +66,7 @@ def test_create_if_not_exist(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_keys_get(self, resource_group): response = self.client.keys.get( resource_group_name=resource_group.name, vault_name="str", @@ -79,7 +79,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_keys_list(self, resource_group): response = self.client.keys.list( resource_group_name=resource_group.name, vault_name="str", @@ -91,7 +91,7 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_version(self, resource_group): + def test_keys_get_version(self, resource_group): response = self.client.keys.get_version( resource_group_name=resource_group.name, vault_name="str", @@ -105,7 +105,7 @@ def test_get_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_versions(self, resource_group): + def test_keys_list_versions(self, resource_group): response = self.client.keys.list_versions( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py index 816fea325878..40025ca930b4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_create_if_not_exist(self, resource_group): + async def test_keys_create_if_not_exist(self, resource_group): response = await self.client.keys.create_if_not_exist( resource_group_name=resource_group.name, vault_name="str", @@ -67,7 +67,7 @@ async def test_create_if_not_exist(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_keys_get(self, resource_group): response = await self.client.keys.get( resource_group_name=resource_group.name, vault_name="str", @@ -80,7 +80,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_keys_list(self, resource_group): response = self.client.keys.list( resource_group_name=resource_group.name, vault_name="str", @@ -92,7 +92,7 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_version(self, resource_group): + async def test_keys_get_version(self, resource_group): response = await self.client.keys.get_version( resource_group_name=resource_group.name, vault_name="str", @@ -106,7 +106,7 @@ async def test_get_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_versions(self, resource_group): + async def test_keys_list_versions(self, resource_group): response = self.client.keys.list_versions( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py index 458942c37200..95f52c077659 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_create_if_not_exist(self, resource_group): + def test_managed_hsm_keys_create_if_not_exist(self, resource_group): response = self.client.managed_hsm_keys.create_if_not_exist( resource_group_name=resource_group.name, name="str", @@ -66,7 +66,7 @@ def test_create_if_not_exist(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_managed_hsm_keys_get(self, resource_group): response = self.client.managed_hsm_keys.get( resource_group_name=resource_group.name, name="str", @@ -79,7 +79,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_managed_hsm_keys_list(self, resource_group): response = self.client.managed_hsm_keys.list( resource_group_name=resource_group.name, name="str", @@ -91,7 +91,7 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_version(self, resource_group): + def test_managed_hsm_keys_get_version(self, resource_group): response = self.client.managed_hsm_keys.get_version( resource_group_name=resource_group.name, name="str", @@ -105,7 +105,7 @@ def test_get_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_versions(self, resource_group): + def test_managed_hsm_keys_list_versions(self, resource_group): response = self.client.managed_hsm_keys.list_versions( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py index b09c8b48ddbc..8bfb011401b2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_create_if_not_exist(self, resource_group): + async def test_managed_hsm_keys_create_if_not_exist(self, resource_group): response = await self.client.managed_hsm_keys.create_if_not_exist( resource_group_name=resource_group.name, name="str", @@ -67,7 +67,7 @@ async def test_create_if_not_exist(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_managed_hsm_keys_get(self, resource_group): response = await self.client.managed_hsm_keys.get( resource_group_name=resource_group.name, name="str", @@ -80,7 +80,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_managed_hsm_keys_list(self, resource_group): response = self.client.managed_hsm_keys.list( resource_group_name=resource_group.name, name="str", @@ -92,7 +92,7 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_version(self, resource_group): + async def test_managed_hsm_keys_get_version(self, resource_group): response = await self.client.managed_hsm_keys.get_version( resource_group_name=resource_group.name, name="str", @@ -106,7 +106,7 @@ async def test_get_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_versions(self, resource_group): + async def test_managed_hsm_keys_list_versions(self, resource_group): response = self.client.managed_hsm_keys.list_versions( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py index 8a3d11234efb..0b06cc798db7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_managed_hsms_begin_create_or_update(self, resource_group): response = self.client.managed_hsms.begin_create_or_update( resource_group_name=resource_group.name, name="str", @@ -88,7 +88,7 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_managed_hsms_begin_update(self, resource_group): response = self.client.managed_hsms.begin_update( resource_group_name=resource_group.name, name="str", @@ -156,7 +156,7 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_managed_hsms_begin_delete(self, resource_group): response = self.client.managed_hsms.begin_delete( resource_group_name=resource_group.name, name="str", @@ -168,7 +168,7 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_managed_hsms_get(self, resource_group): response = self.client.managed_hsms.get( resource_group_name=resource_group.name, name="str", @@ -180,7 +180,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_managed_hsms_list_by_resource_group(self, resource_group): response = self.client.managed_hsms.list_by_resource_group( resource_group_name=resource_group.name, api_version="2023-07-01", @@ -191,7 +191,7 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_subscription(self, resource_group): + def test_managed_hsms_list_by_subscription(self, resource_group): response = self.client.managed_hsms.list_by_subscription( api_version="2023-07-01", ) @@ -201,7 +201,7 @@ def test_list_by_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_deleted(self, resource_group): + def test_managed_hsms_list_deleted(self, resource_group): response = self.client.managed_hsms.list_deleted( api_version="2023-07-01", ) @@ -211,7 +211,7 @@ def test_list_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_deleted(self, resource_group): + def test_managed_hsms_get_deleted(self, resource_group): response = self.client.managed_hsms.get_deleted( name="str", location="str", @@ -223,7 +223,7 @@ def test_get_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_purge_deleted(self, resource_group): + def test_managed_hsms_begin_purge_deleted(self, resource_group): response = self.client.managed_hsms.begin_purge_deleted( name="str", location="str", @@ -235,7 +235,7 @@ def test_begin_purge_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_check_mhsm_name_availability(self, resource_group): + def test_managed_hsms_check_mhsm_name_availability(self, resource_group): response = self.client.managed_hsms.check_mhsm_name_availability( mhsm_name={"name": "str"}, api_version="2023-07-01", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py index 63231a0daa1d..5a78daa244a4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_managed_hsms_begin_create_or_update(self, resource_group): response = await ( await self.client.managed_hsms.begin_create_or_update( resource_group_name=resource_group.name, @@ -91,7 +91,7 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_managed_hsms_begin_update(self, resource_group): response = await ( await self.client.managed_hsms.begin_update( resource_group_name=resource_group.name, @@ -161,7 +161,7 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_managed_hsms_begin_delete(self, resource_group): response = await ( await self.client.managed_hsms.begin_delete( resource_group_name=resource_group.name, @@ -175,7 +175,7 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_managed_hsms_get(self, resource_group): response = await self.client.managed_hsms.get( resource_group_name=resource_group.name, name="str", @@ -187,7 +187,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_managed_hsms_list_by_resource_group(self, resource_group): response = self.client.managed_hsms.list_by_resource_group( resource_group_name=resource_group.name, api_version="2023-07-01", @@ -198,7 +198,7 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_subscription(self, resource_group): + async def test_managed_hsms_list_by_subscription(self, resource_group): response = self.client.managed_hsms.list_by_subscription( api_version="2023-07-01", ) @@ -208,7 +208,7 @@ async def test_list_by_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_deleted(self, resource_group): + async def test_managed_hsms_list_deleted(self, resource_group): response = self.client.managed_hsms.list_deleted( api_version="2023-07-01", ) @@ -218,7 +218,7 @@ async def test_list_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_deleted(self, resource_group): + async def test_managed_hsms_get_deleted(self, resource_group): response = await self.client.managed_hsms.get_deleted( name="str", location="str", @@ -230,7 +230,7 @@ async def test_get_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_purge_deleted(self, resource_group): + async def test_managed_hsms_begin_purge_deleted(self, resource_group): response = await ( await self.client.managed_hsms.begin_purge_deleted( name="str", @@ -244,7 +244,7 @@ async def test_begin_purge_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_check_mhsm_name_availability(self, resource_group): + async def test_managed_hsms_check_mhsm_name_availability(self, resource_group): response = await self.client.managed_hsms.check_mhsm_name_availability( mhsm_name={"name": "str"}, api_version="2023-07-01", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py index 2be6db7e3003..dfae37a08896 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource(self, resource_group): + def test_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): response = self.client.mhsm_private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, name="str", @@ -32,7 +32,7 @@ def test_list_by_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_mhsm_private_endpoint_connections_get(self, resource_group): response = self.client.mhsm_private_endpoint_connections.get( resource_group_name=resource_group.name, name="str", @@ -45,7 +45,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_put(self, resource_group): + def test_mhsm_private_endpoint_connections_put(self, resource_group): response = self.client.mhsm_private_endpoint_connections.put( resource_group_name=resource_group.name, name="str", @@ -84,7 +84,7 @@ def test_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_mhsm_private_endpoint_connections_begin_delete(self, resource_group): response = self.client.mhsm_private_endpoint_connections.begin_delete( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py index 61fd22575a5d..5fb6b25dea2f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource(self, resource_group): + async def test_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): response = self.client.mhsm_private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, name="str", @@ -33,7 +33,7 @@ async def test_list_by_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_mhsm_private_endpoint_connections_get(self, resource_group): response = await self.client.mhsm_private_endpoint_connections.get( resource_group_name=resource_group.name, name="str", @@ -46,7 +46,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_put(self, resource_group): + async def test_mhsm_private_endpoint_connections_put(self, resource_group): response = await self.client.mhsm_private_endpoint_connections.put( resource_group_name=resource_group.name, name="str", @@ -85,7 +85,7 @@ async def test_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_mhsm_private_endpoint_connections_begin_delete(self, resource_group): response = await ( await self.client.mhsm_private_endpoint_connections.begin_delete( resource_group_name=resource_group.name, diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py index a34a8e97ba8e..e0913d73037f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_mhsm_resource(self, resource_group): + def test_mhsm_private_link_resources_list_by_mhsm_resource(self, resource_group): response = self.client.mhsm_private_link_resources.list_by_mhsm_resource( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py index 423129d78eb2..8ee6a5f6c2fe 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_mhsm_resource(self, resource_group): + async def test_mhsm_private_link_resources_list_by_mhsm_resource(self, resource_group): response = await self.client.mhsm_private_link_resources.list_by_mhsm_resource( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py index b84d378a2eb0..ec9477ebd45b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource(self, resource_group): + def test_mhsm_regions_list_by_resource(self, resource_group): response = self.client.mhsm_regions.list_by_resource( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py index e0c286563e23..f284fdb05584 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource(self, resource_group): + async def test_mhsm_regions_list_by_resource(self, resource_group): response = self.client.mhsm_regions.list_by_resource( resource_group_name=resource_group.name, name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py index 6b904c83df29..4aec125c3c4f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_operations_list(self, resource_group): response = self.client.operations.list( api_version="2023-07-01", ) diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py index cc8d37178d66..a2ff1216ec75 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_operations_list(self, resource_group): response = self.client.operations.list( api_version="2023-07-01", ) diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py index f97783b3757e..ebdaebe25995 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_private_endpoint_connections_get(self, resource_group): response = self.client.private_endpoint_connections.get( resource_group_name=resource_group.name, vault_name="str", @@ -33,7 +33,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_put(self, resource_group): + def test_private_endpoint_connections_put(self, resource_group): response = self.client.private_endpoint_connections.put( resource_group_name=resource_group.name, vault_name="str", @@ -57,7 +57,7 @@ def test_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_private_endpoint_connections_begin_delete(self, resource_group): response = self.client.private_endpoint_connections.begin_delete( resource_group_name=resource_group.name, vault_name="str", @@ -70,7 +70,7 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource(self, resource_group): + def test_private_endpoint_connections_list_by_resource(self, resource_group): response = self.client.private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py index a7e8fd14fc17..0286f704b911 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_private_endpoint_connections_get(self, resource_group): response = await self.client.private_endpoint_connections.get( resource_group_name=resource_group.name, vault_name="str", @@ -34,7 +34,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_put(self, resource_group): + async def test_private_endpoint_connections_put(self, resource_group): response = await self.client.private_endpoint_connections.put( resource_group_name=resource_group.name, vault_name="str", @@ -58,7 +58,7 @@ async def test_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_private_endpoint_connections_begin_delete(self, resource_group): response = await ( await self.client.private_endpoint_connections.begin_delete( resource_group_name=resource_group.name, @@ -73,7 +73,7 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource(self, resource_group): + async def test_private_endpoint_connections_list_by_resource(self, resource_group): response = self.client.private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py index 0c8d9fe10db6..be9e57fe305f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_vault(self, resource_group): + def test_private_link_resources_list_by_vault(self, resource_group): response = self.client.private_link_resources.list_by_vault( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py index ef50a781beda..061c5da12f05 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_vault(self, resource_group): + async def test_private_link_resources_list_by_vault(self, resource_group): response = await self.client.private_link_resources.list_by_vault( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py index d080bb956b8a..87bd4675f92d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_create_or_update(self, resource_group): + def test_secrets_create_or_update(self, resource_group): response = self.client.secrets.create_or_update( resource_group_name=resource_group.name, vault_name="str", @@ -49,7 +49,7 @@ def test_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update(self, resource_group): + def test_secrets_update(self, resource_group): response = self.client.secrets.update( resource_group_name=resource_group.name, vault_name="str", @@ -76,7 +76,7 @@ def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_secrets_get(self, resource_group): response = self.client.secrets.get( resource_group_name=resource_group.name, vault_name="str", @@ -89,7 +89,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_secrets_list(self, resource_group): response = self.client.secrets.list( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py index ad48b8930a22..3bb3c5a430a1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_create_or_update(self, resource_group): + async def test_secrets_create_or_update(self, resource_group): response = await self.client.secrets.create_or_update( resource_group_name=resource_group.name, vault_name="str", @@ -50,7 +50,7 @@ async def test_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update(self, resource_group): + async def test_secrets_update(self, resource_group): response = await self.client.secrets.update( resource_group_name=resource_group.name, vault_name="str", @@ -77,7 +77,7 @@ async def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_secrets_get(self, resource_group): response = await self.client.secrets.get( resource_group_name=resource_group.name, vault_name="str", @@ -90,7 +90,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_secrets_list(self, resource_group): response = self.client.secrets.list( resource_group_name=resource_group.name, vault_name="str", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py index eb8d7f66ca33..d4e7abb4da39 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_vaults_begin_create_or_update(self, resource_group): response = self.client.vaults.begin_create_or_update( resource_group_name=resource_group.name, vault_name="str", @@ -84,7 +84,7 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update(self, resource_group): + def test_vaults_update(self, resource_group): response = self.client.vaults.update( resource_group_name=resource_group.name, vault_name="str", @@ -131,7 +131,7 @@ def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delete(self, resource_group): + def test_vaults_delete(self, resource_group): response = self.client.vaults.delete( resource_group_name=resource_group.name, vault_name="str", @@ -143,7 +143,7 @@ def test_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_vaults_get(self, resource_group): response = self.client.vaults.get( resource_group_name=resource_group.name, vault_name="str", @@ -155,7 +155,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update_access_policy(self, resource_group): + def test_vaults_update_access_policy(self, resource_group): response = self.client.vaults.update_access_policy( resource_group_name=resource_group.name, vault_name="str", @@ -189,7 +189,7 @@ def test_update_access_policy(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_vaults_list_by_resource_group(self, resource_group): response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, api_version="2023-07-01", @@ -200,7 +200,7 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_subscription(self, resource_group): + def test_vaults_list_by_subscription(self, resource_group): response = self.client.vaults.list_by_subscription( api_version="2023-07-01", ) @@ -210,7 +210,7 @@ def test_list_by_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_deleted(self, resource_group): + def test_vaults_list_deleted(self, resource_group): response = self.client.vaults.list_deleted( api_version="2023-07-01", ) @@ -220,7 +220,7 @@ def test_list_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_deleted(self, resource_group): + def test_vaults_get_deleted(self, resource_group): response = self.client.vaults.get_deleted( vault_name="str", location="str", @@ -232,7 +232,7 @@ def test_get_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_purge_deleted(self, resource_group): + def test_vaults_begin_purge_deleted(self, resource_group): response = self.client.vaults.begin_purge_deleted( vault_name="str", location="str", @@ -244,7 +244,7 @@ def test_begin_purge_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_vaults_list(self, resource_group): response = self.client.vaults.list( filter="resourceType eq 'Microsoft.KeyVault/vaults'", api_version="2015-11-01", @@ -255,7 +255,7 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_check_name_availability(self, resource_group): + def test_vaults_check_name_availability(self, resource_group): response = self.client.vaults.check_name_availability( vault_name={"name": "str", "type": "Microsoft.KeyVault/vaults"}, api_version="2023-07-01", diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py index 6ff927fa974b..be6f3fd14057 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_vaults_begin_create_or_update(self, resource_group): response = await ( await self.client.vaults.begin_create_or_update( resource_group_name=resource_group.name, @@ -87,7 +87,7 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update(self, resource_group): + async def test_vaults_update(self, resource_group): response = await self.client.vaults.update( resource_group_name=resource_group.name, vault_name="str", @@ -134,7 +134,7 @@ async def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delete(self, resource_group): + async def test_vaults_delete(self, resource_group): response = await self.client.vaults.delete( resource_group_name=resource_group.name, vault_name="str", @@ -146,7 +146,7 @@ async def test_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_vaults_get(self, resource_group): response = await self.client.vaults.get( resource_group_name=resource_group.name, vault_name="str", @@ -158,7 +158,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update_access_policy(self, resource_group): + async def test_vaults_update_access_policy(self, resource_group): response = await self.client.vaults.update_access_policy( resource_group_name=resource_group.name, vault_name="str", @@ -192,7 +192,7 @@ async def test_update_access_policy(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_vaults_list_by_resource_group(self, resource_group): response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, api_version="2023-07-01", @@ -203,7 +203,7 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_subscription(self, resource_group): + async def test_vaults_list_by_subscription(self, resource_group): response = self.client.vaults.list_by_subscription( api_version="2023-07-01", ) @@ -213,7 +213,7 @@ async def test_list_by_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_deleted(self, resource_group): + async def test_vaults_list_deleted(self, resource_group): response = self.client.vaults.list_deleted( api_version="2023-07-01", ) @@ -223,7 +223,7 @@ async def test_list_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_deleted(self, resource_group): + async def test_vaults_get_deleted(self, resource_group): response = await self.client.vaults.get_deleted( vault_name="str", location="str", @@ -235,7 +235,7 @@ async def test_get_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_purge_deleted(self, resource_group): + async def test_vaults_begin_purge_deleted(self, resource_group): response = await ( await self.client.vaults.begin_purge_deleted( vault_name="str", @@ -249,7 +249,7 @@ async def test_begin_purge_deleted(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_vaults_list(self, resource_group): response = self.client.vaults.list( filter="resourceType eq 'Microsoft.KeyVault/vaults'", api_version="2015-11-01", @@ -260,7 +260,7 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_check_name_availability(self, resource_group): + async def test_vaults_check_name_availability(self, resource_group): response = await self.client.vaults.check_name_availability( vault_name={"name": "str", "type": "Microsoft.KeyVault/vaults"}, api_version="2023-07-01",