diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/README.md b/sdk/appconfiguration/azure-mgmt-appconfiguration/README.md index 0ff31ab2d85c..ee37c278a415 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/README.md +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure App Configuration Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-appconfiguration%2FREADME.png) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/_meta.json b/sdk/appconfiguration/azure-mgmt-appconfiguration/_meta.json index 52401bab879f..9139ecb1f3c4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/_meta.json +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/_meta.json @@ -1,11 +1,15 @@ { - "commit": "396209531039d3e211cb1ec0982606dbbdf64ac2", + "commit": "70b92eea3c667e36dfcdabdd6ae0daeacb8dddf6", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.3", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/appconfiguration/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.3 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/appconfiguration/resource-manager/readme.md" + "autorest_command": "autorest specification/appconfiguration/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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/appconfiguration/resource-manager/readme.md", + "package-2024-05-01": "2024-09-09 14:41:31 -0400 2b700e5e84d4a95880d373e6a4bce5d16882e4b5 Microsoft.AppConfiguration/stable/2024-05-01/appconfiguration.json", + "package-2023-03-01": "2023-05-03 21:13:49 -0700 32e5ec18ee2125c2638de8d48d63053fa5e4af93 Microsoft.AppConfiguration/stable/2023-03-01/appconfiguration.json", + "package-2022-05-01": "2023-02-02 21:00:54 -0500 2c4244e5bcb8939167b79f633cdc17a1f0eae9be Microsoft.AppConfiguration/stable/2022-05-01/appconfiguration.json", + "package-2022-03-01-preview": "2022-07-19 19:54:15 -0700 0e1a9820941badc06e99bda9d1efa59de777efbf Microsoft.AppConfiguration/preview/2022-03-01-preview/appconfiguration.json" } \ No newline at end of file diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/__init__.py index 858738cf88a1..9b210796291b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/__init__.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/__init__.py @@ -7,12 +7,10 @@ # -------------------------------------------------------------------------- from ._app_configuration_management_client import AppConfigurationManagementClient - -__all__ = ["AppConfigurationManagementClient"] +__all__ = ['AppConfigurationManagementClient'] try: from ._patch import patch_sdk # type: ignore - patch_sdk() except ImportError: pass diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_app_configuration_management_client.py index 5c24bbd33423..88d5256173ea 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_app_configuration_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,7 +25,6 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential - class _SDKClient(object): def __init__(self, *args, **kwargs): """This is a fake class to support current implemetation of MultiApiClientMixin." @@ -30,7 +32,6 @@ def __init__(self, *args, **kwargs): """ pass - class AppConfigurationManagementClient(MultiApiClientMixin, _SDKClient): """AppConfigurationManagementClient. @@ -55,29 +56,50 @@ class AppConfigurationManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = "2023-03-01" + DEFAULT_API_VERSION = '2024-05-01' _PROFILE_TAG = "azure.mgmt.appconfiguration.AppConfigurationManagementClient" - LATEST_PROFILE = ProfileDefinition( - { - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - } - }, - _PROFILE_TAG + " latest", + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" ) def __init__( self, credential: "TokenCredential", subscription_id: str, - api_version: Optional[str] = None, + api_version: Optional[str]=None, base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, + profile: KnownProfiles=KnownProfiles.default, **kwargs: Any ): + if api_version: + kwargs.setdefault('api_version', api_version) self._config = AppConfigurationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AppConfigurationManagementClient, self).__init__(api_version=api_version, profile=profile) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + super(AppConfigurationManagementClient, self).__init__( + api_version=api_version, + profile=profile + ) @classmethod def _models_dict(cls, api_version): @@ -87,21 +109,22 @@ def _models_dict(cls, api_version): def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: - * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` - * 2022-05-01: :mod:`v2022_05_01.models` - * 2023-03-01: :mod:`v2023_03_01.models` + * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` + * 2022-05-01: :mod:`v2022_05_01.models` + * 2023-03-01: :mod:`v2023_03_01.models` + * 2024-05-01: :mod:`v2024_05_01.models` """ - if api_version == "2022-03-01-preview": + if api_version == '2022-03-01-preview': from .v2022_03_01_preview import models - return models - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01 import models - return models - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01 import models - + return models + elif api_version == '2024-05-01': + from .v2024_05_01 import models return models raise ValueError("API version {} is not available".format(api_version)) @@ -109,159 +132,155 @@ def models(cls, api_version=DEFAULT_API_VERSION): def configuration_stores(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`ConfigurationStoresOperations` - * 2022-05-01: :class:`ConfigurationStoresOperations` - * 2023-03-01: :class:`ConfigurationStoresOperations` + * 2022-03-01-preview: :class:`ConfigurationStoresOperations` + * 2022-05-01: :class:`ConfigurationStoresOperations` + * 2023-03-01: :class:`ConfigurationStoresOperations` + * 2024-05-01: :class:`ConfigurationStoresOperations` """ - api_version = self._get_api_version("configuration_stores") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('configuration_stores') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import ConfigurationStoresOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01.operations import ConfigurationStoresOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import ConfigurationStoresOperations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import ConfigurationStoresOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'configuration_stores'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def key_values(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`KeyValuesOperations` - * 2022-05-01: :class:`KeyValuesOperations` - * 2023-03-01: :class:`KeyValuesOperations` + * 2022-03-01-preview: :class:`KeyValuesOperations` + * 2022-05-01: :class:`KeyValuesOperations` + * 2023-03-01: :class:`KeyValuesOperations` + * 2024-05-01: :class:`KeyValuesOperations` """ - api_version = self._get_api_version("key_values") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('key_values') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import KeyValuesOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01.operations import KeyValuesOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import KeyValuesOperations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import KeyValuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'key_values'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`Operations` - * 2022-05-01: :class:`Operations` - * 2023-03-01: :class:`Operations` + * 2022-03-01-preview: :class:`Operations` + * 2022-05-01: :class:`Operations` + * 2023-03-01: :class:`Operations` + * 2024-05-01: :class:`Operations` """ - api_version = self._get_api_version("operations") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('operations') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import Operations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01.operations import Operations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import Operations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_endpoint_connections(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` - * 2023-03-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-03-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-03-01: :class:`PrivateEndpointConnectionsOperations` + * 2024-05-01: :class:`PrivateEndpointConnectionsOperations` """ - api_version = self._get_api_version("private_endpoint_connections") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('private_endpoint_connections') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass else: - raise ValueError( - "API version {} does not have operation group 'private_endpoint_connections'".format(api_version) - ) + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_link_resources(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`PrivateLinkResourcesOperations` - * 2022-05-01: :class:`PrivateLinkResourcesOperations` - * 2023-03-01: :class:`PrivateLinkResourcesOperations` + * 2022-03-01-preview: :class:`PrivateLinkResourcesOperations` + * 2022-05-01: :class:`PrivateLinkResourcesOperations` + * 2023-03-01: :class:`PrivateLinkResourcesOperations` + * 2024-05-01: :class:`PrivateLinkResourcesOperations` """ - api_version = self._get_api_version("private_link_resources") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('private_link_resources') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from .v2022_05_01.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import PrivateLinkResourcesOperations as OperationClass else: - raise ValueError( - "API version {} does not have operation group 'private_link_resources'".format(api_version) - ) + raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def replicas(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`ReplicasOperations` - * 2023-03-01: :class:`ReplicasOperations` + * 2022-03-01-preview: :class:`ReplicasOperations` + * 2023-03-01: :class:`ReplicasOperations` + * 2024-05-01: :class:`ReplicasOperations` """ - api_version = self._get_api_version("replicas") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('replicas') + if api_version == '2022-03-01-preview': from .v2022_03_01_preview.operations import ReplicasOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from .v2023_03_01.operations import ReplicasOperations as OperationClass + elif api_version == '2024-05-01': + from .v2024_05_01.operations import ReplicasOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'replicas'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def snapshots(self): + """Instance depends on the API version: + + * 2024-05-01: :class:`SnapshotsOperations` + """ + api_version = self._get_api_version('snapshots') + if api_version == '2024-05-01': + from .v2024_05_01.operations import SnapshotsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'snapshots'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) def close(self): self._client.close() - def __enter__(self): self._client.__enter__() return self - def __exit__(self, *exc_details): self._client.__exit__(*exc_details) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_configuration.py index 4408a9bd06cf..e5d665773601 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -20,8 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential - -class AppConfigurationManagementClientConfiguration(Configuration): +class AppConfigurationManagementClientConfiguration: """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,30 +31,36 @@ class AppConfigurationManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any): + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ): if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "azure-mgmt-appconfiguration/{}".format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-appconfiguration/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure(self, **kwargs: Any): - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") + def _configure( + self, + **kwargs: Any + ): + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_serialization.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_serialization.py index f17c068e833e..59f1fcf71bc9 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_serialization.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,12 +346,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[ + [str, Dict[str, Any], Any], Any + ] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -390,7 +387,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +412,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +442,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +542,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +558,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -629,7 +626,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -649,7 +646,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -662,12 +659,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -709,7 +707,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -729,6 +727,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -741,7 +740,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -749,10 +750,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get('skip_quote', False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -803,7 +802,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -823,7 +822,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -891,6 +890,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +904,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +960,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -983,7 +995,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1160,10 +1172,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1199,7 +1211,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1220,7 +1231,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1271,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1295,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1361,7 +1371,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1381,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1434,12 +1444,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1471,7 +1481,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1505,14 +1515,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1568,7 +1578,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1642,7 +1652,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1690,7 +1700,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1747,7 +1757,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1798,7 +1808,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1852,10 +1861,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1883,7 +1892,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1900,7 +1909,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1935,7 +1944,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1972,7 +1981,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1988,9 +1997,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/__init__.py index f8cd7276168f..c247eefbacdd 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/__init__.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/__init__.py @@ -7,5 +7,4 @@ # -------------------------------------------------------------------------- from ._app_configuration_management_client import AppConfigurationManagementClient - -__all__ = ["AppConfigurationManagementClient"] +__all__ = ['AppConfigurationManagementClient'] diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_app_configuration_management_client.py index ae76cade6bfc..5c24860cef52 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_app_configuration_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,7 +25,6 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - class _SDKClient(object): def __init__(self, *args, **kwargs): """This is a fake class to support current implemetation of MultiApiClientMixin." @@ -30,7 +32,6 @@ def __init__(self, *args, **kwargs): """ pass - class AppConfigurationManagementClient(MultiApiClientMixin, _SDKClient): """AppConfigurationManagementClient. @@ -55,15 +56,13 @@ class AppConfigurationManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = "2023-03-01" + DEFAULT_API_VERSION = '2024-05-01' _PROFILE_TAG = "azure.mgmt.appconfiguration.AppConfigurationManagementClient" - LATEST_PROFILE = ProfileDefinition( - { - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - } - }, - _PROFILE_TAG + " latest", + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" ) def __init__( @@ -75,9 +74,32 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: + if api_version: + kwargs.setdefault('api_version', api_version) self._config = AppConfigurationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AppConfigurationManagementClient, self).__init__(api_version=api_version, profile=profile) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + super(AppConfigurationManagementClient, self).__init__( + api_version=api_version, + profile=profile + ) @classmethod def _models_dict(cls, api_version): @@ -87,21 +109,22 @@ def _models_dict(cls, api_version): def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: - * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` - * 2022-05-01: :mod:`v2022_05_01.models` - * 2023-03-01: :mod:`v2023_03_01.models` + * 2022-03-01-preview: :mod:`v2022_03_01_preview.models` + * 2022-05-01: :mod:`v2022_05_01.models` + * 2023-03-01: :mod:`v2023_03_01.models` + * 2024-05-01: :mod:`v2024_05_01.models` """ - if api_version == "2022-03-01-preview": + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview import models - return models - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01 import models - return models - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01 import models - + return models + elif api_version == '2024-05-01': + from ..v2024_05_01 import models return models raise ValueError("API version {} is not available".format(api_version)) @@ -109,159 +132,155 @@ def models(cls, api_version=DEFAULT_API_VERSION): def configuration_stores(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`ConfigurationStoresOperations` - * 2022-05-01: :class:`ConfigurationStoresOperations` - * 2023-03-01: :class:`ConfigurationStoresOperations` + * 2022-03-01-preview: :class:`ConfigurationStoresOperations` + * 2022-05-01: :class:`ConfigurationStoresOperations` + * 2023-03-01: :class:`ConfigurationStoresOperations` + * 2024-05-01: :class:`ConfigurationStoresOperations` """ - api_version = self._get_api_version("configuration_stores") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('configuration_stores') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import ConfigurationStoresOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import ConfigurationStoresOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import ConfigurationStoresOperations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import ConfigurationStoresOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'configuration_stores'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def key_values(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`KeyValuesOperations` - * 2022-05-01: :class:`KeyValuesOperations` - * 2023-03-01: :class:`KeyValuesOperations` + * 2022-03-01-preview: :class:`KeyValuesOperations` + * 2022-05-01: :class:`KeyValuesOperations` + * 2023-03-01: :class:`KeyValuesOperations` + * 2024-05-01: :class:`KeyValuesOperations` """ - api_version = self._get_api_version("key_values") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('key_values') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import KeyValuesOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import KeyValuesOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import KeyValuesOperations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import KeyValuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'key_values'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`Operations` - * 2022-05-01: :class:`Operations` - * 2023-03-01: :class:`Operations` + * 2022-03-01-preview: :class:`Operations` + * 2022-05-01: :class:`Operations` + * 2023-03-01: :class:`Operations` + * 2024-05-01: :class:`Operations` """ - api_version = self._get_api_version("operations") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('operations') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import Operations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import Operations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import Operations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_endpoint_connections(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` - * 2023-03-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-03-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-03-01: :class:`PrivateEndpointConnectionsOperations` + * 2024-05-01: :class:`PrivateEndpointConnectionsOperations` """ - api_version = self._get_api_version("private_endpoint_connections") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('private_endpoint_connections') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: - raise ValueError( - "API version {} does not have operation group 'private_endpoint_connections'".format(api_version) - ) + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_link_resources(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`PrivateLinkResourcesOperations` - * 2022-05-01: :class:`PrivateLinkResourcesOperations` - * 2023-03-01: :class:`PrivateLinkResourcesOperations` + * 2022-03-01-preview: :class:`PrivateLinkResourcesOperations` + * 2022-05-01: :class:`PrivateLinkResourcesOperations` + * 2023-03-01: :class:`PrivateLinkResourcesOperations` + * 2024-05-01: :class:`PrivateLinkResourcesOperations` """ - api_version = self._get_api_version("private_link_resources") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('private_link_resources') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == "2022-05-01": + elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import PrivateLinkResourcesOperations as OperationClass else: - raise ValueError( - "API version {} does not have operation group 'private_link_resources'".format(api_version) - ) + raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def replicas(self): """Instance depends on the API version: - * 2022-03-01-preview: :class:`ReplicasOperations` - * 2023-03-01: :class:`ReplicasOperations` + * 2022-03-01-preview: :class:`ReplicasOperations` + * 2023-03-01: :class:`ReplicasOperations` + * 2024-05-01: :class:`ReplicasOperations` """ - api_version = self._get_api_version("replicas") - if api_version == "2022-03-01-preview": + api_version = self._get_api_version('replicas') + if api_version == '2022-03-01-preview': from ..v2022_03_01_preview.aio.operations import ReplicasOperations as OperationClass - elif api_version == "2023-03-01": + elif api_version == '2023-03-01': from ..v2023_03_01.aio.operations import ReplicasOperations as OperationClass + elif api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import ReplicasOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'replicas'".format(api_version)) self._config.api_version = api_version - return OperationClass( - self._client, - self._config, - Serializer(self._models_dict(api_version)), - Deserializer(self._models_dict(api_version)), - ) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def snapshots(self): + """Instance depends on the API version: + + * 2024-05-01: :class:`SnapshotsOperations` + """ + api_version = self._get_api_version('snapshots') + if api_version == '2024-05-01': + from ..v2024_05_01.aio.operations import SnapshotsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'snapshots'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() - async def __aenter__(self): await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): await self._client.__aexit__(*exc_details) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_configuration.py index 4908cc856a4f..3de847e3d248 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/aio/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -20,8 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - -class AppConfigurationManagementClientConfiguration(Configuration): +class AppConfigurationManagementClientConfiguration: """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,30 +31,36 @@ class AppConfigurationManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "azure-mgmt-appconfiguration/{}".format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-appconfiguration/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/models.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/models.py index 9c19a9e0294e..6f1fbc4f50f3 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/models.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2023_03_01.models import * +from .v2024_05_01.models import * diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_app_configuration_management_client.py index 3781cabeec0b..ca90cfd9b81e 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -72,26 +75,50 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.replicas = ReplicasOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -111,12 +138,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AppConfigurationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_configuration.py index d16a062141c3..19276dfd6acd 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview") + api_version: str = kwargs.pop("api_version", "2022-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_metadata.json b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_metadata.json index b5214a5c0893..430e7c8c0ca5 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_metadata.json +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "configuration_stores": "ConfigurationStoresOperations", diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_vendor.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_version.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_version.py index cac9f5d10f8b..e5754a47ce68 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_version.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_app_configuration_management_client.py index 0c62a97f3007..fa623c2fb5b5 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -72,26 +75,52 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" + ) + self.replicas = ReplicasOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-03-01-preview" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -111,12 +140,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AppConfigurationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_configuration.py index 2474c7d8abd6..a0de53e4a3b5 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview") + api_version: str = kwargs.pop("api_version", "2022-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_configuration_stores_operations.py index c1982191b596..1cd37fb119c6 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._configuration_stores_operations import ( build_create_request, build_delete_request, @@ -45,10 +46,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,6 +72,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ConfigurationStore"]: @@ -81,7 +83,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore] @@ -90,12 +91,12 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,16 +107,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -126,14 +125,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -143,11 +141,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,8 +158,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -176,7 +172,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore] @@ -185,12 +180,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -201,17 +196,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -222,14 +215,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -239,11 +231,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,10 +248,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace_async async def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -269,12 +257,11 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,26 +272,24 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -314,25 +299,21 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,21 +324,21 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -365,40 +346,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_create( self, @@ -423,14 +399,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -443,7 +411,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -457,18 +425,10 @@ async def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -481,7 +441,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -492,20 +452,9 @@ async def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore or IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -515,8 +464,8 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) @@ -535,12 +484,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -550,22 +500,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,41 +524,44 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -623,14 +574,6 @@ async def begin_delete( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -638,15 +581,15 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -655,11 +598,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -668,26 +612,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -698,21 +638,21 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -720,40 +660,35 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_update( self, @@ -778,14 +713,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -798,7 +725,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -812,18 +739,10 @@ async def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -836,7 +755,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -847,21 +766,10 @@ async def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStoreUpdateParameters or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -871,8 +779,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) @@ -891,12 +799,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -906,17 +815,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -934,7 +841,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey] @@ -943,12 +849,12 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -959,18 +865,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -981,14 +885,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -998,11 +901,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,10 +918,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload async def regenerate_key( self, @@ -1042,7 +941,6 @@ async def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1053,7 +951,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1066,11 +964,10 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1081,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1092,18 +989,14 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1114,8 +1007,8 @@ async def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) @@ -1123,12 +1016,12 @@ async def regenerate_key( content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1136,16 +1029,14 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1155,22 +1046,17 @@ async def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1180,12 +1066,12 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1196,15 +1082,13 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1215,14 +1099,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1232,11 +1115,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1249,10 +1132,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace_async async def get_deleted( self, location: str, config_store_name: str, **kwargs: Any @@ -1263,12 +1142,11 @@ async def get_deleted( :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1279,26 +1157,24 @@ async def get_deleted( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1308,21 +1184,17 @@ async def get_deleted( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - async def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements + async def _purge_deleted_initial( self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1333,41 +1205,44 @@ async def _purge_deleted_initial( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1377,14 +1252,6 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1392,15 +1259,15 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_deleted_initial( # type: ignore + raw_result = await self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1409,11 +1276,12 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1422,14 +1290,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_key_values_operations.py index 085b2b9749f2..eca14e97d8fa 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._key_values_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -81,7 +83,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either KeyValue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue] @@ -90,12 +91,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.KeyValueListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,18 +107,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,14 +127,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("KeyValueListResult", pipeline_response) @@ -145,11 +143,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,10 +160,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any @@ -180,12 +174,11 @@ async def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,27 +189,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,16 +217,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -263,7 +250,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +261,7 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +277,10 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +292,7 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: """Creates a key-value. @@ -321,18 +306,14 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. + or a IO[bytes] type. Default value is None. :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,8 +324,8 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) @@ -352,7 +333,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -360,7 +341,7 @@ async def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -369,16 +350,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,21 +367,17 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -413,42 +388,45 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -464,14 +442,6 @@ async def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -479,15 +449,15 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -497,11 +467,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -510,14 +481,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_operations.py index 65309c9afced..d33b3346e445 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,25 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import ( build_check_name_availability_request, build_list_request, build_regional_check_name_availability_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def check_name_availability( @@ -79,7 +79,6 @@ async def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -87,17 +86,16 @@ async def check_name_availability( @overload async def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -105,23 +103,23 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or + IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,8 +130,8 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) @@ -141,27 +139,25 @@ async def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,16 +167,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: @@ -191,7 +183,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.OperationDefinition] @@ -200,12 +191,12 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,15 +207,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -235,14 +224,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -252,11 +240,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -269,8 +257,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload async def regional_check_name_availability( self, @@ -291,7 +277,6 @@ async def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -301,7 +286,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -312,11 +297,10 @@ async def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -326,7 +310,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -334,18 +318,16 @@ async def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or + IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -356,8 +338,8 @@ async def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) @@ -365,28 +347,26 @@ async def regional_check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -396,13 +376,9 @@ async def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_endpoint_connections_operations.py index 8b4f3a613864..7b2fdcd0a916 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -76,7 +78,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -86,12 +87,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,17 +103,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -123,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -140,11 +138,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -174,12 +168,11 @@ async def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,27 +183,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,26 +211,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,21 +237,21 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -273,40 +260,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -334,14 +316,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -355,7 +329,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -371,18 +345,10 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -396,7 +362,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -410,20 +376,9 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -433,8 +388,8 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -454,12 +409,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -469,22 +425,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,42 +449,45 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -545,14 +502,6 @@ async def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -560,15 +509,15 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -578,11 +527,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -591,14 +541,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_link_resources_operations.py index 8964f3240d9e..1d6611b44cbd 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,24 +20,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import ( build_get_request, build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -72,7 +71,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateLinkResource] @@ -81,12 +79,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +95,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +114,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -135,11 +130,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,10 +147,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -169,12 +160,11 @@ async def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,27 +175,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,13 +203,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_replicas_operations.py index e01c863b0e0d..0da48f38664e 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_replicas_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/aio/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._replicas_operations import ( build_create_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -81,7 +83,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica] @@ -90,12 +91,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,18 +107,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,14 +127,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaListResult", pipeline_response) @@ -145,11 +143,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,10 +160,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any @@ -179,12 +173,11 @@ async def get( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,27 +188,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -225,26 +216,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,21 +242,21 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(replica_creation_parameters, (IO, bytes)): + if isinstance(replica_creation_parameters, (IOBase, bytes)): _content = replica_creation_parameters else: _json = self._serialize.body(replica_creation_parameters, "Replica") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -278,40 +265,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } - @overload async def begin_create( self, @@ -338,14 +320,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -359,7 +333,7 @@ async def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: IO, + replica_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -374,18 +348,10 @@ async def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Required. - :type replica_creation_parameters: IO + :type replica_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -399,7 +365,7 @@ async def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Replica]: """Creates a replica with the specified parameters. @@ -412,20 +378,9 @@ async def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica - type or a IO type. Required. + type or a IO[bytes] type. Required. :type replica_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica or IO[bytes] :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -435,8 +390,8 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) @@ -456,12 +411,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -471,22 +427,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,42 +451,45 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -547,14 +504,6 @@ async def begin_delete( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -562,15 +511,15 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -580,11 +529,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -595,14 +545,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/models/_models_py3.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/models/_models_py3.py index baf2b907fdb3..785322db1fff 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/models/_models_py3.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/models/_models_py3.py @@ -97,7 +97,7 @@ def __init__( class CheckNameAvailabilityParameters(_serialization.Model): """Parameters used for checking whether a resource name is available. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name to check for availability. Required. :vartype name: str @@ -137,7 +137,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -172,10 +172,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -221,10 +221,10 @@ class ConfigurationStore(TrackedResource): # pylint: disable=too-many-instance- Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1614,7 +1614,7 @@ class ResourceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.IdentityType :ivar user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.UserIdentity] :ivar principal_id: The principal id of the identity. This property will only be provided for a @@ -1652,7 +1652,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.IdentityType :keyword user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.UserIdentity] """ @@ -1702,7 +1702,7 @@ def __init__( class Sku(_serialization.Model): """Describes a configuration store SKU. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The SKU name of the configuration store. Required. :vartype name: str diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_configuration_stores_operations.py index 13ca9482f02d..0a22de8c3061 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +48,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +59,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,9 +78,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +91,7 @@ def build_list_by_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,9 +110,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +126,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,9 +143,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +160,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,9 +179,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +195,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -221,9 +212,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -240,7 +229,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -264,9 +253,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -282,7 +269,7 @@ def build_list_keys_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -301,9 +288,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -320,7 +305,7 @@ def build_regenerate_key_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -337,9 +322,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -351,7 +334,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,9 +351,7 @@ def build_get_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -386,7 +367,7 @@ def build_get_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -403,9 +384,7 @@ def build_purge_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -421,7 +400,7 @@ def build_purge_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -450,6 +429,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ConfigurationStore"]: @@ -460,7 +440,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore] @@ -469,12 +448,12 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -485,16 +464,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -505,14 +482,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -522,11 +498,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -539,8 +515,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -555,7 +529,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore] @@ -564,12 +537,12 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,17 +553,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -601,14 +572,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -618,11 +588,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -635,10 +605,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -648,12 +614,11 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,26 +629,24 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -693,25 +656,21 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -722,21 +681,21 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -744,40 +703,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_create( self, @@ -802,14 +756,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -822,7 +768,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -836,18 +782,10 @@ def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -860,7 +798,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -871,20 +809,9 @@ def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStore or IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -894,8 +821,8 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) @@ -914,12 +841,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -929,22 +857,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -955,41 +879,44 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1000,14 +927,6 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1015,15 +934,15 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -1032,11 +951,12 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1045,26 +965,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1075,21 +991,21 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1097,40 +1013,35 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_update( self, @@ -1155,14 +1066,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1175,7 +1078,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1189,18 +1092,10 @@ def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1213,7 +1108,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -1224,21 +1119,10 @@ def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ConfigurationStoreUpdateParameters or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1248,8 +1132,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) @@ -1268,12 +1152,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1283,17 +1168,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -1311,7 +1194,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey] @@ -1320,12 +1202,12 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1336,18 +1218,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1358,14 +1238,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -1375,11 +1254,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1392,10 +1271,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload def regenerate_key( self, @@ -1419,7 +1294,6 @@ def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1430,7 +1304,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1443,11 +1317,10 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1458,7 +1331,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1469,18 +1342,14 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1491,8 +1360,8 @@ def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) @@ -1500,12 +1369,12 @@ def regenerate_key( content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1513,16 +1382,14 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1532,22 +1399,17 @@ def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1557,12 +1419,12 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1573,15 +1435,13 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1592,14 +1452,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1609,11 +1468,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1626,10 +1485,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _models.DeletedConfigurationStore: """Gets a deleted Azure app configuration store. @@ -1638,12 +1493,11 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1654,26 +1508,24 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1683,21 +1535,15 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements - self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _purge_deleted_initial(self, location: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1708,41 +1554,44 @@ def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1752,14 +1601,6 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,15 +1608,15 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_deleted_initial( # type: ignore + raw_result = self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1784,11 +1625,12 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1797,14 +1639,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_key_values_operations.py index 0aca62ad1d5e..02357058eec8 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +44,7 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, @@ -54,9 +55,7 @@ def build_list_by_configuration_store_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +71,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,9 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +107,7 @@ def build_get_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,9 +124,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -147,7 +142,7 @@ def build_create_or_update_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,9 +161,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -185,7 +178,7 @@ def build_delete_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,6 +207,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -231,7 +225,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either KeyValue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue] @@ -240,12 +233,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.KeyValueListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,18 +249,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -278,14 +269,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("KeyValueListResult", pipeline_response) @@ -295,11 +285,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,10 +302,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any @@ -330,12 +316,11 @@ def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,27 +331,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -376,16 +359,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -413,7 +392,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +403,7 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -441,11 +419,10 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -457,7 +434,7 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: """Creates a key-value. @@ -471,18 +448,14 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. + or a IO[bytes] type. Default value is None. :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,8 +466,8 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) @@ -502,7 +475,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -510,7 +483,7 @@ def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -519,16 +492,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,21 +509,17 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -563,42 +530,45 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -614,14 +584,6 @@ def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -629,15 +591,15 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -647,11 +609,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -660,14 +623,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_operations.py index 74c17eb86890..7a1310621f57 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,20 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +44,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -59,7 +56,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,9 +73,7 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,13 +90,13 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_regional_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_regional_check_name_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -115,7 +110,7 @@ def build_regional_check_name_availability_request(location: str, subscription_i "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,6 +141,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def check_name_availability( @@ -164,7 +160,6 @@ def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -172,17 +167,16 @@ def check_name_availability( @overload def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -190,23 +184,23 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or + IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,8 +211,8 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) @@ -226,27 +220,25 @@ def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,16 +248,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: @@ -276,7 +264,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.OperationDefinition] @@ -285,12 +272,12 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -301,15 +288,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -320,14 +305,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -337,11 +321,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,8 +338,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload def regional_check_name_availability( self, @@ -376,7 +358,6 @@ def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -386,7 +367,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -397,11 +378,10 @@ def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +391,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -419,18 +399,16 @@ def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.CheckNameAvailabilityParameters or + IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,8 +419,8 @@ def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) @@ -450,28 +428,26 @@ def regional_check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -481,13 +457,9 @@ def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_endpoint_connections_operations.py index a336745f2f1a..fcab05d369fc 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,15 +44,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +66,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,9 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +106,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,9 +127,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +147,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -175,9 +170,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +189,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -225,6 +218,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -237,7 +231,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -247,12 +240,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,17 +256,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -284,14 +275,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -301,11 +291,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -318,10 +308,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -335,12 +321,11 @@ def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -351,27 +336,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,26 +364,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,21 +390,21 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -434,40 +413,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create_or_update( self, @@ -495,14 +469,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -516,7 +482,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -532,18 +498,10 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -557,7 +515,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -571,20 +529,9 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -594,8 +541,8 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -615,12 +562,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -630,22 +578,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,42 +602,45 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -706,14 +655,6 @@ def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -721,15 +662,15 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -739,11 +680,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -752,14 +694,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_link_resources_operations.py index 4864d448ef9d..7596c4032efd 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +61,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +95,7 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,6 +124,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -142,7 +137,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateLinkResource] @@ -151,12 +145,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,17 +161,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -188,14 +180,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -205,11 +196,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,10 +213,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -239,12 +226,11 @@ def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,27 +241,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +269,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_replicas_operations.py index 8c4cbcdc57bf..3628bd10bff4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_replicas_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_03_01_preview/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +44,7 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, @@ -54,9 +55,7 @@ def build_list_by_configuration_store_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +71,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,9 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +107,7 @@ def build_get_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,9 +124,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -147,7 +142,7 @@ def build_create_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,9 +161,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -185,7 +178,7 @@ def build_delete_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,6 +207,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -231,7 +225,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica] @@ -240,12 +233,12 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,18 +249,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -278,14 +269,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaListResult", pipeline_response) @@ -295,11 +285,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,10 +302,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any @@ -329,12 +315,11 @@ def get( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,27 +330,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -375,26 +358,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,21 +384,21 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(replica_creation_parameters, (IO, bytes)): + if isinstance(replica_creation_parameters, (IOBase, bytes)): _content = replica_creation_parameters else: _json = self._serialize.body(replica_creation_parameters, "Replica") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -428,40 +407,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } - @overload def begin_create( self, @@ -488,14 +462,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica] @@ -508,7 +474,7 @@ def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: IO, + replica_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -523,18 +489,10 @@ def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Required. - :type replica_creation_parameters: IO + :type replica_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica] @@ -547,7 +505,7 @@ def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Replica]: """Creates a replica with the specified parameters. @@ -560,20 +518,9 @@ def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica - type or a IO type. Required. + type or a IO[bytes] type. Required. :type replica_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica or IO[bytes] :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2022_03_01_preview.models.Replica] @@ -582,8 +529,8 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) @@ -603,12 +550,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -618,22 +566,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -644,42 +590,45 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -694,14 +643,6 @@ def begin_delete( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -709,15 +650,15 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-03-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-03-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -727,11 +668,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -742,14 +684,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_app_configuration_management_client.py index 57cb85f68001..9b6968ede048 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -67,25 +70,45 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -105,12 +128,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AppConfigurationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_configuration.py index 4a7d1e075081..a19363effb6f 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", "2022-05-01") + api_version: str = kwargs.pop("api_version", "2022-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_metadata.json b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_metadata.json index f1e192bfd449..a41e7a8f5495 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_metadata.json +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "configuration_stores": "ConfigurationStoresOperations", diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_vendor.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_version.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_version.py index cac9f5d10f8b..e5754a47ce68 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_version.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_app_configuration_management_client.py index d1dff100d6e4..1323c005de88 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -67,25 +70,47 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-05-01" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -105,12 +130,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AppConfigurationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_configuration.py index 9fc6fefdeee5..b7b79279583b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", "2022-05-01") + api_version: str = kwargs.pop("api_version", "2022-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_configuration_stores_operations.py index b97f9f369803..33f277d6c57d 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._configuration_stores_operations import ( build_create_request, build_delete_request, @@ -45,10 +46,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,6 +72,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ConfigurationStore"]: @@ -81,7 +83,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore] @@ -90,10 +91,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,16 +105,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -124,14 +123,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -141,11 +139,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,8 +156,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -174,7 +170,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore] @@ -183,10 +178,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,17 +192,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -218,14 +211,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -235,11 +227,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,10 +244,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace_async async def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -265,12 +253,11 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,24 +268,22 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,25 +293,21 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,19 +318,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -357,40 +338,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_create( self, @@ -415,14 +391,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -435,7 +403,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -449,18 +417,10 @@ async def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -473,7 +433,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -484,20 +444,9 @@ async def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore or IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -507,7 +456,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -525,12 +474,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -540,22 +490,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,39 +514,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -611,14 +562,6 @@ async def begin_delete( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -626,13 +569,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -641,11 +584,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -654,26 +598,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,19 +624,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -704,40 +644,35 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_update( self, @@ -762,14 +697,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -782,7 +709,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -796,18 +723,10 @@ async def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -820,7 +739,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -831,20 +750,9 @@ async def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStoreUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStoreUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -854,7 +762,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -872,12 +780,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -887,17 +796,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -915,7 +822,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey] @@ -924,10 +830,10 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,18 +844,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -960,14 +864,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -977,11 +880,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -994,10 +897,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload async def regenerate_key( self, @@ -1021,7 +920,6 @@ async def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1032,7 +930,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1045,11 +943,10 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1060,7 +957,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1071,18 +968,14 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1093,19 +986,19 @@ async def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1113,16 +1006,14 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1132,22 +1023,17 @@ async def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1157,10 +1043,10 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1171,15 +1057,13 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1190,14 +1074,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1207,11 +1090,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1224,10 +1107,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace_async async def get_deleted( self, location: str, config_store_name: str, **kwargs: Any @@ -1238,12 +1117,11 @@ async def get_deleted( :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1254,24 +1132,22 @@ async def get_deleted( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1281,21 +1157,17 @@ async def get_deleted( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - async def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements + async def _purge_deleted_initial( self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1306,39 +1178,42 @@ async def _purge_deleted_initial( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1348,14 +1223,6 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1363,13 +1230,13 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_deleted_initial( # type: ignore + raw_result = await self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1378,11 +1245,12 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1391,14 +1259,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_key_values_operations.py index 9d7d8c0ea389..43c58777d247 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,25 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._key_values_operations import build_create_or_update_request, build_delete_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -71,12 +73,11 @@ async def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,25 +88,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,16 +114,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -152,7 +147,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -164,7 +158,7 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -180,11 +174,10 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +189,7 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: """Creates a key-value. @@ -210,17 +203,14 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. - :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue or + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,14 +221,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -246,7 +236,7 @@ async def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -255,16 +245,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -274,21 +262,17 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,40 +283,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -348,14 +335,6 @@ async def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -363,13 +342,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -379,11 +358,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -392,14 +372,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_operations.py index 685afcb236dd..51307a940b8f 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,25 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import ( build_check_name_availability_request, build_list_request, build_regional_check_name_availability_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def check_name_availability( @@ -79,7 +79,6 @@ async def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -87,17 +86,16 @@ async def check_name_availability( @overload async def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -105,23 +103,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,34 +129,32 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,16 +164,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: @@ -189,7 +180,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.OperationDefinition] @@ -198,10 +188,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,15 +202,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -231,14 +219,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -248,11 +235,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,8 +252,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload async def regional_check_name_availability( self, @@ -287,7 +272,6 @@ async def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -297,7 +281,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -308,11 +292,10 @@ async def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +305,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -330,18 +313,15 @@ async def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,35 +332,33 @@ async def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +368,9 @@ async def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py index fd8a3c02ba11..8c58ed2e0cfc 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -76,7 +78,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -86,10 +87,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +101,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +120,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -172,12 +166,11 @@ async def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,25 +181,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,26 +207,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,19 +233,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -267,40 +254,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -329,14 +311,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -350,7 +324,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -367,18 +341,10 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -392,7 +358,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -407,20 +373,9 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -430,7 +385,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -449,12 +404,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -464,22 +420,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,40 +444,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -538,14 +495,6 @@ async def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,13 +502,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -569,11 +518,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -582,14 +532,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_link_resources_operations.py index c38ab100783d..52adf70398fb 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,24 +20,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import ( build_get_request, build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -72,7 +71,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateLinkResource] @@ -81,10 +79,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +93,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -133,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +145,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -167,12 +158,11 @@ async def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,25 +173,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,13 +199,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/models/_models_py3.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/models/_models_py3.py index ac72d1ff21a4..fa55c7ac1d1e 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/models/_models_py3.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/models/_models_py3.py @@ -97,7 +97,7 @@ def __init__( class CheckNameAvailabilityParameters(_serialization.Model): """Parameters used for checking whether a resource name is available. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name to check for availability. Required. :vartype name: str @@ -136,7 +136,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -171,10 +171,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -220,10 +220,10 @@ class ConfigurationStore(TrackedResource): # pylint: disable=too-many-instance- Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1512,7 +1512,7 @@ class ResourceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.appconfiguration.v2022_05_01.models.IdentityType :ivar user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2022_05_01.models.UserIdentity] :ivar principal_id: The principal id of the identity. This property will only be provided for a @@ -1550,7 +1550,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.appconfiguration.v2022_05_01.models.IdentityType :keyword user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2022_05_01.models.UserIdentity] """ @@ -1600,7 +1600,7 @@ def __init__( class Sku(_serialization.Model): """Describes a configuration store SKU. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The SKU name of the configuration store. Required. :vartype name: str diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_configuration_stores_operations.py index 6f12b75a8631..098b57e34bf0 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +59,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,7 +78,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +91,7 @@ def build_list_by_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +110,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +126,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +143,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,7 +160,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -194,7 +195,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +212,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -228,7 +229,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -252,7 +253,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +269,7 @@ def build_list_keys_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -287,7 +288,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -304,7 +305,7 @@ def build_regenerate_key_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -321,7 +322,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -333,7 +334,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -350,7 +351,7 @@ def build_get_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +367,7 @@ def build_get_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -383,7 +384,7 @@ def build_purge_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -399,7 +400,7 @@ def build_purge_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -428,6 +429,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ConfigurationStore"]: @@ -438,7 +440,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore] @@ -447,10 +448,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,16 +462,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -481,14 +480,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -498,11 +496,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -515,8 +513,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -531,7 +527,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore] @@ -540,10 +535,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +549,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +568,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -592,11 +584,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,10 +601,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -622,12 +610,11 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,24 +625,22 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -665,25 +650,21 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,19 +675,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -714,40 +695,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_create( self, @@ -772,14 +748,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -792,7 +760,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -806,18 +774,10 @@ def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -830,7 +790,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -841,20 +801,9 @@ def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStore or IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -864,7 +813,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -882,12 +831,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -897,22 +847,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -923,39 +869,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -966,14 +915,6 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -981,13 +922,13 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -996,11 +937,12 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1009,26 +951,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1039,19 +977,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1059,40 +997,35 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_update( self, @@ -1117,14 +1050,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1137,7 +1062,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1151,18 +1076,10 @@ def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1175,7 +1092,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -1186,20 +1103,9 @@ def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStoreUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.ConfigurationStoreUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1209,7 +1115,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1227,12 +1133,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1242,17 +1149,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -1270,7 +1175,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey] :raises ~azure.core.exceptions.HttpResponseError: @@ -1278,10 +1182,10 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1292,18 +1196,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1314,14 +1216,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -1331,11 +1232,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1348,10 +1249,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload def regenerate_key( self, @@ -1375,7 +1272,6 @@ def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1386,7 +1282,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1399,11 +1295,10 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1414,7 +1309,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1425,18 +1320,14 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1447,19 +1338,19 @@ def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1467,16 +1358,14 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1486,22 +1375,17 @@ def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1511,10 +1395,10 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1525,15 +1409,13 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1544,14 +1426,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1561,11 +1442,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1578,10 +1459,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _models.DeletedConfigurationStore: """Gets a deleted Azure app configuration store. @@ -1590,12 +1467,11 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1606,24 +1482,22 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1633,21 +1507,15 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements - self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _purge_deleted_initial(self, location: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1658,39 +1526,42 @@ def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1700,14 +1571,6 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1715,13 +1578,13 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_deleted_initial( # type: ignore + raw_result = self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1730,11 +1593,12 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1743,14 +1607,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_key_values_operations.py index e6c5521b7967..a25fa81001c6 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,12 +30,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +65,7 @@ def build_get_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +100,7 @@ def build_create_or_update_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +136,7 @@ def build_delete_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,6 +165,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -179,12 +181,11 @@ def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,25 +196,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,16 +222,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -260,7 +255,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +266,7 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +282,10 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +297,7 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: """Creates a key-value. @@ -318,17 +311,14 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. - :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue or + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,14 +329,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -354,7 +344,7 @@ def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -363,16 +353,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -382,21 +370,17 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,40 +391,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -456,14 +443,6 @@ def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -471,13 +450,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -487,11 +466,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -500,14 +480,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_operations.py index 39df5b41d419..d6957092b87f 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,20 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +44,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -57,7 +56,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,7 +73,7 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,11 +90,13 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_regional_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_regional_check_name_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -109,7 +110,7 @@ def build_regional_check_name_availability_request(location: str, subscription_i "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,6 +141,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def check_name_availability( @@ -158,7 +160,6 @@ def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -166,17 +167,16 @@ def check_name_availability( @overload def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -184,23 +184,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,34 +210,32 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,16 +245,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: @@ -268,7 +261,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.OperationDefinition] @@ -277,10 +269,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -291,15 +283,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -310,14 +300,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -327,11 +316,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,8 +333,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload def regional_check_name_availability( self, @@ -366,7 +353,6 @@ def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -376,7 +362,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -387,11 +373,10 @@ def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -401,7 +386,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -409,18 +394,15 @@ def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2022_05_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,35 +413,33 @@ def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,13 +449,9 @@ def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_endpoint_connections_operations.py index 7a18376296ce..60b4d2671a89 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,13 +44,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +66,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +106,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -146,7 +147,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -169,7 +170,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +189,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -217,6 +218,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -229,7 +231,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -239,10 +240,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,17 +254,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -274,14 +273,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -291,11 +289,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,10 +306,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -325,12 +319,11 @@ def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,25 +334,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,26 +360,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,19 +386,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -420,40 +407,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create_or_update( self, @@ -482,14 +464,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -503,7 +477,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -520,18 +494,10 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -545,7 +511,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -560,20 +526,9 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -583,7 +538,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -602,12 +557,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -617,22 +573,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -643,40 +597,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -691,14 +648,6 @@ def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -706,13 +655,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -722,11 +671,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -735,14 +685,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_link_resources_operations.py index 6a1086b320c5..9e662c61628f 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2022_05_01/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +95,7 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,6 +124,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -138,7 +137,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateLinkResource] @@ -147,10 +145,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,17 +159,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -182,14 +178,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -199,11 +194,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,10 +211,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -233,12 +224,11 @@ def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2022_05_01.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,25 +239,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,13 +265,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_app_configuration_management_client.py index 62459c73a097..c1775c57db1e 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -70,26 +73,46 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-03-01") self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" + ) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize, "2023-03-01") - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -109,12 +132,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AppConfigurationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_configuration.py index ea2833c5f763..e96d4e0ee6db 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", "2023-03-01") + api_version: str = kwargs.pop("api_version", "2023-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_metadata.json b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_metadata.json index 12c61872593a..59dd4bc9fa28 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_metadata.json +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "configuration_stores": "ConfigurationStoresOperations", diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_vendor.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_version.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_version.py index cac9f5d10f8b..e5754a47ce68 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_version.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_app_configuration_management_client.py index 9a0aaf0403a2..92a0b8c02810 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_app_configuration_management_client.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_app_configuration_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -70,26 +73,48 @@ def __init__( self._config = AppConfigurationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.configuration_stores = ConfigurationStoresOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-03-01") self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" ) - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-03-01" + ) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize, "2023-03-01") - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -109,12 +134,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AppConfigurationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_configuration.py index 8dc112b38539..02a6b7c3be0d 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_configuration.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AppConfigurationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AppConfigurationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -41,8 +34,7 @@ class AppConfigurationManagementClientConfiguration(Configuration): # pylint: d """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AppConfigurationManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", "2023-03-01") + api_version: str = kwargs.pop("api_version", "2023-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_configuration_stores_operations.py index 1770f1629278..6c78c0eabd68 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._configuration_stores_operations import ( build_create_request, build_delete_request, @@ -45,10 +46,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,6 +72,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ConfigurationStore"]: @@ -81,7 +83,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore] @@ -90,10 +91,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,16 +105,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -124,14 +123,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -141,11 +139,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,8 +156,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -174,7 +170,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore] @@ -183,10 +178,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,17 +192,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -218,14 +211,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -235,11 +227,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,10 +244,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace_async async def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -265,12 +253,11 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,24 +268,22 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,25 +293,21 @@ async def get(self, resource_group_name: str, config_store_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,19 +318,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -357,40 +338,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_create( self, @@ -415,14 +391,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -435,7 +403,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -449,18 +417,10 @@ async def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -473,7 +433,7 @@ async def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -484,20 +444,9 @@ async def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore or IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -507,7 +456,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -525,12 +474,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -540,22 +490,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,39 +514,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -611,14 +562,6 @@ async def begin_delete( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -626,13 +569,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -641,11 +584,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -654,26 +598,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,19 +624,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -704,40 +644,35 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload async def begin_update( self, @@ -762,14 +697,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -782,7 +709,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -796,18 +723,10 @@ async def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -820,7 +739,7 @@ async def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -831,20 +750,9 @@ async def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStoreUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStoreUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -854,7 +762,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -872,12 +780,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -887,17 +796,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -915,7 +822,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey] @@ -924,10 +830,10 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,18 +844,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -960,14 +864,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -977,11 +880,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -994,10 +897,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload async def regenerate_key( self, @@ -1021,7 +920,6 @@ async def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1032,7 +930,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1045,11 +943,10 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1060,7 +957,7 @@ async def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1071,18 +968,14 @@ async def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1093,19 +986,19 @@ async def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1113,16 +1006,14 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1132,22 +1023,17 @@ async def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1157,10 +1043,10 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1171,15 +1057,13 @@ def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigura def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1190,14 +1074,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1207,11 +1090,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1224,10 +1107,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace_async async def get_deleted( self, location: str, config_store_name: str, **kwargs: Any @@ -1238,12 +1117,11 @@ async def get_deleted( :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1254,24 +1132,22 @@ async def get_deleted( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1281,21 +1157,17 @@ async def get_deleted( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - async def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements + async def _purge_deleted_initial( self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1306,39 +1178,42 @@ async def _purge_deleted_initial( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace_async async def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1348,14 +1223,6 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1363,13 +1230,13 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_deleted_initial( # type: ignore + raw_result = await self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1378,11 +1245,12 @@ async def begin_purge_deleted(self, location: str, config_store_name: str, **kwa params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1391,14 +1259,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_key_values_operations.py index 2f0365c1c58f..cbaaa9df9ff0 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,25 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._key_values_operations import build_create_or_update_request, build_delete_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +57,15 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any ) -> _models.KeyValue: - """Gets the properties of the specified key-value. + """Gets the properties of the specified key-value. NOTE: This operation is intended for use in ARM + Template deployments. For all other scenarios involving App Configuration key-values the data + plane API should be used instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -71,12 +75,11 @@ async def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,25 +90,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,16 +116,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -137,7 +134,9 @@ async def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -152,7 +151,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -164,12 +162,14 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -180,11 +180,10 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -196,10 +195,12 @@ async def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -210,17 +211,14 @@ async def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. - :type key_value_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue or + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,14 +229,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -246,7 +244,7 @@ async def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -255,16 +253,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -274,21 +270,17 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,46 +291,51 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes a key-value. + """Deletes a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -348,14 +345,6 @@ async def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -363,13 +352,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -379,11 +368,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -392,14 +382,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_operations.py index 9cdc850c5c67..d0eca0671495 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,25 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import ( build_check_name_availability_request, build_list_request, build_regional_check_name_availability_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def check_name_availability( @@ -79,7 +79,6 @@ async def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -87,17 +86,16 @@ async def check_name_availability( @overload async def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -105,23 +103,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,34 +129,32 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,16 +164,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: @@ -189,7 +180,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.OperationDefinition] @@ -198,10 +188,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,15 +202,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -231,14 +219,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -248,11 +235,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,8 +252,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload async def regional_check_name_availability( self, @@ -287,7 +272,6 @@ async def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -297,7 +281,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -308,11 +292,10 @@ async def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +305,7 @@ async def regional_check_name_availability( async def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -330,18 +313,15 @@ async def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,35 +332,33 @@ async def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +368,9 @@ async def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_endpoint_connections_operations.py index 6a53daf8e89d..489d5e1e5a5b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -76,7 +78,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -86,10 +87,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +101,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +120,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -172,12 +166,11 @@ async def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,25 +181,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,26 +207,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,19 +233,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -267,40 +254,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -329,14 +311,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -350,7 +324,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -367,18 +341,10 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -392,7 +358,7 @@ async def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -407,20 +373,9 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -430,7 +385,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -449,12 +404,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -464,22 +420,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,40 +444,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -538,14 +495,6 @@ async def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,13 +502,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -569,11 +518,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -582,14 +532,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_link_resources_operations.py index 193bb8bb5cf4..6e25b0de5bf4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,24 +20,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import ( build_get_request, build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -72,7 +71,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateLinkResource] @@ -81,10 +79,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +93,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -133,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +145,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -167,12 +158,11 @@ async def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,25 +173,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,13 +199,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_replicas_operations.py index 7bf2c53da59f..f99b99a945bb 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_replicas_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/aio/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._replicas_operations import ( build_create_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_by_configuration_store_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,6 +65,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -81,7 +83,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.Replica] @@ -90,10 +91,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,18 +105,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -126,14 +125,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaListResult", pipeline_response) @@ -143,11 +141,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,10 +158,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas" - } - @distributed_trace_async async def get( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any @@ -177,12 +171,11 @@ async def get( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,25 +186,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,26 +212,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,19 +238,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(replica_creation_parameters, (IO, bytes)): + if isinstance(replica_creation_parameters, (IOBase, bytes)): _content = replica_creation_parameters else: _json = self._serialize.body(replica_creation_parameters, "Replica") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -272,40 +259,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } - @overload async def begin_create( self, @@ -331,14 +313,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -352,7 +326,7 @@ async def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: IO, + replica_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -367,18 +341,10 @@ async def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Required. - :type replica_creation_parameters: IO + :type replica_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -392,7 +358,7 @@ async def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Replica]: """Creates a replica with the specified parameters. @@ -405,20 +371,9 @@ async def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica - type or a IO type. Required. + type or a IO[bytes] type. Required. :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.Replica or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: @@ -428,7 +383,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -447,12 +402,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -465,22 +421,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,30 +445,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -525,12 +482,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -545,14 +502,6 @@ async def begin_delete( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -560,13 +509,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -576,11 +525,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -592,14 +542,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/models/_models_py3.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/models/_models_py3.py index f6a1c059876d..92161cce3f5b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/models/_models_py3.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/models/_models_py3.py @@ -97,7 +97,7 @@ def __init__( class CheckNameAvailabilityParameters(_serialization.Model): """Parameters used for checking whether a resource name is available. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name to check for availability. Required. :vartype name: str @@ -136,7 +136,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -171,10 +171,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -220,10 +220,10 @@ class ConfigurationStore(TrackedResource): # pylint: disable=too-many-instance- Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1597,7 +1597,7 @@ class ResourceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.appconfiguration.v2023_03_01.models.IdentityType :ivar user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2023_03_01.models.UserIdentity] :ivar principal_id: The principal id of the identity. This property will only be provided for a @@ -1635,7 +1635,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.appconfiguration.v2023_03_01.models.IdentityType :keyword user_assigned_identities: The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appconfiguration.v2023_03_01.models.UserIdentity] """ @@ -1685,7 +1685,7 @@ def __init__( class Sku(_serialization.Model): """Describes a configuration store SKU. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The SKU name of the configuration store. Required. :vartype name: str diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_configuration_stores_operations.py index 1e580859fb0e..96e03d005872 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_configuration_stores_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_configuration_stores_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +59,7 @@ def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,7 +78,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +91,7 @@ def build_list_by_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +110,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +126,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +143,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,7 +160,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -194,7 +195,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +212,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -228,7 +229,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -252,7 +253,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +269,7 @@ def build_list_keys_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -287,7 +288,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -304,7 +305,7 @@ def build_regenerate_key_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -321,7 +322,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -333,7 +334,7 @@ def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpReque "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -350,7 +351,7 @@ def build_get_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +367,7 @@ def build_get_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -383,7 +384,7 @@ def build_purge_deleted_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -399,7 +400,7 @@ def build_purge_deleted_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -428,6 +429,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ConfigurationStore"]: @@ -438,7 +440,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore] @@ -447,10 +448,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,16 +462,14 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -481,14 +480,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -498,11 +496,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -515,8 +513,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -531,7 +527,6 @@ def list_by_resource_group( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationStore or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore] @@ -540,10 +535,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +549,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +568,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) @@ -592,11 +584,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,10 +601,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores" - } - @distributed_trace def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: """Gets the properties of the specified configuration store. @@ -622,12 +610,11 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,24 +625,22 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -665,25 +650,21 @@ def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,19 +675,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_creation_parameters, (IO, bytes)): + if isinstance(config_store_creation_parameters, (IOBase, bytes)): _content = config_store_creation_parameters else: _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -714,40 +695,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_create( self, @@ -772,14 +748,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -792,7 +760,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: IO, + config_store_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -806,18 +774,10 @@ def begin_create( :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Required. - :type config_store_creation_parameters: IO + :type config_store_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -830,7 +790,7 @@ def begin_create( self, resource_group_name: str, config_store_name: str, - config_store_creation_parameters: Union[_models.ConfigurationStore, IO], + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Creates a configuration store with the specified parameters. @@ -841,20 +801,9 @@ def begin_create( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_creation_parameters: The parameters for creating a configuration store. Is - either a ConfigurationStore type or a IO type. Required. + either a ConfigurationStore type or a IO[bytes] type. Required. :type config_store_creation_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStore or IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -864,7 +813,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -882,12 +831,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -897,22 +847,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -923,39 +869,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -966,14 +915,6 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -981,13 +922,13 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, api_version=api_version, @@ -996,11 +937,12 @@ def begin_delete(self, resource_group_name: str, config_store_name: str, **kwarg params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1009,26 +951,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.ConfigurationStore: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1039,19 +977,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(config_store_update_parameters, (IO, bytes)): + if isinstance(config_store_update_parameters, (IOBase, bytes)): _content = config_store_update_parameters else: _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1059,40 +997,35 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } - @overload def begin_update( self, @@ -1117,14 +1050,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1137,7 +1062,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: IO, + config_store_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1151,18 +1076,10 @@ def begin_update( :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Required. - :type config_store_update_parameters: IO + :type config_store_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1175,7 +1092,7 @@ def begin_update( self, resource_group_name: str, config_store_name: str, - config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO], + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ConfigurationStore]: """Updates a configuration store with the specified parameters. @@ -1186,20 +1103,9 @@ def begin_update( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param config_store_update_parameters: The parameters for updating a configuration store. Is - either a ConfigurationStoreUpdateParameters type or a IO type. Required. + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. :type config_store_update_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStoreUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.ConfigurationStoreUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either ConfigurationStore or the result of cls(response) :rtype: @@ -1209,7 +1115,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1227,12 +1133,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConfigurationStore", pipeline_response) + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1242,17 +1149,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ConfigurationStore].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}" - } + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys( @@ -1270,7 +1175,6 @@ def list_keys( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiKey or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey] :raises ~azure.core.exceptions.HttpResponseError: @@ -1278,10 +1182,10 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1292,18 +1196,16 @@ def list_keys( def prepare_request(next_link=None): if not next_link: - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1314,14 +1216,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiKeyListResult", pipeline_response) @@ -1331,11 +1232,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1348,10 +1249,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys" - } - @overload def regenerate_key( self, @@ -1375,7 +1272,6 @@ def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1386,7 +1282,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1399,11 +1295,10 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: @@ -1414,7 +1309,7 @@ def regenerate_key( self, resource_group_name: str, config_store_name: str, - regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.ApiKey: """Regenerates an access key for the specified configuration store. @@ -1425,18 +1320,14 @@ def regenerate_key( :param config_store_name: The name of the configuration store. Required. :type config_store_name: str :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a - RegenerateKeyParameters type or a IO type. Required. + RegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.RegenerateKeyParameters or IO[bytes] :return: ApiKey or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.ApiKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1447,19 +1338,19 @@ def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, @@ -1467,16 +1358,14 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1486,22 +1375,17 @@ def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiKey", pipeline_response) + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey" - } + return deserialized # type: ignore @distributed_trace def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationStore"]: """Gets information about the deleted configuration stores in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedConfigurationStore or the result of cls(response) :rtype: @@ -1511,10 +1395,10 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1525,15 +1409,13 @@ def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationS def prepare_request(next_link=None): if not next_link: - request = build_list_deleted_request( + _request = build_list_deleted_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1544,14 +1426,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) @@ -1561,11 +1442,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1578,10 +1459,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores" - } - @distributed_trace def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _models.DeletedConfigurationStore: """Gets a deleted Azure app configuration store. @@ -1590,12 +1467,11 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedConfigurationStore or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.DeletedConfigurationStore :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1606,24 +1482,22 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) - request = build_get_deleted_request( + _request = build_get_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_deleted.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1633,21 +1507,15 @@ def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _ error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response) + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}" - } + return deserialized # type: ignore - def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements - self, location: str, config_store_name: str, **kwargs: Any - ) -> None: - error_map = { + def _purge_deleted_initial(self, location: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1658,39 +1526,42 @@ def _purge_deleted_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_purge_deleted_request( + _request = build_purge_deleted_request( location=location, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._purge_deleted_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _purge_deleted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return deserialized # type: ignore @distributed_trace def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1700,14 +1571,6 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A :type location: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1715,13 +1578,13 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_deleted_initial( # type: ignore + raw_result = self._purge_deleted_initial( location=location, config_store_name=config_store_name, api_version=api_version, @@ -1730,11 +1593,12 @@ def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: A params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1743,14 +1607,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_purge_deleted.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_key_values_operations.py index d4bad12eae97..ffaaa2741012 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_key_values_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_key_values_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,12 +30,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +65,7 @@ def build_get_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +100,7 @@ def build_create_or_update_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +136,7 @@ def build_delete_request( "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,12 +165,15 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any ) -> _models.KeyValue: - """Gets the properties of the specified key-value. + """Gets the properties of the specified key-value. NOTE: This operation is intended for use in ARM + Template deployments. For all other scenarios involving App Configuration key-values the data + plane API should be used instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -179,12 +183,11 @@ def get( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,25 +198,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,16 +224,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -245,7 +242,9 @@ def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -260,7 +259,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -272,12 +270,14 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[IO] = None, + key_value_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -288,11 +288,10 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Default value is None. - :type key_value_parameters: IO + :type key_value_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: @@ -304,10 +303,12 @@ def create_or_update( resource_group_name: str, config_store_name: str, key_value_name: str, - key_value_parameters: Optional[Union[_models.KeyValue, IO]] = None, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, **kwargs: Any ) -> _models.KeyValue: - """Creates a key-value. + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -318,17 +319,14 @@ def create_or_update( character. Label is optional. Required. :type key_value_name: str :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type - or a IO type. Default value is None. - :type key_value_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue or + IO[bytes] :return: KeyValue or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,14 +337,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_value_parameters, (IO, bytes)): + if isinstance(key_value_parameters, (IOBase, bytes)): _content = key_value_parameters else: if key_value_parameters is not None: @@ -354,7 +352,7 @@ def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -363,16 +361,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -382,21 +378,17 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyValue", pipeline_response) + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,46 +399,51 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes a key-value. + """Deletes a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. :param resource_group_name: The name of the resource group to which the container registry belongs. Required. @@ -456,14 +453,6 @@ def begin_delete( :param key_value_name: Identifier of key and label combination. Key and label are joined by $ character. Label is optional. Required. :type key_value_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -471,13 +460,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, key_value_name=key_value_name, @@ -487,11 +476,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -500,14 +490,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_operations.py index 5a125a9cf15e..88b12929d4ba 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,20 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +44,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -57,7 +56,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,7 +73,7 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,11 +90,13 @@ def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> Ht return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_regional_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_regional_check_name_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -109,7 +110,7 @@ def build_regional_check_name_availability_request(location: str, subscription_i "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,6 +141,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def check_name_availability( @@ -158,7 +160,6 @@ def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -166,17 +167,16 @@ def check_name_availability( @overload def check_name_availability( - self, check_name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -184,23 +184,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,34 +210,32 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,16 +245,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: @@ -268,7 +261,6 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.OperationDefinition] @@ -277,10 +269,10 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -291,15 +283,13 @@ def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -310,14 +300,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) @@ -327,11 +316,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,8 +333,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.AppConfiguration/operations"} - @overload def regional_check_name_availability( self, @@ -366,7 +353,6 @@ def regional_check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -376,7 +362,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: IO, + check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -387,11 +373,10 @@ def regional_check_name_availability( :type location: str :param check_name_availability_parameters: The object containing information for the availability request. Required. - :type check_name_availability_parameters: IO + :type check_name_availability_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: @@ -401,7 +386,7 @@ def regional_check_name_availability( def regional_check_name_availability( self, location: str, - check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO], + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailabilityStatus: """Checks whether the configuration store name is available for use. @@ -409,18 +394,15 @@ def regional_check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param check_name_availability_parameters: The object containing information for the - availability request. Is either a CheckNameAvailabilityParameters type or a IO type. Required. + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. :type check_name_availability_parameters: - ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.appconfiguration.v2023_03_01.models.CheckNameAvailabilityParameters or IO[bytes] :return: NameAvailabilityStatus or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.NameAvailabilityStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,35 +413,33 @@ def regional_check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_parameters, (IO, bytes)): + if isinstance(check_name_availability_parameters, (IOBase, bytes)): _content = check_name_availability_parameters else: _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") - request = build_regional_check_name_availability_request( + _request = build_regional_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.regional_check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,13 +449,9 @@ def regional_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response) + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regional_check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_endpoint_connections_operations.py index 3b80d58d39bc..082c48d9eadc 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,13 +44,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +66,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +106,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -146,7 +147,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -169,7 +170,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +189,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -217,6 +218,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -229,7 +231,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -239,10 +240,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,17 +254,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -274,14 +273,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -291,11 +289,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,10 +306,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -325,12 +319,11 @@ def get( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,25 +334,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,26 +360,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,19 +386,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -420,40 +407,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create_or_update( self, @@ -482,14 +464,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -503,7 +477,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -520,18 +494,10 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -545,7 +511,7 @@ def begin_create_or_update( resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of the specified private endpoint connection associated with the configuration @@ -560,20 +526,9 @@ def begin_create_or_update( :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type private_endpoint_connection: - ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -583,7 +538,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -602,12 +557,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -617,22 +573,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -643,40 +597,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -691,14 +648,6 @@ def begin_delete( :type config_store_name: str :param private_endpoint_connection_name: Private endpoint connection name. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -706,13 +655,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -722,11 +671,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -735,14 +685,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_link_resources_operations.py index 12f9adf09845..1a8eaed43a4d 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_link_resources_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,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, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +95,7 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,6 +124,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -138,7 +137,6 @@ def list_by_configuration_store( :type resource_group_name: str :param config_store_name: The name of the configuration store. Required. :type config_store_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateLinkResource] @@ -147,10 +145,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,17 +159,15 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -182,14 +178,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -199,11 +194,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,10 +211,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any @@ -233,12 +224,11 @@ def get( :type config_store_name: str :param group_name: The name of the private link resource group. Required. :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,25 +239,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,13 +265,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_replicas_operations.py index c6d0c2b2679b..2744c6d7df86 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_replicas_operations.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2023_03_01/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +44,7 @@ _SERIALIZER.client_side_validation = False -def build_list_by_configuration_store_request( +def build_list_by_configuration_store_request( # pylint: disable=name-too-long resource_group_name: str, config_store_name: str, subscription_id: str, @@ -54,7 +55,7 @@ def build_list_by_configuration_store_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +71,7 @@ def build_list_by_configuration_store_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +107,7 @@ def build_get_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -123,7 +124,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_create_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +161,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +178,7 @@ def build_delete_request( "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -206,6 +207,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_configuration_store( @@ -223,7 +225,6 @@ def list_by_configuration_store( element will include a skipToken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2023_03_01.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -231,10 +232,10 @@ def list_by_configuration_store( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,18 +246,16 @@ def list_by_configuration_store( def prepare_request(next_link=None): if not next_link: - request = build_list_by_configuration_store_request( + _request = build_list_by_configuration_store_request( resource_group_name=resource_group_name, config_store_name=config_store_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_configuration_store.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -267,14 +266,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaListResult", pipeline_response) @@ -284,11 +282,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,10 +299,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_configuration_store.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas" - } - @distributed_trace def get( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any @@ -318,12 +312,11 @@ def get( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appconfiguration.v2023_03_01.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,25 +327,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,26 +353,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,19 +379,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(replica_creation_parameters, (IO, bytes)): + if isinstance(replica_creation_parameters, (IOBase, bytes)): _content = replica_creation_parameters else: _json = self._serialize.body(replica_creation_parameters, "Replica") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -413,40 +400,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } - @overload def begin_create( self, @@ -472,14 +454,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2023_03_01.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -491,7 +465,7 @@ def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: IO, + replica_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -506,18 +480,10 @@ def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Required. - :type replica_creation_parameters: IO + :type replica_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2023_03_01.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -529,7 +495,7 @@ def begin_create( resource_group_name: str, config_store_name: str, replica_name: str, - replica_creation_parameters: Union[_models.Replica, IO], + replica_creation_parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Replica]: """Creates a replica with the specified parameters. @@ -542,20 +508,9 @@ def begin_create( :param replica_name: The name of the replica. Required. :type replica_name: str :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica - type or a IO type. Required. + type or a IO[bytes] type. Required. :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2023_03_01.models.Replica or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2023_03_01.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -563,7 +518,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -582,12 +537,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -599,22 +555,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,30 +579,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -659,12 +616,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -679,14 +636,6 @@ def begin_delete( :type config_store_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -694,13 +643,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, config_store_name=config_store_name, replica_name=replica_name, @@ -710,11 +659,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -725,14 +675,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/__init__.py new file mode 100644 index 000000000000..f2ea8d6fa6dd --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_configuration_management_client import AppConfigurationManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AppConfigurationManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_app_configuration_management_client.py new file mode 100644 index 000000000000..c1cb0bc883e9 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_app_configuration_management_client.py @@ -0,0 +1,151 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import AppConfigurationManagementClientConfiguration +from .operations import ( + ConfigurationStoresOperations, + KeyValuesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ReplicasOperations, + SnapshotsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppConfigurationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """AppConfigurationManagementClient. + + :ivar configuration_stores: ConfigurationStoresOperations operations + :vartype configuration_stores: + azure.mgmt.appconfiguration.v2024_05_01.operations.ConfigurationStoresOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appconfiguration.v2024_05_01.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.appconfiguration.v2024_05_01.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.appconfiguration.v2024_05_01.operations.PrivateLinkResourcesOperations + :ivar key_values: KeyValuesOperations operations + :vartype key_values: azure.mgmt.appconfiguration.v2024_05_01.operations.KeyValuesOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.appconfiguration.v2024_05_01.operations.ReplicasOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.appconfiguration.v2024_05_01.operations.SnapshotsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Microsoft Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppConfigurationManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.configuration_stores = ConfigurationStoresOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-05-01") + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize, "2024-05-01") + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_configuration.py new file mode 100644 index 000000000000..ba57e98c7ced --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for AppConfigurationManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Microsoft Azure subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2024-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_metadata.json b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_metadata.json new file mode 100644 index 000000000000..98ec06ffc696 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_metadata.json @@ -0,0 +1,116 @@ +{ + "chosen_version": "2024-05-01", + "total_api_version_list": ["2024-05-01"], + "client": { + "name": "AppConfigurationManagementClient", + "filename": "_app_configuration_management_client", + "description": "AppConfigurationManagementClient.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_public_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AppConfigurationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "configuration_stores": "ConfigurationStoresOperations", + "operations": "Operations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "key_values": "KeyValuesOperations", + "replicas": "ReplicasOperations", + "snapshots": "SnapshotsOperations" + } +} diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_patch.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_version.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/__init__.py new file mode 100644 index 000000000000..185a5e3680ea --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._app_configuration_management_client import AppConfigurationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AppConfigurationManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_app_configuration_management_client.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_app_configuration_management_client.py new file mode 100644 index 000000000000..698c65f3db5b --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_app_configuration_management_client.py @@ -0,0 +1,153 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import AppConfigurationManagementClientConfiguration +from .operations import ( + ConfigurationStoresOperations, + KeyValuesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ReplicasOperations, + SnapshotsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppConfigurationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """AppConfigurationManagementClient. + + :ivar configuration_stores: ConfigurationStoresOperations operations + :vartype configuration_stores: + azure.mgmt.appconfiguration.v2024_05_01.aio.operations.ConfigurationStoresOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.appconfiguration.v2024_05_01.aio.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.appconfiguration.v2024_05_01.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.appconfiguration.v2024_05_01.aio.operations.PrivateLinkResourcesOperations + :ivar key_values: KeyValuesOperations operations + :vartype key_values: azure.mgmt.appconfiguration.v2024_05_01.aio.operations.KeyValuesOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.appconfiguration.v2024_05_01.aio.operations.ReplicasOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.appconfiguration.v2024_05_01.aio.operations.SnapshotsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Microsoft Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AppConfigurationManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.configuration_stores = ConfigurationStoresOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-05-01") + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.key_values = KeyValuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize, "2024-05-01") + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-05-01" + ) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_configuration.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_configuration.py new file mode 100644 index 000000000000..dc1a7d909ab5 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AppConfigurationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for AppConfigurationManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Microsoft Azure subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2024-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appconfiguration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_patch.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/__init__.py new file mode 100644 index 000000000000..32a6900a6d7c --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._configuration_stores_operations import ConfigurationStoresOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._key_values_operations import KeyValuesOperations +from ._replicas_operations import ReplicasOperations +from ._snapshots_operations import SnapshotsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ConfigurationStoresOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "KeyValuesOperations", + "ReplicasOperations", + "SnapshotsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_configuration_stores_operations.py new file mode 100644 index 000000000000..14f90042d09b --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_configuration_stores_operations.py @@ -0,0 +1,1268 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._configuration_stores_operations import ( + build_create_request, + build_delete_request, + build_get_deleted_request, + build_get_request, + build_list_by_resource_group_request, + build_list_deleted_request, + build_list_keys_request, + build_list_request, + build_purge_deleted_request, + build_regenerate_key_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`configuration_stores` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ConfigurationStore"]: + """Lists the configuration stores for a given subscription. + + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ConfigurationStore or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationStore"]: + """Lists the configuration stores for a given resource group. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ConfigurationStore or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: + """Gets the properties of the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: ConfigurationStore or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_store_creation_parameters, (IOBase, bytes)): + _content = config_store_creation_parameters + else: + _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: _models.ConfigurationStore, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. + Required. + :type config_store_creation_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. + Required. + :type config_store_creation_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. Is + either a ConfigurationStore type or a IO[bytes] type. Required. + :type config_store_creation_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + config_store_creation_parameters=config_store_creation_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_store_update_parameters, (IOBase, bytes)): + _content = config_store_update_parameters + else: + _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: _models.ConfigurationStoreUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. + Required. + :type config_store_update_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStoreUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. + Required. + :type config_store_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. Is + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. + :type config_store_update_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStoreUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + config_store_update_parameters=config_store_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ConfigurationStore].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_keys( + self, resource_group_name: str, config_store_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ApiKey"]: + """Lists the access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ApiKey or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiKeyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Required. + :type regenerate_key_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Required. + :type regenerate_key_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type regenerate_key_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.RegenerateKeyParameters or IO[bytes] + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_parameters, (IOBase, bytes)): + _content = regenerate_key_parameters + else: + _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") + + _request = build_regenerate_key_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> AsyncIterable["_models.DeletedConfigurationStore"]: + """Gets information about the deleted configuration stores in a subscription. + + :return: An iterator like instance of either DeletedConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_deleted( + self, location: str, config_store_name: str, **kwargs: Any + ) -> _models.DeletedConfigurationStore: + """Gets a deleted Azure app configuration store. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: DeletedConfigurationStore or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) + + _request = build_get_deleted_request( + location=location, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_deleted_initial( + self, location: str, config_store_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_purge_deleted_request( + location=location, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Permanently deletes the specified configuration store. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._purge_deleted_initial( + location=location, + config_store_name=config_store_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_key_values_operations.py new file mode 100644 index 000000000000..617566a18dc4 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_key_values_operations.py @@ -0,0 +1,391 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._key_values_operations import build_create_or_update_request, build_delete_request, build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class KeyValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`key_values` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> _models.KeyValue: + """Gets the properties of the specified key-value. NOTE: This operation is intended for use in ARM + Template deployments. For all other scenarios involving App Configuration key-values the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[_models.KeyValue] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Default value is None. + :type key_value_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue or + IO[bytes] + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_value_parameters, (IOBase, bytes)): + _content = key_value_parameters + else: + if key_value_parameters is not None: + _json = self._serialize.body(key_value_parameters, "KeyValue") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_operations.py new file mode 100644 index 000000000000..b24b502e8f21 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_operations.py @@ -0,0 +1,376 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._operations import ( + build_check_name_availability_request, + build_list_request, + build_regional_check_name_availability_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + async def check_name_availability( + self, + check_name_availability_parameters: _models.CheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters or IO[bytes] + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_parameters, (IOBase, bytes)): + _content = check_name_availability_parameters + else: + _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") + + _request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: + """Lists the operations available from this provider. + + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: _models.CheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters or IO[bytes] + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_parameters, (IOBase, bytes)): + _content = check_name_availability_parameters + else: + _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") + + _request = build_regional_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_patch.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..967fbc5815d9 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,541 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_configuration_store_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Required. + :type private_endpoint_connection: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Required. + :type private_endpoint_connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..dc06bcd5f89f --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,207 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._private_link_resources_operations import ( + build_get_request, + build_list_by_configuration_store_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource that need to be created for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param group_name: The name of the private link resource group. Required. + :type group_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_replicas_operations.py new file mode 100644 index 000000000000..f353f35549fe --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_replicas_operations.py @@ -0,0 +1,551 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._replicas_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_configuration_store_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`replicas` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Replica"]: + """Lists the replicas for a given configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either Replica or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicaListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> _models.Replica: + """Gets the properties of the specified replica. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: Replica or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replica", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: Union[_models.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replica_creation_parameters, (IOBase, bytes)): + _content = replica_creation_parameters + else: + _json = self._serialize.body(replica_creation_parameters, "Replica") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Required. + :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Replica or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Required. + :type replica_creation_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Replica or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: Union[_models.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica + type or a IO[bytes] type. Required. + :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either Replica or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + replica_creation_parameters=replica_creation_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replica", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a replica. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_snapshots_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_snapshots_operations.py new file mode 100644 index 000000000000..312de682f5ef --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/aio/operations/_snapshots_operations.py @@ -0,0 +1,340 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._snapshots_operations import build_create_request, build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.aio.AppConfigurationManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, resource_group_name: str, config_store_name: str, snapshot_name: str, **kwargs: Any + ) -> _models.Snapshot: + """Gets the properties of the specified snapshot. NOTE: This operation is intended for use in + Azure Resource Manager (ARM) Template deployments. For all other scenarios involving App + Configuration snapshots the data plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: Union[_models.Snapshot, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "Snapshot") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Required. + :type body: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: Union[_models.Snapshot, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Is either a Snapshot type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Snapshot].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/__init__.py new file mode 100644 index 000000000000..1df2657f1de1 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/__init__.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ApiKey +from ._models_py3 import ApiKeyListResult +from ._models_py3 import CheckNameAvailabilityParameters +from ._models_py3 import ConfigurationStore +from ._models_py3 import ConfigurationStoreListResult +from ._models_py3 import ConfigurationStoreUpdateParameters +from ._models_py3 import DataPlaneProxyProperties +from ._models_py3 import DeletedConfigurationStore +from ._models_py3 import DeletedConfigurationStoreListResult +from ._models_py3 import EncryptionProperties +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorDetails +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseAutoGenerated +from ._models_py3 import KeyValue +from ._models_py3 import KeyValueFilter +from ._models_py3 import KeyValueListResult +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LogSpecification +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import NameAvailabilityStatus +from ._models_py3 import OperationDefinition +from ._models_py3 import OperationDefinitionDisplay +from ._models_py3 import OperationDefinitionListResult +from ._models_py3 import OperationProperties +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointConnectionReference +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegenerateKeyParameters +from ._models_py3 import Replica +from ._models_py3 import ReplicaListResult +from ._models_py3 import Resource +from ._models_py3 import ResourceIdentity +from ._models_py3 import ServiceSpecification +from ._models_py3 import Sku +from ._models_py3 import Snapshot +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UserIdentity + +from ._app_configuration_management_client_enums import ActionsRequired +from ._app_configuration_management_client_enums import AuthenticationMode +from ._app_configuration_management_client_enums import CompositionType +from ._app_configuration_management_client_enums import ConfigurationResourceType +from ._app_configuration_management_client_enums import ConnectionStatus +from ._app_configuration_management_client_enums import CreateMode +from ._app_configuration_management_client_enums import CreatedByType +from ._app_configuration_management_client_enums import IdentityType +from ._app_configuration_management_client_enums import PrivateLinkDelegation +from ._app_configuration_management_client_enums import ProvisioningState +from ._app_configuration_management_client_enums import PublicNetworkAccess +from ._app_configuration_management_client_enums import ReplicaProvisioningState +from ._app_configuration_management_client_enums import SnapshotStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApiKey", + "ApiKeyListResult", + "CheckNameAvailabilityParameters", + "ConfigurationStore", + "ConfigurationStoreListResult", + "ConfigurationStoreUpdateParameters", + "DataPlaneProxyProperties", + "DeletedConfigurationStore", + "DeletedConfigurationStoreListResult", + "EncryptionProperties", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorDetails", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "KeyValue", + "KeyValueFilter", + "KeyValueListResult", + "KeyVaultProperties", + "LogSpecification", + "MetricDimension", + "MetricSpecification", + "NameAvailabilityStatus", + "OperationDefinition", + "OperationDefinitionDisplay", + "OperationDefinitionListResult", + "OperationProperties", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionReference", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "RegenerateKeyParameters", + "Replica", + "ReplicaListResult", + "Resource", + "ResourceIdentity", + "ServiceSpecification", + "Sku", + "Snapshot", + "SystemData", + "TrackedResource", + "UserIdentity", + "ActionsRequired", + "AuthenticationMode", + "CompositionType", + "ConfigurationResourceType", + "ConnectionStatus", + "CreateMode", + "CreatedByType", + "IdentityType", + "PrivateLinkDelegation", + "ProvisioningState", + "PublicNetworkAccess", + "ReplicaProvisioningState", + "SnapshotStatus", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_app_configuration_management_client_enums.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_app_configuration_management_client_enums.py new file mode 100644 index 000000000000..895c3a9e616e --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_app_configuration_management_client_enums.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Any action that is required beyond basic workflow (approve/ reject/ disconnect).""" + + NONE = "None" + RECREATE = "Recreate" + + +class AuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data plane proxy authentication mode. This property manages the authentication mode of + request to the data plane resources. + """ + + LOCAL = "Local" + """The local authentication mode. Users are not required to have data plane permissions if local + authentication is not disabled.""" + PASS_THROUGH = "Pass-through" + """The pass-through authentication mode. User identity will be passed through from Azure Resource + Manager (ARM), requiring user to have data plane action permissions (Available via App + Configuration Data Owner/ App Configuration Data Reader).""" + + +class CompositionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The composition type describes how the key-values within the snapshot are composed. The 'key' + composition type ensures there are no two key-values containing the same key. The 'key_label' + composition type ensures there are no two key-values containing the same key and label. + """ + + KEY = "Key" + KEY_LABEL = "Key_Label" + + +class ConfigurationResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The resource type to check for name availability.""" + + MICROSOFT_APP_CONFIGURATION_CONFIGURATION_STORES = "Microsoft.AppConfiguration/configurationStores" + + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether the configuration store need to be recovered.""" + + RECOVER = "Recover" + DEFAULT = "Default" + + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an + implicitly created identity and a set of user-assigned identities. The type 'None' will remove + any identities. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + + +class PrivateLinkDelegation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data plane proxy private link delegation. This property manages if a request from delegated + Azure Resource Manager (ARM) private link is allowed when the data plane resource requires + private link. + """ + + ENABLED = "Enabled" + """Azure Resource Manager (ARM) private endpoint is required if the resource requires private + link.""" + DISABLED = "Disabled" + """Request is denied if the resource requires private link.""" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the configuration store.""" + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Control permission for data plane traffic coming from public networks while private endpoint is + enabled. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ReplicaProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the replica.""" + + CREATING = "Creating" + SUCCEEDED = "Succeeded" + DELETING = "Deleting" + FAILED = "Failed" + CANCELED = "Canceled" + + +class SnapshotStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the snapshot.""" + + PROVISIONING = "Provisioning" + READY = "Ready" + ARCHIVED = "Archived" + FAILED = "Failed" diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_models_py3.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_models_py3.py new file mode 100644 index 000000000000..20de0bf71ea8 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_models_py3.py @@ -0,0 +1,2086 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ApiKey(_serialization.Model): + """An API key used for authenticating with a configuration store endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The key ID. + :vartype id: str + :ivar name: A name for the key describing its usage. + :vartype name: str + :ivar value: The value of the key that is used for authentication purposes. + :vartype value: str + :ivar connection_string: A connection string that can be used by supporting clients for + authentication. + :vartype connection_string: str + :ivar last_modified: The last time any of the key's properties were modified. + :vartype last_modified: ~datetime.datetime + :ivar read_only: Whether this key can only be used for read operations. + :vartype read_only: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "value": {"readonly": True}, + "connection_string": {"readonly": True}, + "last_modified": {"readonly": True}, + "read_only": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "last_modified": {"key": "lastModified", "type": "iso-8601"}, + "read_only": {"key": "readOnly", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.value = None + self.connection_string = None + self.last_modified = None + self.read_only = None + + +class ApiKeyListResult(_serialization.Model): + """The result of a request to list API keys. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ApiKey]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ApiKey"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CheckNameAvailabilityParameters(_serialization.Model): + """Parameters used for checking whether a resource name is available. + + All required parameters must be populated in order to send to server. + + :ivar name: The name to check for availability. Required. + :vartype name: str + :ivar type: The resource type to check for name availability. Required. + "Microsoft.AppConfiguration/configurationStores" + :vartype type: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationResourceType + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: str, type: Union[str, "_models.ConfigurationResourceType"], **kwargs: Any) -> None: + """ + :keyword name: The name to check for availability. Required. + :paramtype name: str + :keyword type: The resource type to check for name availability. Required. + "Microsoft.AppConfiguration/configurationStores" + :paramtype type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationResourceType + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class ConfigurationStore(TrackedResource): # pylint: disable=too-many-instance-attributes + """The configuration store along with all resource properties. The Configuration Store will have + all information to begin utilizing it. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: The managed identity information, if configured. + :vartype identity: ~azure.mgmt.appconfiguration.v2024_05_01.models.ResourceIdentity + :ivar sku: The sku of the configuration store. Required. + :vartype sku: ~azure.mgmt.appconfiguration.v2024_05_01.models.Sku + :ivar system_data: Resource system metadata. + :vartype system_data: ~azure.mgmt.appconfiguration.v2024_05_01.models.SystemData + :ivar provisioning_state: The provisioning state of the configuration store. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ProvisioningState + :ivar creation_date: The creation date of configuration store. + :vartype creation_date: ~datetime.datetime + :ivar endpoint: The DNS endpoint where the configuration store API will be available. + :vartype endpoint: str + :ivar encryption: The encryption settings of the configuration store. + :vartype encryption: ~azure.mgmt.appconfiguration.v2024_05_01.models.EncryptionProperties + :ivar private_endpoint_connections: The list of private endpoint connections that are set up + for this resource. + :vartype private_endpoint_connections: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnectionReference] + :ivar public_network_access: Control permission for data plane traffic coming from public + networks while private endpoint is enabled. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PublicNetworkAccess + :ivar disable_local_auth: Disables all authentication methods other than AAD authentication. + :vartype disable_local_auth: bool + :ivar soft_delete_retention_in_days: The amount of time in days that the configuration store + will be retained when it is soft deleted. + :vartype soft_delete_retention_in_days: int + :ivar enable_purge_protection: Property specifying whether protection against purge is enabled + for this configuration store. + :vartype enable_purge_protection: bool + :ivar data_plane_proxy: Property specifying the configuration of data plane proxy for Azure + Resource Manager (ARM). + :vartype data_plane_proxy: + ~azure.mgmt.appconfiguration.v2024_05_01.models.DataPlaneProxyProperties + :ivar create_mode: Indicates whether the configuration store need to be recovered. Known values + are: "Recover" and "Default". + :vartype create_mode: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.CreateMode + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "creation_date": {"readonly": True}, + "endpoint": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "sku": {"key": "sku", "type": "Sku"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperties"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnectionReference]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "soft_delete_retention_in_days": {"key": "properties.softDeleteRetentionInDays", "type": "int"}, + "enable_purge_protection": {"key": "properties.enablePurgeProtection", "type": "bool"}, + "data_plane_proxy": {"key": "properties.dataPlaneProxy", "type": "DataPlaneProxyProperties"}, + "create_mode": {"key": "properties.createMode", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + disable_local_auth: bool = False, + soft_delete_retention_in_days: int = 7, + enable_purge_protection: bool = False, + data_plane_proxy: Optional["_models.DataPlaneProxyProperties"] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The managed identity information, if configured. + :paramtype identity: ~azure.mgmt.appconfiguration.v2024_05_01.models.ResourceIdentity + :keyword sku: The sku of the configuration store. Required. + :paramtype sku: ~azure.mgmt.appconfiguration.v2024_05_01.models.Sku + :keyword encryption: The encryption settings of the configuration store. + :paramtype encryption: ~azure.mgmt.appconfiguration.v2024_05_01.models.EncryptionProperties + :keyword public_network_access: Control permission for data plane traffic coming from public + networks while private endpoint is enabled. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PublicNetworkAccess + :keyword disable_local_auth: Disables all authentication methods other than AAD authentication. + :paramtype disable_local_auth: bool + :keyword soft_delete_retention_in_days: The amount of time in days that the configuration store + will be retained when it is soft deleted. + :paramtype soft_delete_retention_in_days: int + :keyword enable_purge_protection: Property specifying whether protection against purge is + enabled for this configuration store. + :paramtype enable_purge_protection: bool + :keyword data_plane_proxy: Property specifying the configuration of data plane proxy for Azure + Resource Manager (ARM). + :paramtype data_plane_proxy: + ~azure.mgmt.appconfiguration.v2024_05_01.models.DataPlaneProxyProperties + :keyword create_mode: Indicates whether the configuration store need to be recovered. Known + values are: "Recover" and "Default". + :paramtype create_mode: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.CreateMode + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.sku = sku + self.system_data = None + self.provisioning_state = None + self.creation_date = None + self.endpoint = None + self.encryption = encryption + self.private_endpoint_connections = None + self.public_network_access = public_network_access + self.disable_local_auth = disable_local_auth + self.soft_delete_retention_in_days = soft_delete_retention_in_days + self.enable_purge_protection = enable_purge_protection + self.data_plane_proxy = data_plane_proxy + self.create_mode = create_mode + + +class ConfigurationStoreListResult(_serialization.Model): + """The result of a request to list configuration stores. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationStore]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ConfigurationStore"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ConfigurationStoreUpdateParameters(_serialization.Model): + """The parameters for updating a configuration store. + + :ivar identity: The managed identity information for the configuration store. + :vartype identity: ~azure.mgmt.appconfiguration.v2024_05_01.models.ResourceIdentity + :ivar sku: The SKU of the configuration store. + :vartype sku: ~azure.mgmt.appconfiguration.v2024_05_01.models.Sku + :ivar tags: The ARM resource tags. + :vartype tags: dict[str, str] + :ivar encryption: The encryption settings of the configuration store. + :vartype encryption: ~azure.mgmt.appconfiguration.v2024_05_01.models.EncryptionProperties + :ivar disable_local_auth: Disables all authentication methods other than AAD authentication. + :vartype disable_local_auth: bool + :ivar public_network_access: Control permission for data plane traffic coming from public + networks while private endpoint is enabled. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PublicNetworkAccess + :ivar enable_purge_protection: Property specifying whether protection against purge is enabled + for this configuration store. + :vartype enable_purge_protection: bool + :ivar data_plane_proxy: Property specifying the configuration of data plane proxy for Azure + Resource Manager (ARM). + :vartype data_plane_proxy: + ~azure.mgmt.appconfiguration.v2024_05_01.models.DataPlaneProxyProperties + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperties"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "enable_purge_protection": {"key": "properties.enablePurgeProtection", "type": "bool"}, + "data_plane_proxy": {"key": "properties.dataPlaneProxy", "type": "DataPlaneProxyProperties"}, + } + + def __init__( + self, + *, + identity: Optional["_models.ResourceIdentity"] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + disable_local_auth: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + enable_purge_protection: Optional[bool] = None, + data_plane_proxy: Optional["_models.DataPlaneProxyProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The managed identity information for the configuration store. + :paramtype identity: ~azure.mgmt.appconfiguration.v2024_05_01.models.ResourceIdentity + :keyword sku: The SKU of the configuration store. + :paramtype sku: ~azure.mgmt.appconfiguration.v2024_05_01.models.Sku + :keyword tags: The ARM resource tags. + :paramtype tags: dict[str, str] + :keyword encryption: The encryption settings of the configuration store. + :paramtype encryption: ~azure.mgmt.appconfiguration.v2024_05_01.models.EncryptionProperties + :keyword disable_local_auth: Disables all authentication methods other than AAD authentication. + :paramtype disable_local_auth: bool + :keyword public_network_access: Control permission for data plane traffic coming from public + networks while private endpoint is enabled. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PublicNetworkAccess + :keyword enable_purge_protection: Property specifying whether protection against purge is + enabled for this configuration store. + :paramtype enable_purge_protection: bool + :keyword data_plane_proxy: Property specifying the configuration of data plane proxy for Azure + Resource Manager (ARM). + :paramtype data_plane_proxy: + ~azure.mgmt.appconfiguration.v2024_05_01.models.DataPlaneProxyProperties + """ + super().__init__(**kwargs) + self.identity = identity + self.sku = sku + self.tags = tags + self.encryption = encryption + self.disable_local_auth = disable_local_auth + self.public_network_access = public_network_access + self.enable_purge_protection = enable_purge_protection + self.data_plane_proxy = data_plane_proxy + + +class DataPlaneProxyProperties(_serialization.Model): + """The data plane proxy settings for a configuration store. + + :ivar authentication_mode: The data plane proxy authentication mode. This property manages the + authentication mode of request to the data plane resources. Known values are: "Local" and + "Pass-through". + :vartype authentication_mode: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.AuthenticationMode + :ivar private_link_delegation: The data plane proxy private link delegation. This property + manages if a request from delegated Azure Resource Manager (ARM) private link is allowed when + the data plane resource requires private link. Known values are: "Enabled" and "Disabled". + :vartype private_link_delegation: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkDelegation + """ + + _attribute_map = { + "authentication_mode": {"key": "authenticationMode", "type": "str"}, + "private_link_delegation": {"key": "privateLinkDelegation", "type": "str"}, + } + + def __init__( + self, + *, + authentication_mode: Optional[Union[str, "_models.AuthenticationMode"]] = None, + private_link_delegation: Optional[Union[str, "_models.PrivateLinkDelegation"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword authentication_mode: The data plane proxy authentication mode. This property manages + the authentication mode of request to the data plane resources. Known values are: "Local" and + "Pass-through". + :paramtype authentication_mode: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.AuthenticationMode + :keyword private_link_delegation: The data plane proxy private link delegation. This property + manages if a request from delegated Azure Resource Manager (ARM) private link is allowed when + the data plane resource requires private link. Known values are: "Enabled" and "Disabled". + :paramtype private_link_delegation: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkDelegation + """ + super().__init__(**kwargs) + self.authentication_mode = authentication_mode + self.private_link_delegation = private_link_delegation + + +class DeletedConfigurationStore(_serialization.Model): + """Deleted configuration store information with extended details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID for the deleted configuration store. + :vartype id: str + :ivar name: The name of the configuration store. + :vartype name: str + :ivar type: The resource type of the configuration store. + :vartype type: str + :ivar configuration_store_id: The resource id of the original configuration store. + :vartype configuration_store_id: str + :ivar location: The location of the original configuration store. + :vartype location: str + :ivar deletion_date: The deleted date. + :vartype deletion_date: ~datetime.datetime + :ivar scheduled_purge_date: The scheduled purged date. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar tags: Tags of the original configuration store. + :vartype tags: dict[str, str] + :ivar purge_protection_enabled: Purge protection status of the original configuration store. + :vartype purge_protection_enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "configuration_store_id": {"readonly": True}, + "location": {"readonly": True}, + "deletion_date": {"readonly": True}, + "scheduled_purge_date": {"readonly": True}, + "tags": {"readonly": True}, + "purge_protection_enabled": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "configuration_store_id": {"key": "properties.configurationStoreId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "deletion_date": {"key": "properties.deletionDate", "type": "iso-8601"}, + "scheduled_purge_date": {"key": "properties.scheduledPurgeDate", "type": "iso-8601"}, + "tags": {"key": "properties.tags", "type": "{str}"}, + "purge_protection_enabled": {"key": "properties.purgeProtectionEnabled", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.configuration_store_id = None + self.location = None + self.deletion_date = None + self.scheduled_purge_date = None + self.tags = None + self.purge_protection_enabled = None + + +class DeletedConfigurationStoreListResult(_serialization.Model): + """List of deleted configuration stores. + + :ivar value: The list of deleted configuration store. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore] + :ivar next_link: The URL to get the next set of deleted configuration stores. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DeletedConfigurationStore]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.DeletedConfigurationStore"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of deleted configuration store. + :paramtype value: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore] + :keyword next_link: The URL to get the next set of deleted configuration stores. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class EncryptionProperties(_serialization.Model): + """The encryption settings for a configuration store. + + :ivar key_vault_properties: Key vault properties. + :vartype key_vault_properties: + ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyVaultProperties + """ + + _attribute_map = { + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + } + + def __init__(self, *, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs: Any) -> None: + """ + :keyword key_vault_properties: Key vault properties. + :paramtype key_vault_properties: + ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyVaultProperties + """ + super().__init__(**kwargs) + self.key_vault_properties = key_vault_properties + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorDetails(_serialization.Model): + """The details of the error. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The + reason is provided in the error message. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorDetails + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetails"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetails"] = None, **kwargs: Any) -> None: + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorDetails + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.appconfiguration.v2024_05_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class KeyValue(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The key-value resource along with all resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar key: The primary identifier of a key-value. + The key is used in unison with the label to uniquely identify a key-value. + :vartype key: str + :ivar label: A value used to group key-values. + The label is used in unison with the key to uniquely identify a key-value. + :vartype label: str + :ivar value: The value of the key-value. + :vartype value: str + :ivar content_type: The content type of the key-value's value. + Providing a proper content-type can enable transformations of values when they are retrieved + by applications. + :vartype content_type: str + :ivar e_tag: An ETag indicating the state of a key-value within a configuration store. + :vartype e_tag: str + :ivar last_modified: The last time a modifying operation was performed on the given key-value. + :vartype last_modified: ~datetime.datetime + :ivar locked: A value indicating whether the key-value is locked. + A locked key-value may not be modified until it is unlocked. + :vartype locked: bool + :ivar tags: A dictionary of tags that can help identify what a key-value may be applicable for. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "key": {"readonly": True}, + "label": {"readonly": True}, + "e_tag": {"readonly": True}, + "last_modified": {"readonly": True}, + "locked": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "key": {"key": "properties.key", "type": "str"}, + "label": {"key": "properties.label", "type": "str"}, + "value": {"key": "properties.value", "type": "str"}, + "content_type": {"key": "properties.contentType", "type": "str"}, + "e_tag": {"key": "properties.eTag", "type": "str"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "locked": {"key": "properties.locked", "type": "bool"}, + "tags": {"key": "properties.tags", "type": "{str}"}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + content_type: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The value of the key-value. + :paramtype value: str + :keyword content_type: The content type of the key-value's value. + Providing a proper content-type can enable transformations of values when they are retrieved + by applications. + :paramtype content_type: str + :keyword tags: A dictionary of tags that can help identify what a key-value may be applicable + for. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.key = None + self.label = None + self.value = value + self.content_type = content_type + self.e_tag = None + self.last_modified = None + self.locked = None + self.tags = tags + + +class KeyValueFilter(_serialization.Model): + """Enables filtering of key-values. + + All required parameters must be populated in order to send to server. + + :ivar key: Filters key-values by their key field. Required. + :vartype key: str + :ivar label: Filters key-values by their label field. + :vartype label: str + """ + + _validation = { + "key": {"required": True}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "label": {"key": "label", "type": "str"}, + } + + def __init__(self, *, key: str, label: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key: Filters key-values by their key field. Required. + :paramtype key: str + :keyword label: Filters key-values by their label field. + :paramtype label: str + """ + super().__init__(**kwargs) + self.key = key + self.label = label + + +class KeyValueListResult(_serialization.Model): + """The result of a request to list key-values. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[KeyValue]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.KeyValue"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class KeyVaultProperties(_serialization.Model): + """Settings concerning key vault encryption for a configuration store. + + :ivar key_identifier: The URI of the key vault key used to encrypt data. + :vartype key_identifier: str + :ivar identity_client_id: The client id of the identity which will be used to access key vault. + :vartype identity_client_id: str + """ + + _attribute_map = { + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "identity_client_id": {"key": "identityClientId", "type": "str"}, + } + + def __init__( + self, *, key_identifier: Optional[str] = None, identity_client_id: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword key_identifier: The URI of the key vault key used to encrypt data. + :paramtype key_identifier: str + :keyword identity_client_id: The client id of the identity which will be used to access key + vault. + :paramtype identity_client_id: str + """ + super().__init__(**kwargs) + self.key_identifier = key_identifier + self.identity_client_id = identity_client_id + + +class LogSpecification(_serialization.Model): + """Specifications of the Log for Azure Monitoring. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration of the log. + :vartype blob_duration: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the log. + :paramtype name: str + :keyword display_name: Localized friendly display name of the log. + :paramtype display_name: str + :keyword blob_duration: Blob duration of the log. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.blob_duration = blob_duration + + +class MetricDimension(_serialization.Model): + """Specifications of the Dimension of metrics. + + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar internal_name: Internal name of the dimension. + :vartype internal_name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "internal_name": {"key": "internalName", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + internal_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Localized friendly display name of the dimension. + :paramtype display_name: str + :keyword internal_name: Internal name of the dimension. + :paramtype internal_name: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.internal_name = internal_name + + +class MetricSpecification(_serialization.Model): + """Specifications of the Metrics for Azure Monitoring. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: Unit that makes sense for the metric. + :vartype unit: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar internal_metric_name: Internal metric name. + :vartype internal_metric_name: str + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~azure.mgmt.appconfiguration.v2024_05_01.models.MetricDimension] + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :vartype fill_gap_with_zero: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + internal_metric_name: Optional[str] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + fill_gap_with_zero: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Localized friendly display name of the metric. + :paramtype display_name: str + :keyword display_description: Localized friendly description of the metric. + :paramtype display_description: str + :keyword unit: Unit that makes sense for the metric. + :paramtype unit: str + :keyword aggregation_type: Only provide one value for this field. Valid values: Average, + Minimum, Maximum, Total, Count. + :paramtype aggregation_type: str + :keyword internal_metric_name: Internal metric name. + :paramtype internal_metric_name: str + :keyword dimensions: Dimensions of the metric. + :paramtype dimensions: list[~azure.mgmt.appconfiguration.v2024_05_01.models.MetricDimension] + :keyword fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :paramtype fill_gap_with_zero: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.aggregation_type = aggregation_type + self.internal_metric_name = internal_metric_name + self.dimensions = dimensions + self.fill_gap_with_zero = fill_gap_with_zero + + +class NameAvailabilityStatus(_serialization.Model): + """The result of a request to check the availability of a resource name. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value indicating whether the resource name is available. + :vartype name_available: bool + :ivar message: If any, the error message that provides more detail for the reason that the name + is not available. + :vartype message: str + :ivar reason: If any, the reason that the name is not available. + :vartype reason: str + """ + + _validation = { + "name_available": {"readonly": True}, + "message": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name_available = None + self.message = None + self.reason = None + + +class OperationDefinition(_serialization.Model): + """The definition of a configuration store operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The display information for the configuration store operation. + :vartype display: ~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinitionDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: ~azure.mgmt.appconfiguration.v2024_05_01.models.OperationProperties + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDefinitionDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDefinitionDisplay"] = None, + origin: Optional[str] = None, + properties: Optional["_models.OperationProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The display information for the configuration store operation. + :paramtype display: ~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinitionDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: ~azure.mgmt.appconfiguration.v2024_05_01.models.OperationProperties + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + self.properties = properties + + +class OperationDefinitionDisplay(_serialization.Model): + """The display information for a configuration store operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The resource provider name: Microsoft App Configuration.". + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation that users can perform. + :vartype operation: str + :ivar description: The description for the operation. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource: The resource on which the operation is performed. + :paramtype resource: str + :keyword operation: The operation that users can perform. + :paramtype operation: str + :keyword description: The description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = None + self.resource = resource + self.operation = operation + self.description = description + + +class OperationDefinitionListResult(_serialization.Model): + """The result of a request to list configuration store operations. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinition] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.OperationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinition] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationProperties(_serialization.Model): + """Extra Operation properties. + + :ivar service_specification: Service specifications of the operation. + :vartype service_specification: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ServiceSpecification + """ + + _attribute_map = { + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__( + self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs: Any + ) -> None: + """ + :keyword service_specification: Service specifications of the operation. + :paramtype service_specification: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.service_specification = service_specification + + +class PrivateEndpoint(_serialization.Model): + """Private endpoint which a connection belongs to. + + :ivar id: The resource Id for private endpoint. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The resource Id for private endpoint. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class PrivateEndpointConnection(_serialization.Model): + """A private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar provisioning_state: The provisioning status of the private endpoint connection. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ProvisioningState + :ivar private_endpoint: The resource of private endpoint. + :vartype private_endpoint: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The resource of private endpoint. + :paramtype private_endpoint: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """A list of private endpoint connections. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateEndpointConnectionReference(_serialization.Model): + """A reference to a related private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar provisioning_state: The provisioning status of the private endpoint connection. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ProvisioningState + :ivar private_endpoint: The resource of private endpoint. + :vartype private_endpoint: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The resource of private endpoint. + :paramtype private_endpoint: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateLinkResource(_serialization.Model): + """A resource that supports private link capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The list of required DNS zone names of the private link resource. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.group_id = None + self.required_members = None + self.required_zone_names = None + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateLinkResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The state of a private link service connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The private link service connection status. Known values are: "Pending", + "Approved", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.ConnectionStatus + :ivar description: The private link service connection description. + :vartype description: str + :ivar actions_required: Any action that is required beyond basic workflow (approve/ reject/ + disconnect). Known values are: "None" and "Recreate". + :vartype actions_required: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ActionsRequired + """ + + _validation = { + "actions_required": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: The private link service connection status. Known values are: "Pending", + "Approved", "Rejected", and "Disconnected". + :paramtype status: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.ConnectionStatus + :keyword description: The private link service connection description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = None + + +class RegenerateKeyParameters(_serialization.Model): + """The parameters used to regenerate an API key. + + :ivar id: The id of the key to regenerate. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The id of the key to regenerate. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class Replica(_serialization.Model): + """The replica resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the replica. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the replica. + :vartype location: str + :ivar system_data: Resource system metadata. + :vartype system_data: ~azure.mgmt.appconfiguration.v2024_05_01.models.SystemData + :ivar endpoint: The URI of the replica where the replica API will be available. + :vartype endpoint: str + :ivar provisioning_state: The provisioning state of the replica. Known values are: "Creating", + "Succeeded", "Deleting", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ReplicaProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "endpoint": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: The location of the replica. + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.system_data = None + self.endpoint = None + self.provisioning_state = None + + +class ReplicaListResult(_serialization.Model): + """The result of a request to list replicas. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Replica]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Replica"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceIdentity(_serialization.Model): + """An identity that can be associated with a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes + both an implicitly created identity and a set of user-assigned identities. The type 'None' will + remove any identities. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned, UserAssigned". + :vartype type: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.IdentityType + :ivar user_assigned_identities: The list of user-assigned identities associated with the + resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.appconfiguration.v2024_05_01.models.UserIdentity] + :ivar principal_id: The principal id of the identity. This property will only be provided for a + system-assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id associated with the resource's identity. This property will only + be provided for a system-assigned identity. + :vartype tenant_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentity}"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.IdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' + includes both an implicitly created identity and a set of user-assigned identities. The type + 'None' will remove any identities. Known values are: "None", "SystemAssigned", "UserAssigned", + and "SystemAssigned, UserAssigned". + :paramtype type: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.IdentityType + :keyword user_assigned_identities: The list of user-assigned identities associated with the + resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.appconfiguration.v2024_05_01.models.UserIdentity] + """ + super().__init__(**kwargs) + self.type = type + self.user_assigned_identities = user_assigned_identities + self.principal_id = None + self.tenant_id = None + + +class ServiceSpecification(_serialization.Model): + """Service specification payload. + + :ivar log_specifications: Specifications of the Log for Azure Monitoring. + :vartype log_specifications: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.LogSpecification] + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.MetricSpecification] + """ + + _attribute_map = { + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + } + + def __init__( + self, + *, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword log_specifications: Specifications of the Log for Azure Monitoring. + :paramtype log_specifications: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.LogSpecification] + :keyword metric_specifications: Specifications of the Metrics for Azure Monitoring. + :paramtype metric_specifications: + list[~azure.mgmt.appconfiguration.v2024_05_01.models.MetricSpecification] + """ + super().__init__(**kwargs) + self.log_specifications = log_specifications + self.metric_specifications = metric_specifications + + +class Sku(_serialization.Model): + """Describes a configuration store SKU. + + All required parameters must be populated in order to send to server. + + :ivar name: The SKU name of the configuration store. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: The SKU name of the configuration store. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class Snapshot(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The snapshot resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the snapshot. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar provisioning_state: The provisioning state of the snapshot. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.ProvisioningState + :ivar status: The current status of the snapshot. Known values are: "Provisioning", "Ready", + "Archived", and "Failed". + :vartype status: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.SnapshotStatus + :ivar filters: A list of filters used to filter the key-values included in the snapshot. + :vartype filters: list[~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValueFilter] + :ivar composition_type: The composition type describes how the key-values within the snapshot + are composed. The 'key' composition type ensures there are no two key-values containing the + same key. The 'key_label' composition type ensures there are no two key-values containing the + same key and label. Known values are: "Key" and "Key_Label". + :vartype composition_type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.CompositionType + :ivar created: The time that the snapshot was created. + :vartype created: ~datetime.datetime + :ivar expires: The time that the snapshot will expire. + :vartype expires: ~datetime.datetime + :ivar retention_period: The amount of time, in seconds, that a snapshot will remain in the + archived state before expiring. This property is only writable during the creation of a + snapshot. If not specified, the default lifetime of key-value revisions will be used. + :vartype retention_period: int + :ivar size: The size in bytes of the snapshot. + :vartype size: int + :ivar items_count: The amount of key-values in the snapshot. + :vartype items_count: int + :ivar tags: The tags of the snapshot. NOTE: These are data plane tags, not Azure Resource + Manager (ARM) tags. + :vartype tags: dict[str, str] + :ivar etag: A value representing the current state of the snapshot. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "filters": {"max_items": 3, "min_items": 1}, + "created": {"readonly": True}, + "expires": {"readonly": True}, + "retention_period": {"maximum": 7776000, "minimum": 3600}, + "size": {"readonly": True}, + "items_count": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "filters": {"key": "properties.filters", "type": "[KeyValueFilter]"}, + "composition_type": {"key": "properties.compositionType", "type": "str"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "expires": {"key": "properties.expires", "type": "iso-8601"}, + "retention_period": {"key": "properties.retentionPeriod", "type": "int"}, + "size": {"key": "properties.size", "type": "int"}, + "items_count": {"key": "properties.itemsCount", "type": "int"}, + "tags": {"key": "properties.tags", "type": "{str}"}, + "etag": {"key": "properties.etag", "type": "str"}, + } + + def __init__( + self, + *, + filters: Optional[List["_models.KeyValueFilter"]] = None, + composition_type: Optional[Union[str, "_models.CompositionType"]] = None, + retention_period: Optional[int] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword filters: A list of filters used to filter the key-values included in the snapshot. + :paramtype filters: list[~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValueFilter] + :keyword composition_type: The composition type describes how the key-values within the + snapshot are composed. The 'key' composition type ensures there are no two key-values + containing the same key. The 'key_label' composition type ensures there are no two key-values + containing the same key and label. Known values are: "Key" and "Key_Label". + :paramtype composition_type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.CompositionType + :keyword retention_period: The amount of time, in seconds, that a snapshot will remain in the + archived state before expiring. This property is only writable during the creation of a + snapshot. If not specified, the default lifetime of key-value revisions will be used. + :paramtype retention_period: int + :keyword tags: The tags of the snapshot. NOTE: These are data plane tags, not Azure Resource + Manager (ARM) tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.status = None + self.filters = filters + self.composition_type = composition_type + self.created = None + self.expires = None + self.retention_period = retention_period + self.size = None + self.items_count = None + self.tags = tags + self.etag = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.appconfiguration.v2024_05_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.appconfiguration.v2024_05_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UserIdentity(_serialization.Model): + """A resource identity that is managed by the user of the service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the user-assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the user-assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_patch.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/__init__.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/__init__.py new file mode 100644 index 000000000000..32a6900a6d7c --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._configuration_stores_operations import ConfigurationStoresOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._key_values_operations import KeyValuesOperations +from ._replicas_operations import ReplicasOperations +from ._snapshots_operations import SnapshotsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ConfigurationStoresOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "KeyValuesOperations", + "ReplicasOperations", + "SnapshotsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_configuration_stores_operations.py new file mode 100644 index 000000000000..cad143e3ab74 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_configuration_stores_operations.py @@ -0,0 +1,1616 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, + config_store_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/regenerateKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_deleted_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/deletedConfigurationStores", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_deleted_request( + location: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_purge_deleted_request( + location: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/deletedConfigurationStores/{configStoreName}/purge", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigurationStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`configuration_stores` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ConfigurationStore"]: + """Lists the configuration stores for a given subscription. + + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ConfigurationStore or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConfigurationStore"]: + """Lists the configuration stores for a given resource group. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ConfigurationStore or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> _models.ConfigurationStore: + """Gets the properties of the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: ConfigurationStore or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_store_creation_parameters, (IOBase, bytes)): + _content = config_store_creation_parameters + else: + _json = self._serialize.body(config_store_creation_parameters, "ConfigurationStore") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: _models.ConfigurationStore, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. + Required. + :type config_store_creation_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. + Required. + :type config_store_creation_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + config_store_creation_parameters: Union[_models.ConfigurationStore, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Creates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_creation_parameters: The parameters for creating a configuration store. Is + either a ConfigurationStore type or a IO[bytes] type. Required. + :type config_store_creation_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore or IO[bytes] + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + config_store_creation_parameters=config_store_creation_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ConfigurationStore].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _update_initial( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(config_store_update_parameters, (IOBase, bytes)): + _content = config_store_update_parameters + else: + _json = self._serialize.body(config_store_update_parameters, "ConfigurationStoreUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: _models.ConfigurationStoreUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. + Required. + :type config_store_update_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStoreUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. + Required. + :type config_store_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + config_store_name: str, + config_store_update_parameters: Union[_models.ConfigurationStoreUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationStore]: + """Updates a configuration store with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param config_store_update_parameters: The parameters for updating a configuration store. Is + either a ConfigurationStoreUpdateParameters type or a IO[bytes] type. Required. + :type config_store_update_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStoreUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.ConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationStore] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + config_store_update_parameters=config_store_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationStore", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ConfigurationStore].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ConfigurationStore]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_keys( + self, resource_group_name: str, config_store_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ApiKey"]: + """Lists the access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either ApiKey or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ApiKeyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiKeyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Required. + :type regenerate_key_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Required. + :type regenerate_key_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + config_store_name: str, + regenerate_key_parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ApiKey: + """Regenerates an access key for the specified configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param regenerate_key_parameters: The parameters for regenerating an access key. Is either a + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type regenerate_key_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.RegenerateKeyParameters or IO[bytes] + :return: ApiKey or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.ApiKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_parameters, (IOBase, bytes)): + _content = regenerate_key_parameters + else: + _json = self._serialize.body(regenerate_key_parameters, "RegenerateKeyParameters") + + _request = build_regenerate_key_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> Iterable["_models.DeletedConfigurationStore"]: + """Gets information about the deleted configuration stores in a subscription. + + :return: An iterator like instance of either DeletedConfigurationStore or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.DeletedConfigurationStoreListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedConfigurationStoreListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> _models.DeletedConfigurationStore: + """Gets a deleted Azure app configuration store. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: DeletedConfigurationStore or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.DeletedConfigurationStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.DeletedConfigurationStore] = kwargs.pop("cls", None) + + _request = build_get_deleted_request( + location=location, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedConfigurationStore", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_deleted_initial(self, location: str, config_store_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_purge_deleted_request( + location=location, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_purge_deleted(self, location: str, config_store_name: str, **kwargs: Any) -> LROPoller[None]: + """Permanently deletes the specified configuration store. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._purge_deleted_initial( + location=location, + config_store_name=config_store_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_key_values_operations.py new file mode 100644 index 000000000000..25f46c0715de --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_key_values_operations.py @@ -0,0 +1,499 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, config_store_name: str, key_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, config_store_name: str, key_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, config_store_name: str, key_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "keyValueName": _SERIALIZER.url("key_value_name", key_value_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KeyValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`key_values` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> _models.KeyValue: + """Gets the properties of the specified key-value. NOTE: This operation is intended for use in ARM + Template deployments. For all other scenarios involving App Configuration key-values the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[_models.KeyValue] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Default value is None. + :type key_value_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + config_store_name: str, + key_value_name: str, + key_value_parameters: Optional[Union[_models.KeyValue, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.KeyValue: + """Creates a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :param key_value_parameters: The parameters for creating a key-value. Is either a KeyValue type + or a IO[bytes] type. Default value is None. + :type key_value_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue or + IO[bytes] + :return: KeyValue or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.KeyValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_value_parameters, (IOBase, bytes)): + _content = key_value_parameters + else: + if key_value_parameters is not None: + _json = self._serialize.body(key_value_parameters, "KeyValue") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KeyValue", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, config_store_name: str, key_value_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a key-value. NOTE: This operation is intended for use in ARM Template deployments. For + all other scenarios involving App Configuration key-values the data plane API should be used + instead. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param key_value_name: Identifier of key and label combination. Key and label are joined by $ + character. Label is optional. Required. + :type key_value_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + key_value_name=key_value_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_operations.py new file mode 100644 index 000000000000..09d672a372b5 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_operations.py @@ -0,0 +1,457 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/checkNameAvailability" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(*, skip_token: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AppConfiguration/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regional_check_name_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + def check_name_availability( + self, + check_name_availability_parameters: _models.CheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, check_name_availability_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param check_name_availability_parameters: The object containing information for the + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters or IO[bytes] + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_parameters, (IOBase, bytes)): + _content = check_name_availability_parameters + else: + _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") + + _request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: + """Lists the operations available from this provider. + + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.OperationDefinitionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: _models.CheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Required. + :type check_name_availability_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regional_check_name_availability( + self, + location: str, + check_name_availability_parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityStatus: + """Checks whether the configuration store name is available for use. + + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param check_name_availability_parameters: The object containing information for the + availability request. Is either a CheckNameAvailabilityParameters type or a IO[bytes] type. + Required. + :type check_name_availability_parameters: + ~azure.mgmt.appconfiguration.v2024_05_01.models.CheckNameAvailabilityParameters or IO[bytes] + :return: NameAvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.NameAvailabilityStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_parameters, (IOBase, bytes)): + _content = check_name_availability_parameters + else: + _json = self._serialize.body(check_name_availability_parameters, "CheckNameAvailabilityParameters") + + _request = build_regional_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_patch.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..8d9290298fb7 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,694 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_configuration_store_request( # pylint: disable=name-too-long + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Required. + :type private_endpoint_connection: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Required. + :type private_endpoint_connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + config_store_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of the specified private endpoint connection associated with the configuration + store. This operation cannot be used to create a private endpoint connection. Private endpoint + connections must be created with the Network resource provider. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: + ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, config_store_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param private_endpoint_connection_name: Private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..472085ea7054 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_private_link_resources_operations.py @@ -0,0 +1,273 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_configuration_store_request( # pylint: disable=name-too-long + resource_group_name: str, config_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, config_store_name: str, group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, config_store_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource that need to be created for a configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param group_name: The name of the private link resource group. Required. + :type group_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_replicas_operations.py new file mode 100644 index 000000000000..19ca97e01b71 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_replicas_operations.py @@ -0,0 +1,684 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_configuration_store_request( # pylint: disable=name-too-long + resource_group_name: str, + config_store_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, config_store_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, config_store_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, config_store_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/replicas/{replicaName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`replicas` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_configuration_store( + self, resource_group_name: str, config_store_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Replica"]: + """Lists the replicas for a given configuration store. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param skip_token: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skip_token: str + :return: An iterator like instance of either Replica or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.ReplicaListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_configuration_store_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicaListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> _models.Replica: + """Gets the properties of the specified replica. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: Replica or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replica", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: Union[_models.Replica, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replica_creation_parameters, (IOBase, bytes)): + _content = replica_creation_parameters + else: + _json = self._serialize.body(replica_creation_parameters, "Replica") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Required. + :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Replica or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Required. + :type replica_creation_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Replica or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + replica_name: str, + replica_creation_parameters: Union[_models.Replica, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Creates a replica with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param replica_creation_parameters: The parameters for creating a replica. Is either a Replica + type or a IO[bytes] type. Required. + :type replica_creation_parameters: ~azure.mgmt.appconfiguration.v2024_05_01.models.Replica or + IO[bytes] + :return: An instance of LROPoller that returns either Replica or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + replica_creation_parameters=replica_creation_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replica", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, config_store_name: str, replica_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a replica. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + replica_name=replica_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_snapshots_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_snapshots_operations.py new file mode 100644 index 000000000000..676a3d3d25d3 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/operations/_snapshots_operations.py @@ -0,0 +1,411 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, config_store_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str", pattern=r"^[^\x00-\x1F\x7F]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, config_store_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/snapshots/{snapshotName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "configStoreName": _SERIALIZER.url( + "config_store_name", config_store_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9_-]*$" + ), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str", pattern=r"^[^\x00-\x1F\x7F]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appconfiguration.v2024_05_01.AppConfigurationManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, resource_group_name: str, config_store_name: str, snapshot_name: str, **kwargs: Any + ) -> _models.Snapshot: + """Gets the properties of the specified snapshot. NOTE: This operation is intended for use in + Azure Resource Manager (ARM) Template deployments. For all other scenarios involving App + Configuration snapshots the data plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: Union[_models.Snapshot, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "Snapshot") + + _request = build_create_request( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Required. + :type body: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + config_store_name: str, + snapshot_name: str, + body: Union[_models.Snapshot, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates a snapshot. NOTE: This operation is intended for use in Azure Resource Manager (ARM) + Template deployments. For all other scenarios involving App Configuration snapshots the data + plane API should be used instead. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param config_store_name: The name of the configuration store. Required. + :type config_store_name: str + :param snapshot_name: The name of the snapshot. Required. + :type snapshot_name: str + :param body: The parameters for creating a snapshot. Is either a Snapshot type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot or IO[bytes] + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appconfiguration.v2024_05_01.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + config_store_name=config_store_name, + snapshot_name=snapshot_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Snapshot].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/py.typed b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/azure/mgmt/appconfiguration/v2024_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_available.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_available.py index 333c2e7a9594..87aba1d831b7 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_available.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/CheckNameAvailable.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/CheckNameAvailable.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_not_available.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_not_available.py index 0fd5f81a8eb0..a0fa3ff5e7d4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_not_available.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/check_name_not_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/CheckNameNotAvailable.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/CheckNameNotAvailable.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create.py index 7f9e7e84ec1e..cc670a1b413b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -41,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreate.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreate.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_key_value.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_key_value.py index 38b525683300..59b22578eb42 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_key_value.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_key_value.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateKeyValue.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateKeyValue.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_replica.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_replica.py index 78832a235c86..ecd4a42521d4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_replica.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_replica.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateReplica.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateReplica.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_snapshot.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_snapshot.py new file mode 100644 index 000000000000..453a5da70b54 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_snapshot.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-appconfiguration +# USAGE + python configuration_stores_create_snapshot.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AppConfigurationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", + ) + + response = client.snapshots.begin_create( + resource_group_name="myResourceGroup", + config_store_name="contoso", + snapshot_name="mySnapshot", + body={"properties": {"filters": [{"key": "app1/*", "label": "Production"}], "retentionPeriod": 3600}}, + ).result() + print(response) + + +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateSnapshot.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_data_plane_proxy.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_data_plane_proxy.py new file mode 100644 index 000000000000..6f86dd0da5ea --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_data_plane_proxy.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-appconfiguration +# USAGE + python configuration_stores_create_with_data_plane_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AppConfigurationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", + ) + + response = client.configuration_stores.begin_create( + resource_group_name="myResourceGroup", + config_store_name="contoso", + config_store_creation_parameters={ + "location": "westus", + "properties": { + "dataPlaneProxy": {"authenticationMode": "Pass-through", "privateLinkDelegation": "Enabled"} + }, + "sku": {"name": "Standard"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateWithDataPlaneProxy.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_identity.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_identity.py index 3b7fa0e3fd9c..d9dc0718dd43 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_identity.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_identity.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithIdentity.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_local_auth_disabled.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_local_auth_disabled.py index 2dc093741123..c40dd3e6a8d9 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_local_auth_disabled.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_create_with_local_auth_disabled.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -41,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithLocalAuthDisabled.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresCreateWithLocalAuthDisabled.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete.py index 8a5fa3c2ed96..a03c9cf4df75 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", ) - response = client.configuration_stores.begin_delete( + client.configuration_stores.begin_delete( resource_group_name="myResourceGroup", config_store_name="contoso", ).result() - print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDelete.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresDelete.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_key_value.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_key_value.py index 1f156e677861..0118fb2ce469 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_key_value.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_key_value.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", ) - response = client.key_values.begin_delete( + client.key_values.begin_delete( resource_group_name="myResourceGroup", config_store_name="contoso", key_value_name="myKey$myLabel", ).result() - print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteKeyValue.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresDeleteKeyValue.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_private_endpoint_connection.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_private_endpoint_connection.py index 8e7b2c6384f7..91543fa09378 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_private_endpoint_connection.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="myResourceGroup", config_store_name="contoso", private_endpoint_connection_name="myConnection", ).result() - print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeletePrivateEndpointConnection.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresDeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_replica.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_replica.py index e0e6d7485c75..0380287eda3b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_replica.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_delete_replica.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", ) - response = client.replicas.begin_delete( + client.replicas.begin_delete( resource_group_name="myResourceGroup", config_store_name="contoso", replica_name="myReplicaEus", ).result() - print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteReplica.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresDeleteReplica.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get.py index 85b8d3ec524c..64427f1c90e6 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresGet.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_key_value.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_key_value.py index 1220a3d05e69..ff0427a41b86 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_key_value.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_key_value.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetKeyValue.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresGetKeyValue.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_private_endpoint_connection.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_private_endpoint_connection.py index 3ef4142b72da..ceb7ea1aec1b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_private_endpoint_connection.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetPrivateEndpointConnection.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresGetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_replica.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_replica.py index c6160e168a3e..b6e038c2b41e 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_replica.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_replica.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetReplica.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresGetReplica.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_snapshot.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_snapshot.py new file mode 100644 index 000000000000..cbdb99910b96 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_get_snapshot.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-appconfiguration +# USAGE + python configuration_stores_get_snapshot.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AppConfigurationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", + ) + + response = client.snapshots.get( + resource_group_name="myResourceGroup", + config_store_name="contoso", + snapshot_name="mySnapshot", + ) + print(response) + + +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresGetSnapshot.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list.py index 76e9d209f565..a07a5c3e1f7a 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresList.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresList.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_by_resource_group.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_by_resource_group.py index 7a28dae863cb..5399b0a2cf17 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_by_resource_group.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListByResourceGroup.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_keys.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_keys.py index db88205336f3..389c532213e6 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_keys.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListKeys.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresListKeys.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_private_endpoint_connections.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_private_endpoint_connections.py index 0106b7ad9ee2..8eb940ce8ee9 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_private_endpoint_connections.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_private_endpoint_connections.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListPrivateEndpointConnections.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresListPrivateEndpointConnections.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_replicas.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_replicas.py index eb197f1dd7dd..b3002633fce7 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_replicas.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_list_replicas.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListReplicas.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresListReplicas.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_regenerate_key.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_regenerate_key.py index 1c287bb926bd..fd3d2097be1b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_regenerate_key.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_regenerate_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresRegenerateKey.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update.py index 62501ec4ae23..5c6a451203f4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdate.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresUpdate.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_disable_local_auth.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_disable_local_auth.py index 177236714355..9930e12dbd9d 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_disable_local_auth.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_disable_local_auth.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdateDisableLocalAuth.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresUpdateDisableLocalAuth.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_private_endpoint_connection.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_private_endpoint_connection.py index 73f8869a623a..fa8c1344f5b3 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_private_endpoint_connection.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_with_identity.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_with_identity.py index bfa74e003c4d..45572c85d19d 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_with_identity.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/configuration_stores_update_with_identity.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdateWithIdentity.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/ConfigurationStoresUpdateWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_get.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_get.py index 42f52c778fdb..bac951d6e8a0 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_get.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresGet.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/DeletedConfigurationStoresGet.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_list.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_list.py index e632a4de4733..089fa6fb92ba 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_list.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresList.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/DeletedConfigurationStoresList.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_purge.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_purge.py index 18ba402c8963..6256f8dc7bb8 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_purge.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/deleted_configuration_stores_purge.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="c80fb759-c965-4c6a-9110-9b2b2d038882", ) - response = client.configuration_stores.begin_purge_deleted( + client.configuration_stores.begin_purge_deleted( location="westus", config_store_name="contoso", ).result() - print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresPurge.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/DeletedConfigurationStoresPurge.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/operations_list.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/operations_list.py index 0b8c8d793e9d..43fde1ad39ce 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/operations_list.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/OperationsList.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resource_get.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resource_get.py index 08d53356ccc5..d92c99d66733 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resource_get.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resource_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourceGet.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/PrivateLinkResourceGet.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resources_list_by_configuration_store.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resources_list_by_configuration_store.py index 6336f9497500..5b525e105ab4 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resources_list_by_configuration_store.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/private_link_resources_list_by_configuration_store.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourcesListByConfigurationStore.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/PrivateLinkResourcesListByConfigurationStore.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_available.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_available.py index fe494110a646..ee3ea21847b9 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_available.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/RegionalCheckNameAvailable.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/RegionalCheckNameAvailable.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_not_available.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_not_available.py index 4227882a2e4c..788825fbf766 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_not_available.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_samples/regional_check_name_not_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.appconfiguration import AppConfigurationManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/RegionalCheckNameNotAvailable.json +# x-ms-original-file: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2024-05-01/examples/RegionalCheckNameNotAvailable.json if __name__ == "__main__": main() diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/conftest.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/conftest.py new file mode 100644 index 000000000000..bdabbe9c6cc3 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + appconfigurationmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + appconfigurationmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + appconfigurationmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + appconfigurationmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appconfigurationmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appconfigurationmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appconfigurationmanagement_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appconfigurationmanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations.py new file mode 100644 index 000000000000..0db951c273bf --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations.py @@ -0,0 +1,208 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementConfigurationStoresOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.configuration_stores.list( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.configuration_stores.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.configuration_stores.get( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.configuration_stores.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + config_store_creation_parameters={ + "location": "str", + "sku": {"name": "str"}, + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "dataPlaneProxy": {"authenticationMode": "str", "privateLinkDelegation": "str"}, + "disableLocalAuth": False, + "enablePurgeProtection": False, + "encryption": {"keyVaultProperties": {"identityClientId": "str", "keyIdentifier": "str"}}, + "endpoint": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "softDeleteRetentionInDays": 7, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.configuration_stores.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.configuration_stores.begin_update( + resource_group_name=resource_group.name, + config_store_name="str", + config_store_update_parameters={ + "dataPlaneProxy": {"authenticationMode": "str", "privateLinkDelegation": "str"}, + "disableLocalAuth": bool, + "enablePurgeProtection": bool, + "encryption": {"keyVaultProperties": {"identityClientId": "str", "keyIdentifier": "str"}}, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "publicNetworkAccess": "str", + "sku": {"name": "str"}, + "tags": {"str": "str"}, + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_keys(self, resource_group): + response = self.client.configuration_stores.list_keys( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_key(self, resource_group): + response = self.client.configuration_stores.regenerate_key( + resource_group_name=resource_group.name, + config_store_name="str", + regenerate_key_parameters={"id": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_deleted(self, resource_group): + response = self.client.configuration_stores.list_deleted( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_deleted(self, resource_group): + response = self.client.configuration_stores.get_deleted( + location="str", + config_store_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_purge_deleted(self, resource_group): + response = self.client.configuration_stores.begin_purge_deleted( + location="str", + config_store_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations_async.py new file mode 100644 index 000000000000..c8c3648b9e5a --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_configuration_stores_operations_async.py @@ -0,0 +1,217 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementConfigurationStoresOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.configuration_stores.list( + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.configuration_stores.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.configuration_stores.get( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.configuration_stores.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + config_store_creation_parameters={ + "location": "str", + "sku": {"name": "str"}, + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "dataPlaneProxy": {"authenticationMode": "str", "privateLinkDelegation": "str"}, + "disableLocalAuth": False, + "enablePurgeProtection": False, + "encryption": {"keyVaultProperties": {"identityClientId": "str", "keyIdentifier": "str"}}, + "endpoint": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "softDeleteRetentionInDays": 7, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.configuration_stores.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.configuration_stores.begin_update( + resource_group_name=resource_group.name, + config_store_name="str", + config_store_update_parameters={ + "dataPlaneProxy": {"authenticationMode": "str", "privateLinkDelegation": "str"}, + "disableLocalAuth": bool, + "enablePurgeProtection": bool, + "encryption": {"keyVaultProperties": {"identityClientId": "str", "keyIdentifier": "str"}}, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "publicNetworkAccess": "str", + "sku": {"name": "str"}, + "tags": {"str": "str"}, + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_keys(self, resource_group): + response = self.client.configuration_stores.list_keys( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_key(self, resource_group): + response = await self.client.configuration_stores.regenerate_key( + resource_group_name=resource_group.name, + config_store_name="str", + regenerate_key_parameters={"id": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_deleted(self, resource_group): + response = self.client.configuration_stores.list_deleted( + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_deleted(self, resource_group): + response = await self.client.configuration_stores.get_deleted( + location="str", + config_store_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_purge_deleted(self, resource_group): + response = await ( + await self.client.configuration_stores.begin_purge_deleted( + location="str", + config_store_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations.py new file mode 100644 index 000000000000..5895e470f7bb --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementKeyValuesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.key_values.get( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.key_values.create_or_update( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.key_values.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations_async.py new file mode 100644 index 000000000000..1eb96b4c4bbd --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_key_values_operations_async.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementKeyValuesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.key_values.get( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.key_values.create_or_update( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.key_values.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + key_value_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations.py new file mode 100644 index 000000000000..2b1ffafbe83f --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.operations.check_name_availability( + check_name_availability_parameters={"name": "str", "type": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regional_check_name_availability(self, resource_group): + response = self.client.operations.regional_check_name_availability( + location="str", + check_name_availability_parameters={"name": "str", "type": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations_async.py new file mode 100644 index 000000000000..be1e4129defd --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_operations_async.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.operations.check_name_availability( + check_name_availability_parameters={"name": "str", "type": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regional_check_name_availability(self, resource_group): + response = await self.client.operations.regional_check_name_availability( + location="str", + check_name_availability_parameters={"name": "str", "type": "str"}, + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..a96b7081a2a4 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_configuration_store(self, resource_group): + response = self.client.private_endpoint_connections.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..54fad9dc27b6 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_configuration_store(self, resource_group): + response = self.client.private_endpoint_connections.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations.py new file mode 100644 index 000000000000..c61abd261446 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_configuration_store(self, resource_group): + response = self.client.private_link_resources.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + config_store_name="str", + group_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..376a859f0bf2 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_configuration_store(self, resource_group): + response = self.client.private_link_resources.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + config_store_name="str", + group_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations.py new file mode 100644 index 000000000000..1e31ba8b6726 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementReplicasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_configuration_store(self, resource_group): + response = self.client.replicas.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.replicas.get( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.replicas.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + replica_creation_parameters={ + "endpoint": "str", + "id": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.replicas.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations_async.py new file mode 100644 index 000000000000..5b14ed3bf6fe --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_replicas_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementReplicasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_configuration_store(self, resource_group): + response = self.client.replicas.list_by_configuration_store( + resource_group_name=resource_group.name, + config_store_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.replicas.get( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.replicas.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + replica_creation_parameters={ + "endpoint": "str", + "id": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.replicas.begin_delete( + resource_group_name=resource_group.name, + config_store_name="str", + replica_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations.py new file mode 100644 index 000000000000..ac4f203d5c96 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementSnapshotsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.snapshots.get( + resource_group_name=resource_group.name, + config_store_name="str", + snapshot_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.snapshots.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + snapshot_name="str", + body={ + "compositionType": "str", + "created": "2020-02-20 00:00:00", + "etag": "str", + "expires": "2020-02-20 00:00:00", + "filters": [{"key": "str", "label": "str"}], + "id": "str", + "itemsCount": 0, + "name": "str", + "provisioningState": "str", + "retentionPeriod": 0, + "size": 0, + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations_async.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations_async.py new file mode 100644 index 000000000000..ea9c83b2aa92 --- /dev/null +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/generated_tests/test_app_configuration_management_snapshots_operations_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppConfigurationManagementSnapshotsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppConfigurationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.snapshots.get( + resource_group_name=resource_group.name, + config_store_name="str", + snapshot_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.snapshots.begin_create( + resource_group_name=resource_group.name, + config_store_name="str", + snapshot_name="str", + body={ + "compositionType": "str", + "created": "2020-02-20 00:00:00", + "etag": "str", + "expires": "2020-02-20 00:00:00", + "filters": [{"key": "str", "label": "str"}], + "id": "str", + "itemsCount": 0, + "name": "str", + "provisioningState": "str", + "retentionPeriod": 0, + "size": 0, + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-mgmt-appconfiguration/setup.py b/sdk/appconfiguration/azure-mgmt-appconfiguration/setup.py index e16e5fa240c3..c44dd5169f9b 100644 --- a/sdk/appconfiguration/azure-mgmt-appconfiguration/setup.py +++ b/sdk/appconfiguration/azure-mgmt-appconfiguration/setup.py @@ -22,11 +22,9 @@ # Version extraction inspired from 'requests' with open( - ( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py") - ), + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), "r", ) as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -55,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -76,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )