diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml index df5122f83d4b..1ace8b669a20 100644 --- a/eng/.docsettings.yml +++ b/eng/.docsettings.yml @@ -108,6 +108,7 @@ known_content_issues: - ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554'] - ['sdk/media/azure-media-nspkg/README.md', '#4554'] - ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554'] + - ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554'] # nspckg and common. - ['sdk/appconfiguration/azure-appconfiguration/README.md', 'nspkg and common'] diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index daef42e6abdf..379b83e64d8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -12,6 +12,7 @@ DistributedTracingPolicy, HttpLoggingPolicy, BearerTokenCredentialPolicy, + ContentDecodePolicy, ) from azure.core.tracing.decorator import distributed_trace from azure.core.pipeline.transport import RequestsTransport @@ -25,7 +26,6 @@ ) from ._azure_appconfiguration_error import ResourceReadOnlyError from ._generated import AzureAppConfiguration -from ._generated.models import ErrorException from ._generated._configuration import AzureAppConfigurationConfiguration from ._models import ConfigurationSetting from ._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy @@ -74,8 +74,10 @@ def __init__(self, base_url, credential, **kwargs): if not credential: raise ValueError("Missing credential") + self._credential_scopes = base_url.strip("/") + "/.default" + self._config = AzureAppConfigurationConfiguration( - credential, base_url, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -94,7 +96,7 @@ def __init__(self, base_url, credential, **kwargs): ) self._impl = AzureAppConfiguration( - credentials=credential, endpoint=base_url, pipeline=pipeline + credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes ) @classmethod @@ -151,6 +153,7 @@ def _create_appconfig_pipeline( self._config.logging_policy, # HTTP request/response log DistributedTracingPolicy(**kwargs), HttpLoggingPolicy(**kwargs), + ContentDecodePolicy(**kwargs), ] if not transport: @@ -213,8 +216,9 @@ def list_configuration_settings( error_map=error_map, **kwargs ) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -274,8 +278,9 @@ def get_configuration_setting( return ConfigurationSetting._from_generated(key_value) except ResourceNotModifiedError: return None - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -322,8 +327,9 @@ def add_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_added) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -388,8 +394,9 @@ def set_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_set) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -443,8 +450,9 @@ def delete_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_deleted) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -503,8 +511,9 @@ def list_revisions( error_map=error_map, **kwargs ) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -572,8 +581,9 @@ def set_read_only( **kwargs ) return ConfigurationSetting._from_generated(key_value) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py index 79273adcd80a..763d10cac09f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py @@ -1,14 +1,16 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._azure_app_configuration import AzureAppConfiguration __all__ = ['AzureAppConfiguration'] -from .version import VERSION - -__version__ = VERSION - +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py index b507a7de4aee..6df47ca6ad0e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py @@ -1,12 +1,22 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + from azure.core import PipelineClient -from msrest import Serializer, Deserializer +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import AzureAppConfigurationConfiguration from .operations import AzureAppConfigurationOperationsMixin @@ -14,35 +24,61 @@ class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): - """AzureAppConfiguration + """AzureAppConfiguration. - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param endpoint: The endpoint of the App Configuration instance to send - requests to. + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. :type endpoint: str - :param sync_token: Used to guarantee real-time consistency between - requests. + :param sync_token: Used to guarantee real-time consistency between requests. :type sync_token: str """ def __init__( - self, credentials, endpoint, sync_token=None, **kwargs): - + self, + credential, # type: "TokenCredential" + endpoint, # type: str + sync_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None base_url = '{endpoint}' - self._config = AzureAppConfigurationConfiguration(credentials, endpoint, sync_token, **kwargs) + self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '1.0' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + def __enter__(self): + # type: () -> AzureAppConfiguration self._client.__enter__() return self + def __exit__(self, *exc_details): + # type: (Any) -> None self._client.__exit__(*exc_details) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py index 4218ab93ee68..2d9bf0a0f9a2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py @@ -1,53 +1,75 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + from azure.core.configuration import Configuration from azure.core.pipeline import policies -from .version import VERSION +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential +VERSION = "unknown" class AzureAppConfigurationConfiguration(Configuration): - """Configuration for AzureAppConfiguration + """Configuration for AzureAppConfiguration. + Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param endpoint: The endpoint of the App Configuration instance to send - requests to. + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. :type endpoint: str - :param sync_token: Used to guarantee real-time consistency between - requests. + :param sync_token: Used to guarantee real-time consistency between requests. :type sync_token: str """ - def __init__(self, credentials, endpoint, sync_token=None, **kwargs): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + def __init__( + self, + credential, # type: "TokenCredential" + endpoint, # type: str + sync_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(AzureAppConfigurationConfiguration, self).__init__(**kwargs) - self._configure(**kwargs) - self.user_agent_policy.add_user_agent('azsdk-python-azureappconfiguration/{}'.format(VERSION)) - self.generate_client_request_id = True - - self.credentials = credentials + self.credential = credential self.endpoint = endpoint self.sync_token = sync_token + self.api_version = "1.0" + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'appconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) - def _configure(self, **kwargs): + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**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 not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py index 5495220b817e..ffb4352ce53c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py @@ -1,9 +1,10 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._azure_app_configuration_async import AzureAppConfiguration +from ._azure_app_configuration import AzureAppConfiguration __all__ = ['AzureAppConfiguration'] diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py new file mode 100644 index 000000000000..eb52b6077a51 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py @@ -0,0 +1,77 @@ +# 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, Optional, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import AzureAppConfigurationConfiguration +from .operations import AzureAppConfigurationOperationsMixin +from .. import models + + +class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): + """AzureAppConfiguration. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + endpoint: str, + sync_token: Optional[str] = None, + **kwargs: Any + ) -> None: + base_url = '{endpoint}' + self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureAppConfiguration": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration_async.py deleted file mode 100644 index baecf707f2e6..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration_async.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from azure.core import AsyncPipelineClient -from msrest import Serializer, Deserializer - -from ._configuration_async import AzureAppConfigurationConfiguration -from .operations_async import AzureAppConfigurationOperationsMixin -from .. import models - - -class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): - """AzureAppConfiguration - - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param endpoint: The endpoint of the App Configuration instance to send - requests to. - :type endpoint: str - :param sync_token: Used to guarantee real-time consistency between - requests. - :type sync_token: str - """ - - def __init__( - self, credentials, endpoint, sync_token=None, **kwargs): - - base_url = '{endpoint}' - self._config = AzureAppConfigurationConfiguration(credentials, endpoint, sync_token, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '1.0' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - - 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-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py new file mode 100644 index 000000000000..fcfc05e38d35 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py @@ -0,0 +1,71 @@ +# 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, Optional, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class AzureAppConfigurationConfiguration(Configuration): + """Configuration for AzureAppConfiguration. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + endpoint: str, + sync_token: Optional[str] = None, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(AzureAppConfigurationConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.endpoint = endpoint + self.sync_token = sync_token + self.api_version = "1.0" + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'appconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**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 not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration_async.py deleted file mode 100644 index eb72f52b17da..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -from ..version import VERSION - - -class AzureAppConfigurationConfiguration(Configuration): - """Configuration for AzureAppConfiguration - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param endpoint: The endpoint of the App Configuration instance to send - requests to. - :type endpoint: str - :param sync_token: Used to guarantee real-time consistency between - requests. - :type sync_token: str - """ - - def __init__(self, credentials, endpoint, sync_token=None, **kwargs): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - - super(AzureAppConfigurationConfiguration, self).__init__(**kwargs) - self._configure(**kwargs) - - self.user_agent_policy.add_user_agent('azsdk-python-azureappconfiguration/{}'.format(VERSION)) - self.generate_client_request_id = True - - self.credentials = credentials - self.endpoint = endpoint - self.sync_token = sync_token - - def _configure(self, **kwargs): - 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.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) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/__init__.py similarity index 57% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/__init__.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/__init__.py index d8343a0207c9..b3314598b704 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/__init__.py @@ -1,11 +1,12 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._azure_app_configuration_operations_async import AzureAppConfigurationOperationsMixin +from ._azure_app_configuration_operations import AzureAppConfigurationOperationsMixin __all__ = [ 'AzureAppConfigurationOperationsMixin', diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/_azure_app_configuration_operations.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/_azure_app_configuration_operations.py new file mode 100644 index 000000000000..d898efd4c7a3 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations/_azure_app_configuration_operations.py @@ -0,0 +1,1218 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureAppConfigurationOperationsMixin: + + def get_keys( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_models.KeyListResult"]: + """Gets a list of keys. + + Gets a list of keys. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.keyset+json, application/json, application/problem+json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.get_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_keys.metadata = {'url': '/keys'} # type: ignore + + async def check_keys( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_keys.metadata = {'url': '/keys'} # type: ignore + + def get_key_values( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "_models.Get6ItemsItem"]]] = None, + **kwargs + ) -> AsyncIterable["_models.KeyValueListResult"]: + """Gets a list of key-values. + + Gets a list of key-values. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Get6ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValueListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.get_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_key_values.metadata = {'url': '/kv'} # type: ignore + + async def check_key_values( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "_models.Head6ItemsItem"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Head6ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_values.metadata = {'url': '/kv'} # type: ignore + + async def get_key_value( + self, + key: str, + label: Optional[str] = None, + accept_datetime: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + select: Optional[List[Union[str, "_models.Get7ItemsItem"]]] = None, + **kwargs + ) -> "_models.KeyValue": + """Gets a single key-value. + + Gets a single key-value. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Get7ItemsItem] + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + + # Construct URL + url = self.get_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def put_key_value( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + entity: Optional["_models.KeyValue"] = None, + **kwargs + ) -> "_models.KeyValue": + """Creates a key-value. + + Creates a key-value. + + :param key: The key of the key-value to create. + :type key: str + :param label: The label of the key-value to create. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param entity: The key-value to create. + :type entity: ~azure.appconfiguration.models.KeyValue + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + content_type = kwargs.pop("content_type", "application/vnd.microsoft.appconfig.kv+json") + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + + # Construct URL + url = self.put_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if entity is not None: + body_content = self._serialize.body(entity, 'KeyValue') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def delete_key_value( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + **kwargs + ) -> Optional["_models.KeyValue"]: + """Deletes a key-value. + + Deletes a key-value. + + :param key: The key of the key-value to delete. + :type key: str + :param label: The label of the key-value to delete. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: 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.appconfiguration.models.KeyValue or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.KeyValue"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + + # Construct URL + url = self.delete_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if response.status_code == 204: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def check_key_value( + self, + key: str, + label: Optional[str] = None, + accept_datetime: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + select: Optional[List[Union[str, "_models.Head7ItemsItem"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Head7ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def get_labels( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[str]] = None, + **kwargs + ) -> AsyncIterable["_models.LabelListResult"]: + """Gets a list of labels. + + Gets a list of labels. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabelListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.LabelListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabelListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.labelset+json, application/json, application/problem+json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.get_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LabelListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_labels.metadata = {'url': '/labels'} # type: ignore + + async def check_labels( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[str]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_labels.metadata = {'url': '/labels'} # type: ignore + + async def put_lock( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_models.KeyValue": + """Locks a key-value. + + Locks a key-value. + + :param key: The key of the key-value to lock. + :type key: str + :param label: The label, if any, of the key-value to lock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: 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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + + # Construct URL + url = self.put_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + async def delete_lock( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_models.KeyValue": + """Unlocks a key-value. + + Unlocks a key-value. + + :param key: The key of the key-value to unlock. + :type key: str + :param label: The label, if any, of the key-value to unlock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: 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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + + # Construct URL + url = self.delete_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + def get_revisions( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "_models.Enum4"]]] = None, + **kwargs + ) -> AsyncIterable["_models.KeyValueListResult"]: + """Gets a list of key-value revisions. + + Gets a list of key-value revisions. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Enum4] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValueListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.get_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_revisions.metadata = {'url': '/revisions'} # type: ignore + + async def check_revisions( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "_models.Enum5"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Enum5] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_revisions.metadata = {'url': '/revisions'} # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/_azure_app_configuration_operations_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/_azure_app_configuration_operations_async.py deleted file mode 100644 index 25227616d7c1..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/operations_async/_azure_app_configuration_operations_async.py +++ /dev/null @@ -1,1056 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError, map_error -from azure.core.async_paging import AsyncItemPaged, AsyncList -from ... import models -import uuid - - -class AzureAppConfigurationOperationsMixin: - - def get_keys( - self, name=None, after=None, accept_datetime=None, *, cls=None, **kwargs): - """Gets a list of keys. - - :param name: A filter for the name of the returned keys. - :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :return: An iterator like instance of Key - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~appconfiguration.models.Key] - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - def prepare_request(next_link=None): - query_parameters = {} - if not next_link: - # Construct URL - url = self.get_keys.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - - else: - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.keyset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data_async(response): - deserialized = self._deserialize('KeyListResult', response) - list_of_elem = deserialized.items - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) - - async def get_next_async(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response - - # Deserialize response - return AsyncItemPaged( - get_next_async, extract_data_async - ) - get_keys.metadata = {'url': '/keys'} - - async def check_keys(self, name=None, after=None, accept_datetime=None, *, cls=None, **kwargs): - """Requests the headers and status of the given resource. - - :param name: A filter for the name of the returned keys. - :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) - :rtype: None - :raises: - :class:`HttpResponseError` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.check_keys.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - - # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_keys.metadata = {'url': '/keys'} - - def get_key_values( - self, key=None, label=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Gets a list of key-values. - - :param key: A filter used to match keys. - :type key: str - :param label: A filter used to match labels - :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :return: An iterator like instance of KeyValue - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~appconfiguration.models.KeyValue] - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - def prepare_request(next_link=None): - query_parameters = {} - if not next_link: - # Construct URL - url = self.get_key_values.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - if key is not None: - query_parameters['key'] = self._serialize.query("key", key, 'str') - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - else: - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kvset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data_async(response): - deserialized = self._deserialize('KeyValueListResult', response) - list_of_elem = deserialized.items - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) - - async def get_next_async(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response - - # Deserialize response - return AsyncItemPaged( - get_next_async, extract_data_async - ) - get_key_values.metadata = {'url': '/kv'} - - async def check_key_values(self, key=None, label=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Requests the headers and status of the given resource. - - :param key: A filter used to match keys. - :type key: str - :param label: A filter used to match labels - :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) - :rtype: None - :raises: - :class:`HttpResponseError` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.check_key_values.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if key is not None: - query_parameters['key'] = self._serialize.query("key", key, 'str') - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_key_values.metadata = {'url': '/kv'} - - async def get_key_value(self, key, label=None, accept_datetime=None, if_match=None, if_none_match=None, select=None, *, cls=None, **kwargs): - """Gets a single key-value. - - :param key: The key of the key-value to retrieve. - :type key: str - :param label: The label of the key-value to retrieve. - :type label: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. - :type if_none_match: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.get_key_value.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - 'Last-Modified': self._deserialize('str', response.headers.get('Last-Modified')), - } - - if cls: - return cls(response, deserialized, header_dict) - - return deserialized - get_key_value.metadata = {'url': '/kv/{key}'} - - async def put_key_value(self, key, label=None, entity=None, if_match=None, if_none_match=None, *, cls=None, **kwargs): - """Creates a key-value. - - :param key: The key of the key-value to create. - :type key: str - :param label: The label of the key-value to create. - :type label: str - :param entity: The key-value to create. - :type entity: ~appconfiguration.models.KeyValue - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. - :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.put_key_value.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - - # Construct body - if entity is not None: - body_content = self._serialize.body(entity, 'KeyValue') - else: - body_content = None - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } - - if cls: - return cls(response, deserialized, header_dict) - - return deserialized - put_key_value.metadata = {'url': '/kv/{key}'} - - async def delete_key_value(self, key, label=None, if_match=None, *, cls=None, **kwargs): - """Deletes a key-value. - - :param key: The key of the key-value to delete. - :type key: str - :param label: The label of the key-value to delete. - :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.delete_key_value.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } - - if cls: - return cls(response, deserialized, header_dict) - - return deserialized - delete_key_value.metadata = {'url': '/kv/{key}'} - - async def check_key_value(self, key, label=None, accept_datetime=None, if_match=None, if_none_match=None, select=None, *, cls=None, **kwargs): - """Requests the headers and status of the given resource. - - :param key: The key of the key-value to retrieve. - :type key: str - :param label: The label of the key-value to retrieve. - :type label: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. - :type if_none_match: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) - :rtype: None - :raises: - :class:`HttpResponseError` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.check_key_value.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - 'Last-Modified': self._deserialize('str', response.headers.get('Last-Modified')), - } - return cls(response, None, response_headers) - check_key_value.metadata = {'url': '/kv/{key}'} - - def get_labels( - self, name=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Gets a list of labels. - - :param name: A filter for the name of the returned labels. - :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :return: An iterator like instance of Label - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~appconfiguration.models.Label] - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - def prepare_request(next_link=None): - query_parameters = {} - if not next_link: - # Construct URL - url = self.get_labels.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - else: - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.labelset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data_async(response): - deserialized = self._deserialize('LabelListResult', response) - list_of_elem = deserialized.items - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) - - async def get_next_async(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response - - # Deserialize response - return AsyncItemPaged( - get_next_async, extract_data_async - ) - get_labels.metadata = {'url': '/labels'} - - async def check_labels(self, name=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Requests the headers and status of the given resource. - - :param name: A filter for the name of the returned labels. - :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) - :rtype: None - :raises: - :class:`HttpResponseError` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.check_labels.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_labels.metadata = {'url': '/labels'} - - async def put_lock(self, key, label=None, if_match=None, if_none_match=None, *, cls=None, **kwargs): - """Locks a key-value. - - :param key: The key of the key-value to lock. - :type key: str - :param label: The label, if any, of the key-value to lock. - :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. - :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.put_lock.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } - - if cls: - return cls(response, deserialized, header_dict) - - return deserialized - put_lock.metadata = {'url': '/locks/{key}'} - - async def delete_lock(self, key, label=None, if_match=None, if_none_match=None, *, cls=None, **kwargs): - """Unlocks a key-value. - - :param key: The key of the key-value to unlock. - :type key: str - :param label: The label, if any, of the key-value to unlock. - :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. - :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. - :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.delete_lock.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } - - if cls: - return cls(response, deserialized, header_dict) - - return deserialized - delete_lock.metadata = {'url': '/locks/{key}'} - - def get_revisions( - self, key=None, label=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Gets a list of key-value revisions. - - :param key: A filter used to match keys. - :type key: str - :param label: A filter used to match labels - :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :return: An iterator like instance of KeyValue - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~appconfiguration.models.KeyValue] - :raises: - :class:`ErrorException` - """ - error_map = kwargs.pop('error_map', None) - def prepare_request(next_link=None): - query_parameters = {} - if not next_link: - # Construct URL - url = self.get_revisions.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - if key is not None: - query_parameters['key'] = self._serialize.query("key", key, 'str') - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - else: - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kvset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data_async(response): - deserialized = self._deserialize('KeyValueListResult', response) - list_of_elem = deserialized.items - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) - - async def get_next_async(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response - - # Deserialize response - return AsyncItemPaged( - get_next_async, extract_data_async - ) - get_revisions.metadata = {'url': '/revisions'} - - async def check_revisions(self, key=None, label=None, after=None, accept_datetime=None, select=None, *, cls=None, **kwargs): - """Requests the headers and status of the given resource. - - :param key: A filter used to match keys. - :type key: str - :param label: A filter used to match labels - :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. - :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. - :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) - :rtype: None - :raises: - :class:`HttpResponseError` - """ - error_map = kwargs.pop('error_map', None) - # Construct URL - url = self.check_revisions.metadata['url'] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if key is not None: - query_parameters['key'] = self._serialize.query("key", key, 'str') - if label is not None: - query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if after is not None: - query_parameters['After'] = self._serialize.query("after", after, 'str') - if select is not None: - query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') - - # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_revisions.metadata = {'url': '/revisions'} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py index b7af00880ff2..b86a8beb23e0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py @@ -1,12 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import Error, ErrorException + from ._models_py3 import Error from ._models_py3 import Key from ._models_py3 import KeyListResult from ._models_py3 import KeyValue @@ -14,20 +15,35 @@ from ._models_py3 import Label from ._models_py3 import LabelListResult except (SyntaxError, ImportError): - from ._models import Error, ErrorException - from ._models import Key - from ._models import KeyListResult - from ._models import KeyValue - from ._models import KeyValueListResult - from ._models import Label - from ._models import LabelListResult + from ._models import Error # type: ignore + from ._models import Key # type: ignore + from ._models import KeyListResult # type: ignore + from ._models import KeyValue # type: ignore + from ._models import KeyValueListResult # type: ignore + from ._models import Label # type: ignore + from ._models import LabelListResult # type: ignore + +from ._azure_app_configuration_enums import ( + Enum4, + Enum5, + Get6ItemsItem, + Get7ItemsItem, + Head6ItemsItem, + Head7ItemsItem, +) __all__ = [ - 'Error', 'ErrorException', + 'Error', 'Key', 'KeyListResult', 'KeyValue', 'KeyValueListResult', 'Label', 'LabelListResult', + 'Enum4', + 'Enum5', + 'Get6ItemsItem', + 'Get7ItemsItem', + 'Head6ItemsItem', + 'Head7ItemsItem', ] diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_azure_app_configuration_enums.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_azure_app_configuration_enums.py new file mode 100644 index 000000000000..5b0a9cfebb61 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_azure_app_configuration_enums.py @@ -0,0 +1,93 @@ +# 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class Enum4(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" + +class Enum5(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" + +class Get6ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" + +class Get7ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" + +class Head6ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" + +class Head7ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py index 80ff44d7f381..c81714c27403 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py @@ -1,15 +1,16 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Error(Model): +class Error(msrest.serialization.Model): """Azure App Configuration error object. :param type: The type of the error. @@ -32,7 +33,10 @@ class Error(Model): 'status': {'key': 'status', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Error, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.title = kwargs.get('title', None) @@ -41,27 +45,10 @@ def __init__(self, **kwargs): self.status = kwargs.get('status', None) -class ErrorException(HttpResponseError): - """Server responsed with exception of type: 'Error'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, response, deserialize, *args): - - model_name = 'Error' - self.error = deserialize(model_name, response) - if self.error is None: - self.error = deserialize.dependencies[model_name]() - super(ErrorException, self).__init__(response=response) - - -class Key(Model): +class Key(msrest.serialization.Model): """Key. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: :vartype name: str @@ -75,18 +62,20 @@ class Key(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Key, self).__init__(**kwargs) self.name = None -class KeyListResult(Model): +class KeyListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.Key] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.Key] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -95,13 +84,16 @@ class KeyListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(KeyListResult, self).__init__(**kwargs) self.items = kwargs.get('items', None) self.next_link = kwargs.get('next_link', None) -class KeyValue(Model): +class KeyValue(msrest.serialization.Model): """KeyValue. :param key: @@ -113,8 +105,8 @@ class KeyValue(Model): :param value: :type value: str :param last_modified: - :type last_modified: datetime - :param tags: + :type last_modified: ~datetime.datetime + :param tags: A set of tags. Dictionary of :code:``. :type tags: dict[str, str] :param locked: :type locked: bool @@ -133,7 +125,10 @@ class KeyValue(Model): 'etag': {'key': 'etag', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(KeyValue, self).__init__(**kwargs) self.key = kwargs.get('key', None) self.label = kwargs.get('label', None) @@ -145,13 +140,12 @@ def __init__(self, **kwargs): self.etag = kwargs.get('etag', None) -class KeyValueListResult(Model): +class KeyValueListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.KeyValue] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.KeyValue] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -160,17 +154,19 @@ class KeyValueListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(KeyValueListResult, self).__init__(**kwargs) self.items = kwargs.get('items', None) self.next_link = kwargs.get('next_link', None) -class Label(Model): +class Label(msrest.serialization.Model): """Label. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: :vartype name: str @@ -184,18 +180,20 @@ class Label(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Label, self).__init__(**kwargs) self.name = None -class LabelListResult(Model): +class LabelListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.Label] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.Label] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -204,7 +202,10 @@ class LabelListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(LabelListResult, self).__init__(**kwargs) self.items = kwargs.get('items', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models_py3.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models_py3.py index 429e897d2993..9eff36631ac6 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models_py3.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models_py3.py @@ -1,15 +1,19 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import datetime +from typing import Dict, List, Optional + from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Error(Model): +class Error(msrest.serialization.Model): """Azure App Configuration error object. :param type: The type of the error. @@ -32,7 +36,16 @@ class Error(Model): 'status': {'key': 'status', 'type': 'int'}, } - def __init__(self, *, type: str=None, title: str=None, name: str=None, detail: str=None, status: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + title: Optional[str] = None, + name: Optional[str] = None, + detail: Optional[str] = None, + status: Optional[int] = None, + **kwargs + ): super(Error, self).__init__(**kwargs) self.type = type self.title = title @@ -41,27 +54,10 @@ def __init__(self, *, type: str=None, title: str=None, name: str=None, detail: s self.status = status -class ErrorException(HttpResponseError): - """Server responsed with exception of type: 'Error'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, response, deserialize, *args): - - model_name = 'Error' - self.error = deserialize(model_name, response) - if self.error is None: - self.error = deserialize.dependencies[model_name]() - super(ErrorException, self).__init__(response=response) - - -class Key(Model): +class Key(msrest.serialization.Model): """Key. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: :vartype name: str @@ -75,18 +71,20 @@ class Key(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Key, self).__init__(**kwargs) self.name = None -class KeyListResult(Model): +class KeyListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.Key] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.Key] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -95,13 +93,19 @@ class KeyListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, *, items=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + items: Optional[List["Key"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(KeyListResult, self).__init__(**kwargs) self.items = items self.next_link = next_link -class KeyValue(Model): +class KeyValue(msrest.serialization.Model): """KeyValue. :param key: @@ -113,8 +117,8 @@ class KeyValue(Model): :param value: :type value: str :param last_modified: - :type last_modified: datetime - :param tags: + :type last_modified: ~datetime.datetime + :param tags: A set of tags. Dictionary of :code:``. :type tags: dict[str, str] :param locked: :type locked: bool @@ -133,7 +137,19 @@ class KeyValue(Model): 'etag': {'key': 'etag', 'type': 'str'}, } - def __init__(self, *, key: str=None, label: str=None, content_type: str=None, value: str=None, last_modified=None, tags=None, locked: bool=None, etag: str=None, **kwargs) -> None: + def __init__( + self, + *, + key: Optional[str] = None, + label: Optional[str] = None, + content_type: Optional[str] = None, + value: Optional[str] = None, + last_modified: Optional[datetime.datetime] = None, + tags: Optional[Dict[str, str]] = None, + locked: Optional[bool] = None, + etag: Optional[str] = None, + **kwargs + ): super(KeyValue, self).__init__(**kwargs) self.key = key self.label = label @@ -145,13 +161,12 @@ def __init__(self, *, key: str=None, label: str=None, content_type: str=None, va self.etag = etag -class KeyValueListResult(Model): +class KeyValueListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.KeyValue] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.KeyValue] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -160,17 +175,22 @@ class KeyValueListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, *, items=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + items: Optional[List["KeyValue"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(KeyValueListResult, self).__init__(**kwargs) self.items = items self.next_link = next_link -class Label(Model): +class Label(msrest.serialization.Model): """Label. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: :vartype name: str @@ -184,18 +204,20 @@ class Label(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Label, self).__init__(**kwargs) self.name = None -class LabelListResult(Model): +class LabelListResult(msrest.serialization.Model): """The result of a list request. :param items: The collection value. - :type items: list[~appconfiguration.models.Label] - :param next_link: The URI that can be used to request the next set of - paged results. + :type items: list[~azure.appconfiguration.models.Label] + :param next_link: The URI that can be used to request the next set of paged results. :type next_link: str """ @@ -204,7 +226,13 @@ class LabelListResult(Model): 'next_link': {'key': '@nextLink', 'type': 'str'}, } - def __init__(self, *, items=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + items: Optional[List["Label"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(LabelListResult, self).__init__(**kwargs) self.items = items self.next_link = next_link diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/__init__.py index 8604c057c7fe..b3314598b704 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/__init__.py @@ -1,8 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._azure_app_configuration_operations import AzureAppConfigurationOperationsMixin diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/_azure_app_configuration_operations.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/_azure_app_configuration_operations.py index 88777a903317..f4345267a482 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/_azure_app_configuration_operations.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/operations/_azure_app_configuration_operations.py @@ -1,140 +1,176 @@ # 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -from azure.core.exceptions import HttpResponseError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged -from .. import models -import uuid +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class AzureAppConfigurationOperationsMixin(object): def get_keys( - self, name=None, after=None, accept_datetime=None, cls=None, **kwargs): + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.KeyListResult"] """Gets a list of keys. + Gets a list of keys. + :param name: A filter for the name of the returned keys. :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :return: An iterator like instance of Key - :rtype: ~azure.core.paging.ItemPaged[~appconfiguration.models.Key] - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.keyset+json, application/json, application/problem+json" + def prepare_request(next_link=None): - query_parameters = {} + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.get_keys.metadata['url'] + url = self.get_keys.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] if name is not None: query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: + url = next_link + query_parameters = {} # type: Dict[str, Any] path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.keyset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) return request - def extract_data(response): - deserialized = self._deserialize('KeyListResult', response) + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyListResult', pipeline_response) list_of_elem = deserialized.items if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response + raise HttpResponseError(response=response, model=error) + + return pipeline_response - # Deserialize response return ItemPaged( get_next, extract_data ) - get_keys.metadata = {'url': '/keys'} - - def check_keys(self, name=None, after=None, accept_datetime=None, cls=None, **kwargs): + get_keys.metadata = {'url': '/keys'} # type: ignore + + def check_keys( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None """Requests the headers and status of the given resource. + Requests the headers and status of the given resource. + :param name: A filter for the name of the returned keys. :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) :rtype: None - :raises: - :class:`HttpResponseError` + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + # Construct URL - url = self.check_keys.metadata['url'] + url = self.check_keys.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if name is not None: query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - # Construct and send request request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -143,154 +179,181 @@ def check_keys(self, name=None, after=None, accept_datetime=None, cls=None, **kw map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_keys.metadata = {'url': '/keys'} + return cls(pipeline_response, None, response_headers) + + check_keys.metadata = {'url': '/keys'} # type: ignore def get_key_values( - self, key=None, label=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Get6ItemsItem"]]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.KeyValueListResult"] """Gets a list of key-values. + Gets a list of key-values. + :param key: A filter used to match keys. :type key: str - :param label: A filter used to match labels + :param label: A filter used to match labels. :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :return: An iterator like instance of KeyValue - :rtype: - ~azure.core.paging.ItemPaged[~appconfiguration.models.KeyValue] - :raises: - :class:`ErrorException` + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Get6ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValueListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json" + def prepare_request(next_link=None): - query_parameters = {} + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.get_key_values.metadata['url'] + url = self.get_key_values.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] if key is not None: query_parameters['key'] = self._serialize.query("key", key, 'str') if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + request = self._client.get(url, query_parameters, header_parameters) else: + url = next_link + query_parameters = {} # type: Dict[str, Any] path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kvset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) return request - def extract_data(response): - deserialized = self._deserialize('KeyValueListResult', response) + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) list_of_elem = deserialized.items if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response + raise HttpResponseError(response=response, model=error) + + return pipeline_response - # Deserialize response return ItemPaged( get_next, extract_data ) - get_key_values.metadata = {'url': '/kv'} - - def check_key_values(self, key=None, label=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + get_key_values.metadata = {'url': '/kv'} # type: ignore + + def check_key_values( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Head6ItemsItem"]]] + **kwargs # type: Any + ): + # type: (...) -> None """Requests the headers and status of the given resource. + Requests the headers and status of the given resource. + :param key: A filter used to match keys. :type key: str - :param label: A filter used to match labels + :param label: A filter used to match labels. :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Head6ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) :rtype: None - :raises: - :class:`HttpResponseError` + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + # Construct URL - url = self.check_key_values.metadata['url'] + url = self.check_key_values.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if key is not None: query_parameters['key'] = self._serialize.query("key", key, 'str') if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - # Construct and send request request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -299,61 +362,75 @@ def check_key_values(self, key=None, label=None, after=None, accept_datetime=Non map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_key_values.metadata = {'url': '/kv'} + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) - def get_key_value(self, key, label=None, accept_datetime=None, if_match=None, if_none_match=None, select=None, cls=None, **kwargs): + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_values.metadata = {'url': '/kv'} # type: ignore + + def get_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Get7ItemsItem"]]] + **kwargs # type: Any + ): + # type: (...) -> "_models.KeyValue" """Gets a single key-value. + Gets a single key-value. + :param key: The key of the key-value to retrieve. :type key: str :param label: The label of the key-value to retrieve. :type label: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. :type if_none_match: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Get7ItemsItem] + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + # Construct URL - url = self.get_key_value.metadata['url'] + url = self.get_key_value.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: @@ -362,225 +439,259 @@ def get_key_value(self, key, label=None, accept_datetime=None, if_match=None, if header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - 'Last-Modified': self._deserialize('str', response.headers.get('Last-Modified')), - } + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + deserialized = self._deserialize('KeyValue', pipeline_response) if cls: - return cls(response, deserialized, header_dict) + return cls(pipeline_response, deserialized, response_headers) return deserialized - get_key_value.metadata = {'url': '/kv/{key}'} - - def put_key_value(self, key, label=None, entity=None, if_match=None, if_none_match=None, cls=None, **kwargs): + get_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def put_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + entity=None, # type: Optional["_models.KeyValue"] + **kwargs # type: Any + ): + # type: (...) -> "_models.KeyValue" """Creates a key-value. + Creates a key-value. + :param key: The key of the key-value to create. :type key: str :param label: The label of the key-value to create. :type label: str - :param entity: The key-value to create. - :type entity: ~appconfiguration.models.KeyValue - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` + :param entity: The key-value to create. + :type entity: ~azure.appconfiguration.models.KeyValue + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + content_type = kwargs.pop("content_type", "application/vnd.microsoft.appconfig.kv+json") + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + # Construct URL - url = self.put_key_value.metadata['url'] + url = self.put_key_value.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] if entity is not None: body_content = self._serialize.body(entity, 'KeyValue') else: body_content = None - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) if cls: - return cls(response, deserialized, header_dict) + return cls(pipeline_response, deserialized, response_headers) return deserialized - put_key_value.metadata = {'url': '/kv/{key}'} - - def delete_key_value(self, key, label=None, if_match=None, cls=None, **kwargs): + put_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def delete_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.KeyValue"] """Deletes a key-value. + Deletes a key-value. + :param key: The key of the key-value to delete. :type key: str :param label: The label of the key-value to delete. :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` + :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.appconfiguration.models.KeyValue or None + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.KeyValue"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + # Construct URL - url = self.delete_key_value.metadata['url'] + url = self.delete_key_value.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) - header_dict = {} + response_headers = {} deserialized = None if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if response.status_code == 204: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) if cls: - return cls(response, deserialized, header_dict) + return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_key_value.metadata = {'url': '/kv/{key}'} - - def check_key_value(self, key, label=None, accept_datetime=None, if_match=None, if_none_match=None, select=None, cls=None, **kwargs): + delete_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def check_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Head7ItemsItem"]]] + **kwargs # type: Any + ): + # type: (...) -> None """Requests the headers and status of the given resource. + Requests the headers and status of the given resource. + :param key: The key of the key-value to retrieve. :type key: str :param label: The label of the key-value to retrieve. :type label: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. :type if_none_match: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Head7ItemsItem] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) :rtype: None - :raises: - :class:`HttpResponseError` + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + # Construct URL - url = self.check_key_value.metadata['url'] + url = self.check_key_value.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: @@ -590,7 +701,6 @@ def check_key_value(self, key, label=None, accept_datetime=None, if_match=None, if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - # Construct and send request request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -599,147 +709,173 @@ def check_key_value(self, key, label=None, accept_datetime=None, if_match=None, map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - 'Last-Modified': self._deserialize('str', response.headers.get('Last-Modified')), - } - return cls(response, None, response_headers) - check_key_value.metadata = {'url': '/kv/{key}'} + return cls(pipeline_response, None, response_headers) + + check_key_value.metadata = {'url': '/kv/{key}'} # type: ignore def get_labels( - self, name=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LabelListResult"] """Gets a list of labels. + Gets a list of labels. + :param name: A filter for the name of the returned labels. :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). + :param select: Used to select what fields are present in the returned resource(s). :type select: list[str] - :return: An iterator like instance of Label - :rtype: ~azure.core.paging.ItemPaged[~appconfiguration.models.Label] - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabelListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.LabelListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabelListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.labelset+json, application/json, application/problem+json" + def prepare_request(next_link=None): - query_parameters = {} + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.get_labels.metadata['url'] + url = self.get_labels.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] if name is not None: query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + request = self._client.get(url, query_parameters, header_parameters) else: + url = next_link + query_parameters = {} # type: Dict[str, Any] path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.labelset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) return request - def extract_data(response): - deserialized = self._deserialize('LabelListResult', response) + def extract_data(pipeline_response): + deserialized = self._deserialize('LabelListResult', pipeline_response) list_of_elem = deserialized.items if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response + raise HttpResponseError(response=response, model=error) + + return pipeline_response - # Deserialize response return ItemPaged( get_next, extract_data ) - get_labels.metadata = {'url': '/labels'} - - def check_labels(self, name=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + get_labels.metadata = {'url': '/labels'} # type: ignore + + def check_labels( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None """Requests the headers and status of the given resource. + Requests the headers and status of the given resource. + :param name: A filter for the name of the returned labels. :type name: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). + :param select: Used to select what fields are present in the returned resource(s). :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) :rtype: None - :raises: - :class:`HttpResponseError` + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + # Construct URL - url = self.check_labels.metadata['url'] + url = self.check_labels.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if name is not None: query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - # Construct and send request request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -748,296 +884,341 @@ def check_labels(self, name=None, after=None, accept_datetime=None, select=None, map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_labels.metadata = {'url': '/labels'} + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) - def put_lock(self, key, label=None, if_match=None, if_none_match=None, cls=None, **kwargs): + if cls: + return cls(pipeline_response, None, response_headers) + + check_labels.metadata = {'url': '/labels'} # type: ignore + + def put_lock( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.KeyValue" """Locks a key-value. + Locks a key-value. + :param key: The key of the key-value to lock. :type key: str :param label: The label, if any, of the key-value to lock. :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + # Construct URL - url = self.put_lock.metadata['url'] + url = self.put_lock.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) if cls: - return cls(response, deserialized, header_dict) + return cls(pipeline_response, deserialized, response_headers) return deserialized - put_lock.metadata = {'url': '/locks/{key}'} - - def delete_lock(self, key, label=None, if_match=None, if_none_match=None, cls=None, **kwargs): + put_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + def delete_lock( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.KeyValue" """Unlocks a key-value. + Unlocks a key-value. + :param key: The key of the key-value to unlock. :type key: str :param label: The label, if any, of the key-value to unlock. :type label: str - :param if_match: Used to perform an operation only if the targeted - resource's etag matches the value provided. + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. :type if_match: str - :param if_none_match: Used to perform an operation only if the - targeted resource's etag does not match the value provided. + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. :type if_none_match: str - :param callable cls: A custom type or function that will be passed the - direct response - :return: KeyValue or the result of cls(response) - :rtype: ~appconfiguration.models.KeyValue - :raises: - :class:`ErrorException` + :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.appconfiguration.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json" + # Construct URL - url = self.delete_lock.metadata['url'] + url = self.delete_lock.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'key': self._serialize.url("key", key, 'str') + 'key': self._serialize.url("key", key, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kv+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('KeyValue', response) - header_dict = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - 'ETag': self._deserialize('str', response.headers.get('ETag')), - } + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) if cls: - return cls(response, deserialized, header_dict) + return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_lock.metadata = {'url': '/locks/{key}'} + delete_lock.metadata = {'url': '/locks/{key}'} # type: ignore def get_revisions( - self, key=None, label=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Enum4"]]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.KeyValueListResult"] """Gets a list of key-value revisions. + Gets a list of key-value revisions. + :param key: A filter used to match keys. :type key: str - :param label: A filter used to match labels + :param label: A filter used to match labels. :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :return: An iterator like instance of KeyValue - :rtype: - ~azure.core.paging.ItemPaged[~appconfiguration.models.KeyValue] - :raises: - :class:`ErrorException` + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Enum4] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyValueListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + accept = "application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json" + def prepare_request(next_link=None): - query_parameters = {} + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.get_revisions.metadata['url'] + url = self.get_revisions.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] if key is not None: query_parameters['key'] = self._serialize.query("key", key, 'str') if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + request = self._client.get(url, query_parameters, header_parameters) else: + url = next_link + query_parameters = {} # type: Dict[str, Any] path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - next_link = self._client.format_url(next_link, **path_format_arguments) - url = next_link - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/vnd.microsoft.appconfig.kvset+json' - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if self._config.sync_token is not None: - header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') - if accept_datetime is not None: - header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) return request - def extract_data(response): - deserialized = self._deserialize('KeyValueListResult', response) + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) list_of_elem = deserialized.items if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorException(response, self._deserialize) - return response + raise HttpResponseError(response=response, model=error) + + return pipeline_response - # Deserialize response return ItemPaged( get_next, extract_data ) - get_revisions.metadata = {'url': '/revisions'} - - def check_revisions(self, key=None, label=None, after=None, accept_datetime=None, select=None, cls=None, **kwargs): + get_revisions.metadata = {'url': '/revisions'} # type: ignore + + def check_revisions( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "_models.Enum5"]]] + **kwargs # type: Any + ): + # type: (...) -> None """Requests the headers and status of the given resource. + Requests the headers and status of the given resource. + :param key: A filter used to match keys. :type key: str - :param label: A filter used to match labels + :param label: A filter used to match labels. :type label: str - :param after: Instructs the server to return elements that appear - after the element referred to by the specified token. + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. :type after: str - :param accept_datetime: Requests the server to respond with the state - of the resource at the specified time. + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. :type accept_datetime: str - :param select: Used to select what fields are present in the returned - resource(s). - :type select: list[str] - :param callable cls: A custom type or function that will be passed the - direct response - :return: None or the result of cls(response) + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.appconfiguration.models.Enum5] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) :rtype: None - :raises: - :class:`HttpResponseError` + :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = kwargs.pop('error_map', None) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + # Construct URL - url = self.check_revisions.metadata['url'] + url = self.check_revisions.metadata['url'] # type: ignore path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True) + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if key is not None: query_parameters['key'] = self._serialize.query("key", key, 'str') if label is not None: query_parameters['label'] = self._serialize.query("label", label, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if after is not None: query_parameters['After'] = self._serialize.query("after", after, 'str') if select is not None: query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') # Construct headers - header_parameters = {} - if self._config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + header_parameters = {} # type: Dict[str, Any] if self._config.sync_token is not None: header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') if accept_datetime is not None: header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') - # Construct and send request request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1046,9 +1227,10 @@ def check_revisions(self, key=None, label=None, after=None, accept_datetime=None map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + if cls: - response_headers = { - 'Sync-Token': self._deserialize('str', response.headers.get('Sync-Token')), - } - return cls(response, None, response_headers) - check_revisions.metadata = {'url': '/revisions'} + return cls(pipeline_response, None, response_headers) + + check_revisions.metadata = {'url': '/revisions'} # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/version.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/version.py deleted file mode 100644 index 096aeed2ccbc..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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" - diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 84cd3863d317..9ffac9aad122 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -12,6 +12,7 @@ DistributedTracingPolicy, HttpLoggingPolicy, AsyncBearerTokenCredentialPolicy, + ContentDecodePolicy, ) from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async @@ -31,8 +32,7 @@ prep_if_none_match, ) from .._generated.aio import AzureAppConfiguration -from .._generated.models import ErrorException -from .._generated.aio._configuration_async import AzureAppConfigurationConfiguration +from .._generated.aio._configuration import AzureAppConfigurationConfiguration from .._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy from .._azure_appconfiguration_credential import AppConfigConnectionStringCredential from .._generated.models import KeyValue @@ -78,8 +78,10 @@ def __init__(self, base_url, credential, **kwargs): if not credential: raise ValueError("Missing credential") + self._credential_scopes = base_url.strip("/") + "/.default" + self._config = AzureAppConfigurationConfiguration( - credential, base_url, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -98,7 +100,7 @@ def __init__(self, base_url, credential, **kwargs): ) self._impl = AzureAppConfiguration( - credentials=credential, endpoint=base_url, pipeline=pipeline + credential, base_url, credential_scopes=self._credential_scopes, pipeline=pipeline ) @classmethod @@ -159,6 +161,7 @@ def _create_appconfig_pipeline( self._config.logging_policy, # HTTP request/response log DistributedTracingPolicy(**kwargs), HttpLoggingPolicy(**kwargs), + ContentDecodePolicy(**kwargs), ] if not transport: @@ -224,8 +227,9 @@ def list_configuration_settings( error_map=error_map, **kwargs ) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -287,8 +291,9 @@ async def get_configuration_setting( return ConfigurationSetting._from_generated(key_value) except ResourceNotModifiedError: return None - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -337,8 +342,9 @@ async def add_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_added) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -404,8 +410,9 @@ async def set_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_set) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -461,8 +468,9 @@ async def delete_configuration_setting( error_map=error_map, ) return ConfigurationSetting._from_generated(key_value_deleted) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -522,8 +530,9 @@ def list_revisions( error_map=error_map, **kwargs ) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") @@ -591,8 +600,9 @@ async def set_read_only( **kwargs ) return ConfigurationSetting._from_generated(key_value) - except ErrorException as error: - raise HttpResponseError(message=error.message, response=error.response) + except HttpResponseError as error: + e = error_map[error.status_code] + raise e(message=error.message, response=error.response) except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") diff --git a/sdk/appconfiguration/azure-appconfiguration/swagger/README.md b/sdk/appconfiguration/azure-appconfiguration/swagger/README.md new file mode 100644 index 000000000000..9cb195a8597f --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/swagger/README.md @@ -0,0 +1,18 @@ +## Azure Appconfiguration for Python + +### Settings +``` yaml +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/appconfiguration/data-plane/Microsoft.AppConfiguration/stable/1.0/appconfiguration.json +output-folder: "../azure/appconfiguration/_generated" +namespace: azure.appconfiguration +no-namespace-folders: true +python: true +python-mode: create +license-header: MICROSOFT_MIT_NO_VERSION +package-name: azure-appconfiguration +clear-output-folder: true +enable-xml: true +vanilla: true +add-credentials: true +credential-scopes: https://dev.azuresynapse.net/.default +``` \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 6356e3690f0f..9ac30ea38445 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -233,7 +233,7 @@ def test_get_non_existing_configuration_setting(self, client, appconfiguration_c # method: delete_configuration_setting @app_config_decorator - def test_delete_with_key_no_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): + def test_delete_with_key_no_label(self, client, appconfiguration_connection_string, test_config_setting_no_label): to_delete_kv = test_config_setting_no_label client.delete_configuration_setting(to_delete_kv.key) with pytest.raises(ResourceNotFoundError):