From 2af7f45c6821277720329ff0bf0f29addf1fc37a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 27 May 2026 13:46:29 -0700 Subject: [PATCH 1/5] Update App Config To Type Spec Gen --- .../azure-appconfiguration/MANIFEST.in | 2 +- .../azure-appconfiguration/_metadata.json | 6 + .../apiview-properties.json | 58 ++ .../azure-appconfiguration/azure/__init__.py | 2 +- .../_azure_appconfiguration_requests.py | 1 + .../appconfiguration/_generated/__init__.py | 2 +- .../appconfiguration/_generated/_client.py | 21 +- .../_generated/_configuration.py | 11 +- .../_generated/_operations/__init__.py | 6 +- .../_generated/_operations/_operations.py | 552 +++++++----- .../_generated/_operations/_patch.py | 1 + .../appconfiguration/_generated/_patch.py | 1 + .../_generated/_utils/__init__.py | 6 + .../{_model_base.py => _utils/model_base.py} | 816 +++++++++++++++--- .../serialization.py} | 252 +++--- .../{_vendor.py => _utils/utils.py} | 16 +- .../_generated/_validation.py | 66 ++ .../appconfiguration/_generated/_version.py | 9 + .../_generated/aio/_client.py | 21 +- .../_generated/aio/_configuration.py | 11 +- .../_generated/aio/_operations/__init__.py | 6 +- .../_generated/aio/_operations/_operations.py | 386 ++++++--- .../_generated/aio/_operations/_patch.py | 2 + .../appconfiguration/_generated/aio/_patch.py | 1 + .../_generated/aio/_vendor.py | 57 -- .../_generated/models/_enums.py | 8 +- .../_generated/models/_models.py | 134 ++- .../_generated/models/_patch.py | 1 + .../appconfiguration/_generated/py.typed | 1 - .../azure/appconfiguration/_version.py | 11 +- .../azure-appconfiguration/pyproject.toml | 60 ++ .../check_configuration_settings_sample.py | 1 + .../samples/conditional_operation_sample.py | 1 + .../conditional_operation_sample_async.py | 1 + .../samples/hello_world_entra_id_sample.py | 1 + .../samples/hello_world_sample.py | 1 + .../samples/hello_world_sample_async.py | 1 + .../hello_world_sample_entra_id_and_bleu.py | 5 +- .../list_configuration_settings_sample.py | 1 + ...ist_configuration_settings_sample_async.py | 1 + .../samples/list_labels_sample.py | 1 + .../samples/list_labels_sample_async.py | 1 + .../samples/list_revision_sample.py | 1 + .../samples/list_revision_sample_async.py | 1 + .../samples/read_only_sample.py | 1 + .../samples/read_only_sample_async.py | 1 + .../samples/send_request_sample.py | 1 + .../samples/send_request_sample_async.py | 1 + .../samples/snapshot_sample.py | 1 + .../samples/snapshot_sample_async.py | 1 + .../samples/sync_token_sample.py | 1 + .../samples/sync_token_sample_async.py | 1 + .../azure-appconfiguration/setup.py | 1 - .../azure-appconfiguration/tests/consts.py | 1 + .../test_azure_appconfiguration_client.py | 1 + ...est_azure_appconfiguration_client_async.py | 1 + .../azure-appconfiguration/tsp-location.yaml | 2 +- 57 files changed, 1752 insertions(+), 806 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration/_metadata.json create mode 100644 sdk/appconfiguration/azure-appconfiguration/apiview-properties.json create mode 100644 sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/__init__.py rename sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/{_model_base.py => _utils/model_base.py} (56%) rename sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/{_serialization.py => _utils/serialization.py} (92%) rename sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/{_vendor.py => _utils/utils.py} (82%) create mode 100644 sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_validation.py create mode 100644 sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_version.py delete mode 100644 sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_vendor.py delete mode 100644 sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed diff --git a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in index 0483ef9dcf83..117293ece3f6 100644 --- a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in @@ -3,4 +3,4 @@ include LICENSE include azure/appconfiguration/py.typed recursive-include tests *.py recursive-include samples *.py *.md -include azure/__init__.py \ No newline at end of file +include azure/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration/_metadata.json b/sdk/appconfiguration/azure-appconfiguration/_metadata.json new file mode 100644 index 000000000000..599f33b5de70 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/_metadata.json @@ -0,0 +1,6 @@ +{ + "apiVersion": "2024-09-01", + "apiVersions": { + "AzureAppConfiguration": "2024-09-01" + } +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/apiview-properties.json b/sdk/appconfiguration/azure-appconfiguration/apiview-properties.json new file mode 100644 index 000000000000..fec9c5d81c24 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/apiview-properties.json @@ -0,0 +1,58 @@ +{ + "CrossLanguagePackageId": "AzureAppConfiguration", + "CrossLanguageDefinitionId": { + "azure.appconfiguration.models.Error": "AzureAppConfiguration.Error", + "azure.appconfiguration.models.Key": "AzureAppConfiguration.Key", + "azure.appconfiguration.models.KeyValue": "AzureAppConfiguration.KeyValue", + "azure.appconfiguration.models.KeyValueFilter": "AzureAppConfiguration.KeyValueFilter", + "azure.appconfiguration.models.Label": "AzureAppConfiguration.Label", + "azure.appconfiguration.models.OperationDetails": "AzureAppConfiguration.OperationDetails", + "azure.appconfiguration.models.Snapshot": "AzureAppConfiguration.Snapshot", + "azure.appconfiguration.models.SnapshotUpdateParameters": "AzureAppConfiguration.SnapshotUpdateParameters", + "azure.appconfiguration.models.ConfigurationSettingFields": "AzureAppConfiguration.KeyValueFields", + "azure.appconfiguration.models.SnapshotStatus": "AzureAppConfiguration.SnapshotStatus", + "azure.appconfiguration.models.SnapshotComposition": "AzureAppConfiguration.CompositionType", + "azure.appconfiguration.models.SnapshotFields": "AzureAppConfiguration.SnapshotFields", + "azure.appconfiguration.models.OperationState": "Azure.Core.Foundations.OperationState", + "azure.appconfiguration.models.LabelFields": "AzureAppConfiguration.LabelFields", + "azure.appconfiguration.AzureAppConfigurationClient.get_keys": "AzureAppConfiguration.getKeys", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_keys": "AzureAppConfiguration.getKeys", + "azure.appconfiguration.AzureAppConfigurationClient.check_keys": "AzureAppConfiguration.checkKeys", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_keys": "AzureAppConfiguration.checkKeys", + "azure.appconfiguration.AzureAppConfigurationClient.get_key_values": "AzureAppConfiguration.getKeyValues", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_key_values": "AzureAppConfiguration.getKeyValues", + "azure.appconfiguration.AzureAppConfigurationClient.check_key_values": "AzureAppConfiguration.checkKeyValues", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_key_values": "AzureAppConfiguration.checkKeyValues", + "azure.appconfiguration.AzureAppConfigurationClient.get_key_value": "AzureAppConfiguration.getKeyValue", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_key_value": "AzureAppConfiguration.getKeyValue", + "azure.appconfiguration.AzureAppConfigurationClient.delete_key_value": "AzureAppConfiguration.deleteKeyValue", + "azure.appconfiguration.aio.AzureAppConfigurationClient.delete_key_value": "AzureAppConfiguration.deleteKeyValue", + "azure.appconfiguration.AzureAppConfigurationClient.check_key_value": "AzureAppConfiguration.checkKeyValue", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_key_value": "AzureAppConfiguration.checkKeyValue", + "azure.appconfiguration.AzureAppConfigurationClient.get_snapshots": "AzureAppConfiguration.getSnapshots", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_snapshots": "AzureAppConfiguration.getSnapshots", + "azure.appconfiguration.AzureAppConfigurationClient.check_snapshots": "AzureAppConfiguration.checkSnapshots", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_snapshots": "AzureAppConfiguration.checkSnapshots", + "azure.appconfiguration.AzureAppConfigurationClient.get_snapshot": "AzureAppConfiguration.getSnapshot", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_snapshot": "AzureAppConfiguration.getSnapshot", + "azure.appconfiguration.AzureAppConfigurationClient.get_operation_details": "AzureAppConfiguration.getOperationDetails", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_operation_details": "AzureAppConfiguration.getOperationDetails", + "azure.appconfiguration.AzureAppConfigurationClient.begin_create_snapshot": "AzureAppConfiguration.createSnapshot", + "azure.appconfiguration.aio.AzureAppConfigurationClient.begin_create_snapshot": "AzureAppConfiguration.createSnapshot", + "azure.appconfiguration.AzureAppConfigurationClient.check_snapshot": "AzureAppConfiguration.checkSnapshot", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_snapshot": "AzureAppConfiguration.checkSnapshot", + "azure.appconfiguration.AzureAppConfigurationClient.get_labels": "AzureAppConfiguration.getLabels", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_labels": "AzureAppConfiguration.getLabels", + "azure.appconfiguration.AzureAppConfigurationClient.check_labels": "AzureAppConfiguration.checkLabels", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_labels": "AzureAppConfiguration.checkLabels", + "azure.appconfiguration.AzureAppConfigurationClient.put_lock": "AzureAppConfiguration.putLock", + "azure.appconfiguration.aio.AzureAppConfigurationClient.put_lock": "AzureAppConfiguration.putLock", + "azure.appconfiguration.AzureAppConfigurationClient.delete_lock": "AzureAppConfiguration.deleteLock", + "azure.appconfiguration.aio.AzureAppConfigurationClient.delete_lock": "AzureAppConfiguration.deleteLock", + "azure.appconfiguration.AzureAppConfigurationClient.get_revisions": "AzureAppConfiguration.getRevisions", + "azure.appconfiguration.aio.AzureAppConfigurationClient.get_revisions": "AzureAppConfiguration.getRevisions", + "azure.appconfiguration.AzureAppConfigurationClient.check_revisions": "AzureAppConfiguration.checkRevisions", + "azure.appconfiguration.aio.AzureAppConfigurationClient.check_revisions": "AzureAppConfiguration.checkRevisions" + }, + "CrossLanguageVersion": "29f9953822ad" +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py index 055660a74a88..4f248d0f47e3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py index ddbe3f930fc3..e478141d10e9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py @@ -13,7 +13,7 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._client import AzureAppConfigurationClient # type: ignore -from .._version import VERSION +from ._version import VERSION __version__ = VERSION diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py index e1bab02c1961..a477d39fce84 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py @@ -7,8 +7,8 @@ # -------------------------------------------------------------------------- from copy import deepcopy +import sys from typing import Any, TYPE_CHECKING, Union -from typing_extensions import Self from azure.core import PipelineClient from azure.core.credentials import AzureKeyCredential @@ -16,23 +16,29 @@ from azure.core.rest import HttpRequest, HttpResponse from ._configuration import AzureAppConfigurationClientConfiguration -from ._operations import AzureAppConfigurationClientOperationsMixin -from ._serialization import Deserializer, Serializer +from ._operations import _AzureAppConfigurationClientOperationsMixin +from ._utils.serialization import Deserializer, Serializer + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore if TYPE_CHECKING: from azure.core.credentials import TokenCredential -class AzureAppConfigurationClient(AzureAppConfigurationClientOperationsMixin): +class AzureAppConfigurationClient(_AzureAppConfigurationClientOperationsMixin): """Azure App Configuration REST API. :param endpoint: Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". + :keyword api_version: The API version to use for this operation. Known values are "2024-09-01" + and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -42,6 +48,7 @@ class AzureAppConfigurationClient(AzureAppConfigurationClientOperationsMixin): def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: _endpoint = "{endpoint}" self._config = AzureAppConfigurationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py index 559ee3e9dcbe..9d022c908830 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py @@ -11,7 +11,7 @@ from azure.core.credentials import AzureKeyCredential from azure.core.pipeline import policies -from .._version import VERSION +from ._version import VERSION if TYPE_CHECKING: from azure.core.credentials import TokenCredential @@ -25,17 +25,18 @@ class AzureAppConfigurationClientConfiguration: # pylint: disable=too-many-inst :param endpoint: Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". + :keyword api_version: The API version to use for this operation. Known values are "2024-09-01" + and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") 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 a90b04c612d7..91bafc83f689 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/__init__.py @@ -12,14 +12,12 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import AzureAppConfigurationClientOperationsMixin # type: ignore +from ._operations import _AzureAppConfigurationClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk -__all__ = [ - "AzureAppConfigurationClientOperationsMixin", -] +__all__ = [] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py index 919a641512d1..372a8b673df0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py @@ -6,13 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse -from azure.core import MatchConditions +from azure.core import MatchConditions, PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -33,17 +33,15 @@ from azure.core.utils import case_insensitive_dict from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer -from .._vendor import AzureAppConfigurationClientMixinABC, prep_if_match, prep_if_none_match - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +from .._configuration import AzureAppConfigurationClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Serializer +from .._utils.utils import ClientMixinABC, prep_if_match, prep_if_none_match +from .._validation import api_version_validation + +JSON = MutableMapping[str, Any] T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -60,8 +58,8 @@ def build_azure_app_configuration_get_keys_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.keyset+json, application/problem+json") # Construct URL _url = "/keys" @@ -78,8 +76,7 @@ def build_azure_app_configuration_get_keys_request( # pylint: disable=name-too- _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) @@ -87,17 +84,15 @@ def build_azure_app_configuration_get_keys_request( # pylint: disable=name-too- def build_azure_app_configuration_check_keys_request( # pylint: disable=name-too-long *, name: Optional[str] = None, - sync_token: Optional[str] = None, after: Optional[str] = None, + sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/keys" @@ -113,7 +108,6 @@ def build_azure_app_configuration_check_keys_request( # pylint: disable=name-to _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) @@ -125,9 +119,9 @@ def build_azure_app_configuration_get_key_values_request( # pylint: disable=nam sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -135,8 +129,8 @@ def build_azure_app_configuration_get_key_values_request( # pylint: disable=nam _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kvset+json, application/problem+json") # Construct URL _url = "/kv" @@ -161,8 +155,7 @@ def build_azure_app_configuration_get_key_values_request( # pylint: disable=nam _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -180,9 +173,9 @@ def build_azure_app_configuration_check_key_values_request( # pylint: disable=n sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -190,9 +183,7 @@ def build_azure_app_configuration_check_key_values_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/kv" @@ -216,7 +207,6 @@ def build_azure_app_configuration_check_key_values_request( # pylint: disable=n _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -231,9 +221,10 @@ def build_azure_app_configuration_get_key_value_request( # pylint: disable=name key: str, *, label: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -241,8 +232,8 @@ def build_azure_app_configuration_get_key_value_request( # pylint: disable=name _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json") # Construct URL _url = "/kv/{key}" @@ -258,14 +249,15 @@ def build_azure_app_configuration_get_key_value_request( # pylint: disable=name _params["label"] = _SERIALIZER.query("label", label, "str") if select is not None: _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",") + if tags is not None: + _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags] # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -289,8 +281,8 @@ def build_azure_app_configuration_put_key_value_request( # pylint: disable=name _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json") # Construct URL _url = "/kv/{key}" @@ -310,8 +302,7 @@ def build_azure_app_configuration_put_key_value_request( # pylint: disable=name _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -334,8 +325,8 @@ def build_azure_app_configuration_delete_key_value_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json") # Construct URL _url = "/kv/{key}" @@ -353,14 +344,13 @@ def build_azure_app_configuration_delete_key_value_request( # pylint: disable=n # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if_none_match = prep_if_none_match(etag, match_condition) if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + _headers["if-none-match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) @@ -371,7 +361,8 @@ def build_azure_app_configuration_check_key_value_request( # pylint: disable=na label: Optional[str] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -379,9 +370,7 @@ def build_azure_app_configuration_check_key_value_request( # pylint: disable=na _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/kv/{key}" path_format_arguments = { @@ -396,13 +385,14 @@ def build_azure_app_configuration_check_key_value_request( # pylint: disable=na _params["label"] = _SERIALIZER.query("label", label, "str") if select is not None: _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",") + if tags is not None: + _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags] # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -417,16 +407,16 @@ def build_azure_app_configuration_get_snapshots_request( # pylint: disable=name *, name: Optional[str] = None, after: Optional[str] = None, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, - status: Optional[List[Union[str, _models.SnapshotStatus]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, + status: Optional[list[Union[str, _models.SnapshotStatus]]] = None, sync_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshotset+json, application/problem+json") # Construct URL _url = "/snapshots" @@ -445,8 +435,7 @@ def build_azure_app_configuration_get_snapshots_request( # pylint: disable=name # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) @@ -457,9 +446,7 @@ def build_azure_app_configuration_check_snapshots_request( # pylint: disable=na _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/snapshots" @@ -471,7 +458,6 @@ def build_azure_app_configuration_check_snapshots_request( # pylint: disable=na # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) @@ -479,7 +465,7 @@ def build_azure_app_configuration_check_snapshots_request( # pylint: disable=na def build_azure_app_configuration_get_snapshot_request( # pylint: disable=name-too-long name: str, *, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, sync_token: Optional[str] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -488,8 +474,8 @@ def build_azure_app_configuration_get_snapshot_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json") # Construct URL _url = "/snapshots/{name}" @@ -507,8 +493,7 @@ def build_azure_app_configuration_get_snapshot_request( # pylint: disable=name- # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -525,7 +510,7 @@ def build_azure_app_configuration_get_operation_details_request( # pylint: disa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -548,8 +533,8 @@ def build_azure_app_configuration_create_snapshot_request( # pylint: disable=na _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json") # Construct URL _url = "/snapshots/{name}" @@ -567,8 +552,7 @@ def build_azure_app_configuration_create_snapshot_request( # pylint: disable=na _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) @@ -585,8 +569,8 @@ def build_azure_app_configuration_update_snapshot_request( # pylint: disable=na _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json") # Construct URL _url = "/snapshots/{name}" @@ -604,8 +588,7 @@ def build_azure_app_configuration_update_snapshot_request( # pylint: disable=na _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -627,9 +610,7 @@ def build_azure_app_configuration_check_snapshot_request( # pylint: disable=nam _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/snapshots/{name}" path_format_arguments = { @@ -644,7 +625,6 @@ def build_azure_app_configuration_check_snapshot_request( # pylint: disable=nam # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -661,14 +641,14 @@ def build_azure_app_configuration_get_labels_request( # pylint: disable=name-to sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.labelset+json, application/problem+json") # Construct URL _url = "/labels" @@ -687,8 +667,7 @@ def build_azure_app_configuration_get_labels_request( # pylint: disable=name-to _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) @@ -699,15 +678,13 @@ def build_azure_app_configuration_check_labels_request( # pylint: disable=name- sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/labels" @@ -725,7 +702,6 @@ def build_azure_app_configuration_check_labels_request( # pylint: disable=name- _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) @@ -742,8 +718,8 @@ def build_azure_app_configuration_put_lock_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json") # Construct URL _url = "/locks/{key}" @@ -761,8 +737,7 @@ def build_azure_app_configuration_put_lock_request( # pylint: disable=name-too- # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -785,8 +760,8 @@ def build_azure_app_configuration_delete_lock_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json") # Construct URL _url = "/locks/{key}" @@ -804,8 +779,7 @@ def build_azure_app_configuration_delete_lock_request( # pylint: disable=name-t # Construct headers if sync_token is not None: _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") if_match = prep_if_match(etag, match_condition) if if_match is not None: _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") @@ -823,15 +797,15 @@ def build_azure_app_configuration_get_revisions_request( # pylint: disable=name sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kvset+json, application/problem+json") # Construct URL _url = "/revisions" @@ -854,8 +828,7 @@ def build_azure_app_configuration_get_revisions_request( # pylint: disable=name _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - if accept is not None: - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) @@ -867,16 +840,14 @@ def build_azure_app_configuration_check_revisions_request( # pylint: disable=na sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) # Construct URL _url = "/revisions" @@ -898,13 +869,12 @@ def build_azure_app_configuration_check_revisions_request( # pylint: disable=na _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str") if accept_datetime is not None: _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -class AzureAppConfigurationClientOperationsMixin( # pylint: disable=too-many-public-methods,name-too-long - AzureAppConfigurationClientMixinABC +class _AzureAppConfigurationClientOperationsMixin( # pylint: disable=too-many-public-methods + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], AzureAppConfigurationClientConfiguration] ): @distributed_trace @@ -916,7 +886,7 @@ def get_keys( sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.Key"]: + ) -> ItemPaged["_models.Key"]: """Gets a list of keys. Gets a list of keys. @@ -934,13 +904,13 @@ def get_keys( time. Default value is None. :paramtype accept_datetime: str :return: An iterator like instance of Key - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Key] + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration._generated.models.Key] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Key]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Key]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -980,7 +950,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -993,7 +966,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Key], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Key], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, iter(list_of_elem) @@ -1009,7 +985,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1021,8 +1000,8 @@ def check_keys( self, *, name: Optional[str] = None, - sync_token: Optional[str] = None, after: Optional[str] = None, + sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, **kwargs: Any ) -> bool: @@ -1032,12 +1011,12 @@ def check_keys( :keyword name: A filter for the name of the returned keys. Default value is None. :paramtype name: str - :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is - None. - :paramtype sync_token: str :keyword after: Instructs the server to return elements that appear after the element referred to by the specified token. Default value is None. :paramtype after: str + :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is + None. + :paramtype sync_token: str :keyword accept_datetime: Requests the server to respond with the state of the resource at the specified time. Default value is None. @@ -1061,8 +1040,8 @@ def check_keys( _request = build_azure_app_configuration_check_keys_request( name=name, - sync_token=sync_token, after=after, + sync_token=sync_token, accept_datetime=accept_datetime, api_version=self._config.api_version, headers=_headers, @@ -1082,7 +1061,10 @@ def check_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1101,22 +1083,24 @@ def get_key_values( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any - ) -> Iterable["_models.KeyValue"]: + ) -> ItemPaged["_models.KeyValue"]: """Gets a list of key-values. Gets a list of key-values. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -1135,7 +1119,8 @@ def get_key_values( the snapshot. Not valid when used with 'key' and 'label' filters. Default value is None. :paramtype snapshot: str :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1143,13 +1128,13 @@ def get_key_values( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: An iterator like instance of KeyValue - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValue] + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration._generated.models.KeyValue] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.KeyValue]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.KeyValue]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1201,7 +1186,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1214,7 +1202,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.KeyValue], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.KeyValue], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, iter(list_of_elem) @@ -1230,7 +1221,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1246,9 +1240,9 @@ def check_key_values( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -1258,10 +1252,12 @@ def check_key_values( Requests the headers and status of the given resource. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -1276,11 +1272,12 @@ def check_key_values( :keyword select: Used to select what fields are present in the returned resource(s). Default value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] - :keyword snapshot: A filter used get key-values for a snapshot. Not valid when used with 'key' - and 'label' filters. Default value is None. + :keyword snapshot: A filter used get key-values for a snapshot. The value should be the name of + the snapshot. Not valid when used with 'key' and 'label' filters. Default value is None. :paramtype snapshot: str :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1339,7 +1336,10 @@ def check_key_values( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1351,14 +1351,19 @@ def check_key_values( return 200 <= response.status_code <= 299 @distributed_trace + @api_version_validation( + params_added_on={"2024-09-01": ["tags"]}, + api_versions_list=["2023-11-01", "2024-09-01"], + ) def get_key_value( self, key: str, *, label: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -1381,13 +1386,17 @@ def get_key_value( specified time. Default value is None. :paramtype accept_datetime: str + :keyword tags: A filter used to query by tags. Syntax reference: + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. + :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1415,6 +1424,7 @@ def get_key_value( select=select, sync_token=sync_token, accept_datetime=accept_datetime, + tags=tags, etag=etag, match_condition=match_condition, api_version=self._config.api_version, @@ -1426,6 +1436,7 @@ def get_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1440,19 +1451,20 @@ def get_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token")) response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -1521,7 +1533,7 @@ def _put_key_value( :type key: str :param entity: The key-value to create. Is one of the following types: KeyValue, JSON, IO[bytes] Default value is None. - :type entity: ~azure.appconfiguration.models.KeyValue or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.KeyValue or JSON or IO[bytes] :keyword label: The label of the key-value to create. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is @@ -1533,7 +1545,7 @@ def _put_key_value( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1554,9 +1566,10 @@ def _put_key_value( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if entity else None cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if entity else None _content = None if isinstance(entity, (IOBase, bytes)): _content = entity @@ -1583,6 +1596,7 @@ def _put_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1597,7 +1611,10 @@ def _put_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1606,7 +1623,7 @@ def _put_key_value( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -1643,7 +1660,7 @@ def delete_key_value( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue or None. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue or None + :rtype: ~azure.appconfiguration._generated.models.KeyValue or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1680,6 +1697,7 @@ def delete_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1694,7 +1712,10 @@ def delete_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) deserialized = None @@ -1705,7 +1726,7 @@ def delete_key_value( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -1718,6 +1739,10 @@ def delete_key_value( return deserialized # type: ignore @distributed_trace + @api_version_validation( + params_added_on={"2024-09-01": ["tags"]}, + api_versions_list=["2023-11-01", "2024-09-01"], + ) def check_key_value( self, key: str, @@ -1725,7 +1750,8 @@ def check_key_value( label: Optional[str] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -1748,6 +1774,10 @@ def check_key_value( :keyword select: Used to select what fields are present in the returned resource(s). Default value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] + :keyword tags: A filter used to query by tags. Syntax reference: + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. + :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1782,6 +1812,7 @@ def check_key_value( sync_token=sync_token, accept_datetime=accept_datetime, select=select, + tags=tags, etag=etag, match_condition=match_condition, api_version=self._config.api_version, @@ -1802,7 +1833,10 @@ def check_key_value( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1819,11 +1853,11 @@ def get_snapshots( *, name: Optional[str] = None, after: Optional[str] = None, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, - status: Optional[List[Union[str, _models.SnapshotStatus]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, + status: Optional[list[Union[str, _models.SnapshotStatus]]] = None, sync_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.Snapshot"]: + ) -> ItemPaged["_models.Snapshot"]: """Gets a list of key-value snapshots. Gets a list of key-value snapshots. @@ -1843,13 +1877,13 @@ def get_snapshots( None. :paramtype sync_token: str :return: An iterator like instance of Snapshot - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Snapshot]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Snapshot]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1890,7 +1924,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1903,7 +1940,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Snapshot], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Snapshot], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, iter(list_of_elem) @@ -1919,7 +1959,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1976,7 +2019,10 @@ def check_snapshots(self, *, sync_token: Optional[str] = None, after: Optional[s if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1991,7 +2037,7 @@ def get_snapshot( self, name: str, *, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, sync_token: Optional[str] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2015,7 +2061,7 @@ def get_snapshot( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.Snapshot + :rtype: ~azure.appconfiguration._generated.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2052,6 +2098,7 @@ def get_snapshot( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2066,20 +2113,21 @@ def get_snapshot( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _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["Link"] = self._deserialize("str", response.headers.get("Link")) - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.Snapshot, response.json()) @@ -2097,7 +2145,7 @@ def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _models.Oper :keyword snapshot: Snapshot identifier for the long running operation. Required. :paramtype snapshot: str :return: OperationDetails. The OperationDetails is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.OperationDetails + :rtype: ~azure.appconfiguration._generated.models.OperationDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2124,6 +2172,7 @@ def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _models.Oper } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2138,11 +2187,14 @@ def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _models.Oper except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.OperationDetails, response.json()) @@ -2194,6 +2246,7 @@ def _create_snapshot_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2207,7 +2260,10 @@ def _create_snapshot_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2217,7 +2273,7 @@ def _create_snapshot_initial( response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2235,7 +2291,7 @@ def begin_create_snapshot( :param name: The name of the key-value snapshot to create. Required. :type name: str :param entity: The key-value snapshot to create. Required. - :type entity: ~azure.appconfiguration.models.Snapshot + :type entity: ~azure.appconfiguration._generated.models.Snapshot :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Required. :paramtype content_type: str @@ -2244,7 +2300,7 @@ def begin_create_snapshot( :paramtype sync_token: str :return: An instance of LROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2268,7 +2324,7 @@ def begin_create_snapshot( :paramtype sync_token: str :return: An instance of LROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2293,7 +2349,7 @@ def begin_create_snapshot( :paramtype sync_token: str :return: An instance of LROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2314,13 +2370,13 @@ def begin_create_snapshot( :type name: str :param entity: The key-value snapshot to create. Is one of the following types: Snapshot, JSON, IO[bytes] Required. - :type entity: ~azure.appconfiguration.models.Snapshot or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.Snapshot or JSON or IO[bytes] :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. :paramtype sync_token: str :return: An instance of LROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2440,7 +2496,8 @@ def _update_snapshot( :type name: str :param entity: The parameters used to update the snapshot. Is one of the following types: SnapshotUpdateParameters, JSON, IO[bytes] Required. - :type entity: ~azure.appconfiguration.models.SnapshotUpdateParameters or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.SnapshotUpdateParameters or JSON or + IO[bytes] :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. :paramtype sync_token: str @@ -2450,7 +2507,7 @@ def _update_snapshot( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.Snapshot + :rtype: ~azure.appconfiguration._generated.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2496,6 +2553,7 @@ def _update_snapshot( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2510,7 +2568,10 @@ def _update_snapshot( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2520,7 +2581,7 @@ def _update_snapshot( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.Snapshot, response.json()) @@ -2599,7 +2660,10 @@ def check_snapshot( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2619,9 +2683,9 @@ def get_labels( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any - ) -> Iterable["_models.Label"]: + ) -> ItemPaged["_models.Label"]: """Gets a list of labels. Gets a list of labels. @@ -2642,13 +2706,13 @@ def get_labels( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.LabelFields] :return: An iterator like instance of Label - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Label] + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration._generated.models.Label] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Label]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Label]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2689,7 +2753,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -2702,7 +2769,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Label], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Label], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, iter(list_of_elem) @@ -2718,7 +2788,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2733,7 +2806,7 @@ def check_labels( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any ) -> bool: """Requests the headers and status of the given resource. @@ -2796,7 +2869,10 @@ def check_labels( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2834,7 +2910,7 @@ def put_lock( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2871,6 +2947,7 @@ def put_lock( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2885,7 +2962,10 @@ def put_lock( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2894,7 +2974,7 @@ def put_lock( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -2931,7 +3011,7 @@ def delete_lock( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2968,6 +3048,7 @@ def delete_lock( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2982,7 +3063,10 @@ def delete_lock( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2991,7 +3075,7 @@ def delete_lock( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -3009,19 +3093,21 @@ def get_revisions( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any - ) -> Iterable["_models.KeyValue"]: + ) -> ItemPaged["_models.KeyValue"]: """Gets a list of key-value revisions. Gets a list of key-value revisions. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -3037,16 +3123,17 @@ def get_revisions( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype tags: list[str] :return: An iterator like instance of KeyValue - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValue] + :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration._generated.models.KeyValue] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.KeyValue]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.KeyValue]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3089,7 +3176,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -3102,7 +3192,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.KeyValue], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.KeyValue], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, iter(list_of_elem) @@ -3118,7 +3211,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -3134,8 +3230,8 @@ def check_revisions( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any ) -> bool: """Requests the headers and status of the given resource. @@ -3143,10 +3239,12 @@ def check_revisions( Requests the headers and status of the given resource. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -3162,7 +3260,8 @@ def check_revisions( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype tags: list[str] :return: bool :rtype: bool @@ -3207,7 +3306,10 @@ def check_revisions( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py index a116bdf6a104..02bbb8fbd0fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + import json import urllib.parse from typing import Any, List, Optional, Union, MutableMapping, Type diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py index f7dd32510333..455941122974 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py @@ -6,6 +6,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + from typing import List __all__: List[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/model_base.py similarity index 56% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/model_base.py index 6a6e1f38b17e..d725c55906d3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/model_base.py @@ -1,9 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=protected-access, broad-except @@ -21,17 +22,19 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET -from typing_extensions import Self +from collections.abc import MutableMapping import isodate from azure.core.exceptions import DeserializationError from azure.core import CaseInsensitiveEnumMeta from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self else: - from typing import MutableMapping + from typing_extensions import Self _LOGGER = logging.getLogger(__name__) @@ -39,6 +42,7 @@ TZ_UTC = timezone.utc _T = typing.TypeVar("_T") +_NONE_TYPE = type(None) def _timedelta_as_isostr(td: timedelta) -> str: @@ -173,6 +177,21 @@ def default(self, o): # pylint: disable=too-many-return-statements r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" ) +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: """Deserialize ISO-8601 formatted string into Datetime object. @@ -204,7 +223,7 @@ def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: test_utc = date_obj.utctimetuple() if test_utc.tm_year > 9999 or test_utc.tm_year < 1: raise OverflowError("Hit max or min date") - return date_obj + return date_obj # type: ignore[no-any-return] def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: @@ -258,7 +277,7 @@ def _deserialize_time(attr: typing.Union[str, time]) -> time: """ if isinstance(attr, time): return attr - return isodate.parse_time(attr) + return isodate.parse_time(attr) # type: ignore[no-any-return] def _deserialize_bytes(attr): @@ -317,6 +336,8 @@ def _deserialize_int_as_str(attr): def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): if annotation is int and rf and rf._format == "str": return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) if rf and rf._format: return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore @@ -347,17 +368,47 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: self._data = data def __contains__(self, key: typing.Any) -> bool: return key in self._data def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized return self._data.__getitem__(key) def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass self._data.__setitem__(key, value) def __delitem__(self, key: str) -> None: @@ -373,55 +424,104 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ return self._data.items() def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ try: return self[key] except KeyError: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) - def popitem(self) -> typing.Tuple[str, typing.Any]: + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from D. + """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ self._data.update(*args, **kwargs) @typing.overload def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data try: other_model = self.__class__(other) except Exception: @@ -438,6 +538,8 @@ def _is_model(obj: typing.Any) -> bool: def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) return [_serialize(x, format) for x in o] if isinstance(o, dict): return {k: _serialize(v, format) for k, v in o.items()} @@ -469,9 +571,7 @@ def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-m return o -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: try: return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) except StopIteration: @@ -490,69 +590,253 @@ def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typin return _serialize(value, rf._format) +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param class Model(_MyMutableMapping): _is_model = True # label whether current class's _attr_to_rest_field has been calculated # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() + _calculated: set[str] = set() def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: class_name = self.__class__.__name__ if len(args) > 1: raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks + dict_to_pass: dict[str, typing.Any] = {} + if args: if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) + dict_to_pass.update(self._init_from_xml(args[0])) else: dict_to_pass.update( {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} @@ -569,8 +853,117 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: if v is not None } ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) super().__init__(dict_to_pass) + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + def copy(self) -> "Model": return Model(self.__dict__) @@ -579,7 +972,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") } annotations = { @@ -594,10 +987,13 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) if not rf._rest_name_input: rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - return super().__new__(cls) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: @@ -623,7 +1019,7 @@ def _deserialize(cls, data, exist_discriminators): model_meta = getattr(cls, "_xml", {}) prop_meta = getattr(discriminator, "_xml", {}) xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) if xml_ns: xml_name = "{" + xml_ns + "}" + xml_name @@ -633,10 +1029,10 @@ def _deserialize(cls, data, exist_discriminators): discriminator_value = data.find(xml_name).text # pyright: ignore else: discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member return mapped_cls._deserialize(data, exist_discriminators) - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: """Return a dict that can be turned into json using json.dump. :keyword bool exclude_readonly: Whether to remove the readonly properties. @@ -696,7 +1092,7 @@ def _deserialize_with_union(deserializers, obj): def _deserialize_dict( value_deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], + obj: dict[typing.Any, typing.Any], ): if obj is None: return obj @@ -706,7 +1102,7 @@ def _deserialize_dict( def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], + entry_deserializers: list[typing.Optional[typing.Callable]], module: typing.Optional[str], obj, ): @@ -715,6 +1111,14 @@ def _deserialize_multiple_sequence( return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + def _deserialize_sequence( deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], @@ -724,17 +1128,30 @@ def _deserialize_sequence( return obj if isinstance(obj, ET.Element): obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: return sorted( types, key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), ) -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches annotation: typing.Any, module: typing.Optional[str], rf: typing.Optional["_RestField"] = None, @@ -774,16 +1191,18 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur # is it optional? try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True if len(annotation.__args__) <= 2: # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore ) return functools.partial(_deserialize_with_optional, if_obj_deserializer) # the type is Optional[Union[...]], we need to remove the None type from the Union annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass @@ -799,7 +1218,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur return functools.partial(_deserialize_with_union, deserializers) try: - if annotation._name == "Dict": # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": value_deserializer = _get_deserialize_callable_from_annotation( annotation.__args__[1], module, rf # pyright: ignore ) @@ -812,7 +1234,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except (AttributeError, IndexError): pass try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: if len(annotation.__args__) > 1: # pyright: ignore entry_deserializers = [ _get_deserialize_callable_from_annotation(dt, module, rf) @@ -861,16 +1286,20 @@ def _deserialize_with_callable( return float(value.text) if value.text else None if deserializer is bool: return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None if deserializer is None: return value if deserializer in [int, float, bool]: return deserializer(value) if isinstance(deserializer, CaseInsensitiveEnumMeta): try: - return deserializer(value) + return deserializer(value.text if isinstance(value, ET.Element) else value) except ValueError: # for unknown value, return raw value - return value + return value.text if isinstance(value, ET.Element) else value if isinstance(deserializer, type) and issubclass(deserializer, Model): return deserializer._deserialize(value, []) return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) @@ -894,6 +1323,36 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes class _RestField: def __init__( self, @@ -901,11 +1360,12 @@ def __init__( name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ): self._type = type self._rest_name_input = name @@ -913,14 +1373,20 @@ def __init__( self._is_discriminator = is_discriminator self._visibility = visibility self._is_model = False + self._is_optional = False self._default = default self._format = format self._is_multipart_file_input = is_multipart_file_input self._xml = xml if xml is not None else {} + self._deserializer = deserializer @property def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result @property def _rest_name(self) -> str: @@ -931,14 +1397,44 @@ def _rest_name(self) -> str: def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin # by this point, type and rest_name will have a value bc we default # them in __new__ of the Model class - item = obj.get(self._rest_name) + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None if item is None: return item if self._is_model: return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + if value is None: # we want to wipe out entries if users set attr to None try: @@ -963,11 +1459,12 @@ def rest_field( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ) -> typing.Any: return _RestField( name=name, @@ -977,6 +1474,7 @@ def rest_field( format=format, is_multipart_file_input=is_multipart_file_input, xml=xml, + deserializer=deserializer, ) @@ -984,8 +1482,8 @@ def rest_discriminator( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, ) -> typing.Any: return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) @@ -1001,21 +1499,77 @@ def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + def _get_element( o: typing.Any, exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: +) -> typing.Union[ET.Element, list[ET.Element]]: if _is_model(o): model_meta = getattr(o, "_xml", {}) # if prop is a model, then use the prop element directly, else generate a wrapper of model if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), + element_name, model_meta.get("prefix"), - model_meta.get("ns"), + _model_ns, ) readonly_props = [] @@ -1037,7 +1591,9 @@ def _get_element( # additional properties will not have rest field, use the wire name as xml name prop_meta = {"name": k} - # if no ns for prop, use model's + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. if prop_meta.get("ns") is None and model_meta.get("ns"): prop_meta["ns"] = model_meta.get("ns") prop_meta["prefix"] = model_meta.get("prefix") @@ -1049,12 +1605,7 @@ def _get_element( # text could only set on primitive type wrapped_element.text = _get_primitive_type_value(v) elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) + _set_xml_attribute(wrapped_element, k, v, prop_meta) else: # other wrapped prop element wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) @@ -1063,6 +1614,7 @@ def _get_element( return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore if isinstance(o, dict): result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None for k, v in o.items(): result.append( _get_wrapped_element( @@ -1070,7 +1622,7 @@ def _get_element( exclude_readonly, { "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, + "ns": _dict_ns, "prefix": parent_meta.get("prefix") if parent_meta else None, }, ) @@ -1079,13 +1631,16 @@ def _get_element( # primitive case need to create element based on parent_meta if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) return _get_wrapped_element( o, exclude_readonly, { "name": parent_meta.get("itemsName", parent_meta.get("name")), "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + "ns": _items_ns, }, ) @@ -1095,10 +1650,11 @@ def _get_element( def _get_wrapped_element( v: typing.Any, exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], + meta: typing.Optional[dict[str, typing.Any]], ) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns ) if isinstance(v, (dict, list)): wrapped_element.extend(_get_element(v, exclude_readonly, meta)) @@ -1106,7 +1662,7 @@ def _get_wrapped_element( _get_element(v, exclude_readonly, meta, wrapped_element) else: wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element + return wrapped_element # type: ignore[no-any-return] def _get_primitive_type_value(v) -> str: @@ -1119,9 +1675,29 @@ def _get_primitive_type_value(v) -> str: return str(v) -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) if ns: return ET.Element("{" + ns + "}" + tag) return ET.Element(tag) @@ -1132,13 +1708,15 @@ def _deserialize_xml( value: str, ) -> typing.Any: element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) return _deserialize(deserializer, element) def _convert_element(e: ET.Element): # dict case if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} + dict_result: dict[str, typing.Any] = {} for child in e: if dict_result.get(child.tag) is not None: if isinstance(dict_result[child.tag], list): @@ -1151,7 +1729,7 @@ def _convert_element(e: ET.Element): return dict_result # array case if len(e) > 0: - array_result: typing.List[typing.Any] = [] + array_result: list[typing.Any] = [] for child in e: array_result.append(_convert_element(child)) return array_result diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/serialization.py similarity index 92% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/serialization.py index e2ad51869908..a088671e9c51 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,10 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, ) try: @@ -65,9 +43,13 @@ from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +167,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -397,7 +313,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -450,25 +366,25 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +395,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -500,7 +416,7 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod @@ -563,7 +479,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -614,7 +530,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -626,7 +542,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -665,7 +581,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -736,8 +652,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +697,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +721,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +751,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +771,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -875,7 +791,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -909,13 +825,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1192,7 +1115,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1141,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1174,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1270,7 +1193,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1429,7 +1352,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1441,7 +1364,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1472,7 +1395,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1482,16 +1405,37 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) @@ -1502,7 +1446,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1717,7 +1661,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1799,7 +1743,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1845,7 +1789,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1871,7 +1815,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1936,7 +1884,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1949,7 +1897,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1964,7 +1912,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1982,7 +1930,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1995,7 +1943,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2013,7 +1961,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2029,7 +1977,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2044,14 +1992,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2067,7 +2015,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2105,7 +2053,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_vendor.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/utils.py similarity index 82% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_vendor.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/utils.py index cd4cb43c3298..927adb7c8ae2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_vendor.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_utils/utils.py @@ -6,23 +6,23 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import Optional, TYPE_CHECKING +from typing import Generic, Optional, TYPE_CHECKING, TypeVar from azure.core import MatchConditions -from ._configuration import AzureAppConfigurationClientConfiguration - if TYPE_CHECKING: - from azure.core import PipelineClient + from .serialization import Deserializer, Serializer + - from ._serialization import Deserializer, Serializer +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class AzureAppConfigurationClientMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "PipelineClient" - _config: AzureAppConfigurationClientConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_validation.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_version.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_version.py new file mode 100644 index 000000000000..d8aed131ebf1 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.8.2" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py index 7959eac63eaa..f5c918a2126f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py @@ -7,32 +7,38 @@ # -------------------------------------------------------------------------- from copy import deepcopy +import sys from typing import Any, Awaitable, TYPE_CHECKING, Union -from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.credentials import AzureKeyCredential from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import AzureAppConfigurationClientConfiguration -from ._operations import AzureAppConfigurationClientOperationsMixin +from ._operations import _AzureAppConfigurationClientOperationsMixin + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential -class AzureAppConfigurationClient(AzureAppConfigurationClientOperationsMixin): +class AzureAppConfigurationClient(_AzureAppConfigurationClientOperationsMixin): """Azure App Configuration REST API. :param endpoint: Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". + :keyword api_version: The API version to use for this operation. Known values are "2024-09-01" + and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -44,6 +50,7 @@ def __init__( ) -> None: _endpoint = "{endpoint}" self._config = AzureAppConfigurationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py index 6af3e3412b3b..cdd3013454df 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py @@ -11,7 +11,7 @@ from azure.core.credentials import AzureKeyCredential from azure.core.pipeline import policies -from ..._version import VERSION +from .._version import VERSION if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential @@ -25,11 +25,12 @@ class AzureAppConfigurationClientConfiguration: # pylint: disable=too-many-inst :param endpoint: Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". + :keyword api_version: The API version to use for this operation. Known values are "2024-09-01" + and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -37,7 +38,7 @@ class AzureAppConfigurationClientConfiguration: # pylint: disable=too-many-inst def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py index a90b04c612d7..91bafc83f689 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py @@ -12,14 +12,12 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import AzureAppConfigurationClientOperationsMixin # type: ignore +from ._operations import _AzureAppConfigurationClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk -__all__ = [ - "AzureAppConfigurationClientOperationsMixin", -] +__all__ = [] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py index 8c754c8e8a79..8d797711dafc 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,13 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse -from azure.core import MatchConditions +from azure.core import AsyncPipelineClient, MatchConditions from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -34,7 +34,6 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize from ..._operations._operations import ( build_azure_app_configuration_check_key_value_request, build_azure_app_configuration_check_key_values_request, @@ -58,19 +57,18 @@ build_azure_app_configuration_put_lock_request, build_azure_app_configuration_update_snapshot_request, ) -from .._vendor import AzureAppConfigurationClientMixinABC +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.utils import ClientMixinABC +from ..._validation import api_version_validation +from .._configuration import AzureAppConfigurationClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -class AzureAppConfigurationClientOperationsMixin( # pylint: disable=too-many-public-methods,name-too-long - AzureAppConfigurationClientMixinABC +class _AzureAppConfigurationClientOperationsMixin( # pylint: disable=too-many-public-methods + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], AzureAppConfigurationClientConfiguration] ): @distributed_trace @@ -82,7 +80,7 @@ def get_keys( sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.Key"]: + ) -> AsyncItemPaged["_models.Key"]: """Gets a list of keys. Gets a list of keys. @@ -100,13 +98,13 @@ def get_keys( time. Default value is None. :paramtype accept_datetime: str :return: An iterator like instance of Key - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.Key] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration._generated.models.Key] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Key]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Key]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -146,7 +144,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -159,7 +160,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Key], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Key], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, AsyncList(list_of_elem) @@ -175,7 +179,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -187,8 +194,8 @@ async def check_keys( self, *, name: Optional[str] = None, - sync_token: Optional[str] = None, after: Optional[str] = None, + sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, **kwargs: Any ) -> bool: @@ -198,12 +205,12 @@ async def check_keys( :keyword name: A filter for the name of the returned keys. Default value is None. :paramtype name: str - :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is - None. - :paramtype sync_token: str :keyword after: Instructs the server to return elements that appear after the element referred to by the specified token. Default value is None. :paramtype after: str + :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is + None. + :paramtype sync_token: str :keyword accept_datetime: Requests the server to respond with the state of the resource at the specified time. Default value is None. @@ -227,8 +234,8 @@ async def check_keys( _request = build_azure_app_configuration_check_keys_request( name=name, - sync_token=sync_token, after=after, + sync_token=sync_token, accept_datetime=accept_datetime, api_version=self._config.api_version, headers=_headers, @@ -248,7 +255,10 @@ async def check_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -267,22 +277,24 @@ def get_key_values( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any - ) -> AsyncIterable["_models.KeyValue"]: + ) -> AsyncItemPaged["_models.KeyValue"]: """Gets a list of key-values. Gets a list of key-values. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -301,7 +313,8 @@ def get_key_values( the snapshot. Not valid when used with 'key' and 'label' filters. Default value is None. :paramtype snapshot: str :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -309,13 +322,14 @@ def get_key_values( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: An iterator like instance of KeyValue - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyValue] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration._generated.models.KeyValue] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.KeyValue]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.KeyValue]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -367,7 +381,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -380,7 +397,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.KeyValue], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.KeyValue], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, AsyncList(list_of_elem) @@ -396,7 +416,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -412,9 +435,9 @@ async def check_key_values( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -424,10 +447,12 @@ async def check_key_values( Requests the headers and status of the given resource. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -442,11 +467,12 @@ async def check_key_values( :keyword select: Used to select what fields are present in the returned resource(s). Default value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] - :keyword snapshot: A filter used get key-values for a snapshot. Not valid when used with 'key' - and 'label' filters. Default value is None. + :keyword snapshot: A filter used get key-values for a snapshot. The value should be the name of + the snapshot. Not valid when used with 'key' and 'label' filters. Default value is None. :paramtype snapshot: str :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None. + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -505,7 +531,10 @@ async def check_key_values( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -517,14 +546,19 @@ async def check_key_values( return 200 <= response.status_code <= 299 @distributed_trace_async + @api_version_validation( + params_added_on={"2024-09-01": ["tags"]}, + api_versions_list=["2023-11-01", "2024-09-01"], + ) async def get_key_value( self, key: str, *, label: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -547,13 +581,17 @@ async def get_key_value( specified time. Default value is None. :paramtype accept_datetime: str + :keyword tags: A filter used to query by tags. Syntax reference: + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. + :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -581,6 +619,7 @@ async def get_key_value( select=select, sync_token=sync_token, accept_datetime=accept_datetime, + tags=tags, etag=etag, match_condition=match_condition, api_version=self._config.api_version, @@ -592,6 +631,7 @@ async def get_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -606,19 +646,20 @@ async def get_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token")) response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -687,7 +728,7 @@ async def _put_key_value( :type key: str :param entity: The key-value to create. Is one of the following types: KeyValue, JSON, IO[bytes] Default value is None. - :type entity: ~azure.appconfiguration.models.KeyValue or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.KeyValue or JSON or IO[bytes] :keyword label: The label of the key-value to create. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is @@ -699,7 +740,7 @@ async def _put_key_value( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -720,9 +761,10 @@ async def _put_key_value( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if entity else None cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if entity else None _content = None if isinstance(entity, (IOBase, bytes)): _content = entity @@ -749,6 +791,7 @@ async def _put_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -763,7 +806,10 @@ async def _put_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -772,7 +818,7 @@ async def _put_key_value( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -809,7 +855,7 @@ async def delete_key_value( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue or None. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue or None + :rtype: ~azure.appconfiguration._generated.models.KeyValue or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -846,6 +892,7 @@ async def delete_key_value( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -860,7 +907,10 @@ async def delete_key_value( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) deserialized = None @@ -871,7 +921,7 @@ async def delete_key_value( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -884,6 +934,10 @@ async def delete_key_value( return deserialized # type: ignore @distributed_trace_async + @api_version_validation( + params_added_on={"2024-09-01": ["tags"]}, + api_versions_list=["2023-11-01", "2024-09-01"], + ) async def check_key_value( self, key: str, @@ -891,7 +945,8 @@ async def check_key_value( label: Optional[str] = None, sync_token: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any @@ -914,6 +969,10 @@ async def check_key_value( :keyword select: Used to select what fields are present in the returned resource(s). Default value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] + :keyword tags: A filter used to query by tags. Syntax reference: + `https://aka.ms/azconfig/docs/keyvaluefiltering + `_. Default value is None. + :paramtype tags: list[str] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -948,6 +1007,7 @@ async def check_key_value( sync_token=sync_token, accept_datetime=accept_datetime, select=select, + tags=tags, etag=etag, match_condition=match_condition, api_version=self._config.api_version, @@ -968,7 +1028,10 @@ async def check_key_value( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -985,11 +1048,11 @@ def get_snapshots( *, name: Optional[str] = None, after: Optional[str] = None, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, - status: Optional[List[Union[str, _models.SnapshotStatus]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, + status: Optional[list[Union[str, _models.SnapshotStatus]]] = None, sync_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.Snapshot"]: + ) -> AsyncItemPaged["_models.Snapshot"]: """Gets a list of key-value snapshots. Gets a list of key-value snapshots. @@ -1009,13 +1072,14 @@ def get_snapshots( None. :paramtype sync_token: str :return: An iterator like instance of Snapshot - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.Snapshot] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Snapshot]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Snapshot]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1056,7 +1120,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1069,7 +1136,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Snapshot], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Snapshot], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, AsyncList(list_of_elem) @@ -1085,7 +1155,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1144,7 +1217,10 @@ async def check_snapshots( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1159,7 +1235,7 @@ async def get_snapshot( self, name: str, *, - select: Optional[List[Union[str, _models.SnapshotFields]]] = None, + select: Optional[list[Union[str, _models.SnapshotFields]]] = None, sync_token: Optional[str] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1183,7 +1259,7 @@ async def get_snapshot( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.Snapshot + :rtype: ~azure.appconfiguration._generated.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1220,6 +1296,7 @@ async def get_snapshot( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1234,20 +1311,21 @@ async def get_snapshot( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _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["Link"] = self._deserialize("str", response.headers.get("Link")) - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.Snapshot, response.json()) @@ -1265,7 +1343,7 @@ async def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _model :keyword snapshot: Snapshot identifier for the long running operation. Required. :paramtype snapshot: str :return: OperationDetails. The OperationDetails is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.OperationDetails + :rtype: ~azure.appconfiguration._generated.models.OperationDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1292,6 +1370,7 @@ async def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _model } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1306,11 +1385,14 @@ async def get_operation_details(self, *, snapshot: str, **kwargs: Any) -> _model except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.OperationDetails, response.json()) @@ -1362,6 +1444,7 @@ async def _create_snapshot_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1375,7 +1458,10 @@ async def _create_snapshot_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1385,7 +1471,7 @@ async def _create_snapshot_initial( response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1403,7 +1489,7 @@ async def begin_create_snapshot( :param name: The name of the key-value snapshot to create. Required. :type name: str :param entity: The key-value snapshot to create. Required. - :type entity: ~azure.appconfiguration.models.Snapshot + :type entity: ~azure.appconfiguration._generated.models.Snapshot :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Required. :paramtype content_type: str @@ -1412,7 +1498,7 @@ async def begin_create_snapshot( :paramtype sync_token: str :return: An instance of AsyncLROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1436,7 +1522,7 @@ async def begin_create_snapshot( :paramtype sync_token: str :return: An instance of AsyncLROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1461,7 +1547,7 @@ async def begin_create_snapshot( :paramtype sync_token: str :return: An instance of AsyncLROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1482,13 +1568,13 @@ async def begin_create_snapshot( :type name: str :param entity: The key-value snapshot to create. Is one of the following types: Snapshot, JSON, IO[bytes] Required. - :type entity: ~azure.appconfiguration.models.Snapshot or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.Snapshot or JSON or IO[bytes] :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. :paramtype sync_token: str :return: An instance of AsyncLROPoller that returns Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration._generated.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1609,7 +1695,8 @@ async def _update_snapshot( :type name: str :param entity: The parameters used to update the snapshot. Is one of the following types: SnapshotUpdateParameters, JSON, IO[bytes] Required. - :type entity: ~azure.appconfiguration.models.SnapshotUpdateParameters or JSON or IO[bytes] + :type entity: ~azure.appconfiguration._generated.models.SnapshotUpdateParameters or JSON or + IO[bytes] :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. :paramtype sync_token: str @@ -1619,7 +1706,7 @@ async def _update_snapshot( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: Snapshot. The Snapshot is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.Snapshot + :rtype: ~azure.appconfiguration._generated.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1665,6 +1752,7 @@ async def _update_snapshot( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1679,7 +1767,10 @@ async def _update_snapshot( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1689,7 +1780,7 @@ async def _update_snapshot( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.Snapshot, response.json()) @@ -1768,7 +1859,10 @@ async def check_snapshot( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1788,9 +1882,9 @@ def get_labels( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any - ) -> AsyncIterable["_models.Label"]: + ) -> AsyncItemPaged["_models.Label"]: """Gets a list of labels. Gets a list of labels. @@ -1811,13 +1905,14 @@ def get_labels( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.LabelFields] :return: An iterator like instance of Label - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.Label] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration._generated.models.Label] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Label]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.Label]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1858,7 +1953,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1871,7 +1969,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Label], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.Label], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, AsyncList(list_of_elem) @@ -1887,7 +1988,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1902,7 +2006,7 @@ async def check_labels( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.LabelFields]]] = None, + select: Optional[list[Union[str, _models.LabelFields]]] = None, **kwargs: Any ) -> bool: """Requests the headers and status of the given resource. @@ -1965,7 +2069,10 @@ async def check_labels( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2003,7 +2110,7 @@ async def put_lock( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2040,6 +2147,7 @@ async def put_lock( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2054,7 +2162,10 @@ async def put_lock( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2063,7 +2174,7 @@ async def put_lock( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -2100,7 +2211,7 @@ async def delete_lock( :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions :return: KeyValue. The KeyValue is compatible with MutableMapping - :rtype: ~azure.appconfiguration.models.KeyValue + :rtype: ~azure.appconfiguration._generated.models.KeyValue :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2137,6 +2248,7 @@ async def delete_lock( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2151,7 +2263,10 @@ async def delete_lock( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2160,7 +2275,7 @@ async def delete_lock( response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.KeyValue, response.json()) @@ -2178,19 +2293,21 @@ def get_revisions( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any - ) -> AsyncIterable["_models.KeyValue"]: + ) -> AsyncItemPaged["_models.KeyValue"]: """Gets a list of key-value revisions. Gets a list of key-value revisions. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -2206,16 +2323,18 @@ def get_revisions( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype tags: list[str] :return: An iterator like instance of KeyValue - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyValue] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration._generated.models.KeyValue] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.KeyValue]] = kwargs.pop("cls", None) + cls: ClsType[list[_models.KeyValue]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2258,7 +2377,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -2271,7 +2393,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.KeyValue], deserialized["items"]) + list_of_elem = _deserialize( + list[_models.KeyValue], + deserialized.get("items", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("@nextLink") or None, AsyncList(list_of_elem) @@ -2287,7 +2412,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2303,8 +2431,8 @@ async def check_revisions( sync_token: Optional[str] = None, after: Optional[str] = None, accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - tags: Optional[List[str]] = None, + select: Optional[list[Union[str, _models.ConfigurationSettingFields]]] = None, + tags: Optional[list[str]] = None, **kwargs: Any ) -> bool: """Requests the headers and status of the given resource. @@ -2312,10 +2440,12 @@ async def check_revisions( Requests the headers and status of the given resource. :keyword key: A filter used to match keys. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype key: str :keyword label: A filter used to match labels. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype label: str :keyword sync_token: Used to guarantee real-time consistency between requests. Default value is None. @@ -2331,7 +2461,8 @@ async def check_revisions( value is None. :paramtype select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields] :keyword tags: A filter used to query by tags. Syntax reference: - https://aka.ms/azconfig/docs/restapirevisions. Default value is None. + `https://aka.ms/azconfig/docs/restapirevisions + `_. Default value is None. :paramtype tags: list[str] :return: bool :rtype: bool @@ -2376,7 +2507,10 @@ async def check_revisions( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) + error = _failsafe_deserialize( + _models.Error, + response, + ) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py index 72d2e362cfb9..9828067dcb8a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -6,6 +7,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + import json import urllib.parse from typing import Any, List, Optional, Union, MutableMapping, Type diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py index f7dd32510333..455941122974 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py @@ -6,6 +6,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + from typing import List __all__: List[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_vendor.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_vendor.py deleted file mode 100644 index 7ad457cb022b..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_vendor.py +++ /dev/null @@ -1,57 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import Optional, TYPE_CHECKING - -from azure.core import MatchConditions - -from ._configuration import AzureAppConfigurationClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class AzureAppConfigurationClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: AzureAppConfigurationClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" - - -def quote_etag(etag: Optional[str]) -> Optional[str]: - if not etag or etag == "*": - return etag - if etag.startswith("W/"): - return etag - if etag.startswith('"') and etag.endswith('"'): - return etag - if etag.startswith("'") and etag.endswith("'"): - return etag - return '"' + etag + '"' - - -def prep_if_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: - if match_condition == MatchConditions.IfNotModified: - if_match = quote_etag(etag) if etag else None - return if_match - if match_condition == MatchConditions.IfPresent: - return "*" - return None - - -def prep_if_none_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: - if match_condition == MatchConditions.IfModified: - if_none_match = quote_etag(etag) if etag else None - return if_none_match - if match_condition == MatchConditions.IfMissing: - return "*" - return None diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py index f96f5dadd444..3de27b76bd96 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py @@ -93,10 +93,10 @@ class SnapshotStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Snapshot status.""" PROVISIONING = "provisioning" - """Provisioning""" + """Provisioning.""" READY = "ready" - """Ready""" + """Ready.""" ARCHIVED = "archived" - """Archived""" + """Archived.""" FAILED = "failed" - """Failed""" + """Failed.""" 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 5187502a03ec..04e26ae75ac1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py @@ -8,18 +8,17 @@ # pylint: disable=useless-super-delegation import datetime -from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload from azure.core.exceptions import ODataV4Format -from .. import _model_base -from .._model_base import rest_field +from .._utils.model_base import Model as _Model, rest_field if TYPE_CHECKING: from .. import models as _models -class Error(_model_base.Model): +class Error(_Model): """Azure App Configuration error object. :ivar type: The type of the error. @@ -34,15 +33,15 @@ class Error(_model_base.Model): :vartype status: int """ - type: Optional[str] = rest_field() + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The type of the error.""" - title: Optional[str] = rest_field() + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A brief summary of the error.""" - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the parameter that resulted in the error.""" - detail: Optional[str] = rest_field() + detail: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A detailed description of the error.""" - status: Optional[int] = rest_field() + status: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The HTTP status code that the error maps to.""" @overload @@ -67,13 +66,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Key(_model_base.Model): +class Key(_Model): """Keys serve as identifiers for key-values and are used to store and retrieve corresponding values. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the key. Required. :vartype name: str """ @@ -82,12 +78,9 @@ class Key(_model_base.Model): """The name of the key. Required.""" -class KeyValue(_model_base.Model): +class KeyValue(_Model): """A key-value pair representing application settings. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar key: The key of the key-value. Required. :vartype key: str :ivar label: The label the key-value belongs to. @@ -108,19 +101,21 @@ class KeyValue(_model_base.Model): key: str = rest_field(visibility=["read"]) """The key of the key-value. Required.""" - label: Optional[str] = rest_field() + label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The label the key-value belongs to.""" - content_type: Optional[str] = rest_field() + content_type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The content type of the value stored within the key-value.""" - value: Optional[str] = rest_field() + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The value of the key-value.""" - last_modified: Optional[datetime.datetime] = rest_field(format="rfc3339") + last_modified: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """A date representing the last time the key-value was modified.""" - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The tags of the key-value.""" - locked: Optional[bool] = rest_field() + locked: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Indicates whether the key-value is locked.""" - etag: Optional[str] = rest_field() + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A value representing the current state of the resource.""" @overload @@ -131,7 +126,7 @@ def __init__( content_type: Optional[str] = None, value: Optional[str] = None, last_modified: Optional[datetime.datetime] = None, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, locked: Optional[bool] = None, etag: Optional[str] = None, ) -> None: ... @@ -147,10 +142,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class KeyValueFilter(_model_base.Model): +class KeyValueFilter(_Model): """Enables filtering of key-values. Syntax reference: - https://aka.ms/azconfig/docs/restapisnapshots. - + `https://aka.ms/azconfig/docs/restapisnapshots + `_. :ivar key: Filters key-values by their key field. Required. :vartype key: str @@ -160,11 +155,11 @@ class KeyValueFilter(_model_base.Model): :vartype tags: list[str] """ - key: str = rest_field() + key: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Filters key-values by their key field. Required.""" - label: Optional[str] = rest_field() + label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Filters key-values by their label field.""" - tags: Optional[List[str]] = rest_field() + tags: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Filters key-values by their tags field.""" @overload @@ -173,7 +168,7 @@ def __init__( *, key: str, label: Optional[str] = None, - tags: Optional[List[str]] = None, + tags: Optional[list[str]] = None, ) -> None: ... @overload @@ -187,14 +182,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Label(_model_base.Model): +class Label(_Model): """Labels are used to group key-values. :ivar name: The name of the label. :vartype name: str """ - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the label.""" @overload @@ -215,28 +210,28 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OperationDetails(_model_base.Model): +class OperationDetails(_Model): """Details of a long running operation. - :ivar id: The unique id of the operation. Required. :vartype id: str :ivar status: The current status of the operation. Required. Known values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". :vartype status: str or ~azure.appconfiguration.models.OperationState - :ivar error: An error, available when the status is ``Failed``\\ , describing why the operation + :ivar error: An error, available when the status is ``Failed``, describing why the operation failed. :vartype error: ~azure.core.ODataV4Format """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique id of the operation. Required.""" - status: Union[str, "_models.OperationState"] = rest_field() + status: Union[str, "_models.OperationState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The current status of the operation. Required. Known values are: \"NotStarted\", \"Running\", \"Succeeded\", \"Failed\", and \"Canceled\".""" - error: Optional[ODataV4Format] = rest_field() - """An error, available when the status is ``Failed``\ , describing why the operation - failed.""" + error: Optional[ODataV4Format] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An error, available when the status is ``Failed``, describing why the operation failed.""" @overload def __init__( @@ -258,12 +253,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Snapshot(_model_base.Model): +class Snapshot(_Model): """A snapshot is a named, immutable subset of an App Configuration store's key-values. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the snapshot. Required. :vartype name: str :ivar status: The current status of the snapshot. Known values are: "provisioning", "ready", @@ -271,22 +263,19 @@ class Snapshot(_model_base.Model): :vartype status: str or ~azure.appconfiguration.models.SnapshotStatus :ivar filters: A list of filters used to filter the key-values included in the snapshot. Required. - :vartype filters: list[~azure.appconfiguration.models.KeyValueFilter] + :vartype filters: list[~azure.appconfiguration._generated.models.KeyValueFilter] :ivar composition_type: The composition type describes how the key-values within the snapshot - are - composed. The 'key' composition type ensures there are no two key-values - containing the same key. The 'key_label' composition type ensures there are no - two key-values containing the same key and label. Known values are: "key" and "key_label". + are composed. The 'key' composition type ensures there are no two key-values containing the + same key. The 'key_label' composition type ensures there are no two key-values containing the + same key and label. Known values are: "key" and "key_label". :vartype composition_type: str or ~azure.appconfiguration.models.SnapshotComposition :ivar created: The time that the snapshot was created. :vartype created: ~datetime.datetime :ivar expires: The time that the snapshot will expire. :vartype expires: ~datetime.datetime :ivar retention_period: The amount of time, in seconds, that a snapshot will remain in the - archived - state before expiring. This property is only writable during the creation of a - snapshot. If not specified, the default lifetime of key-value revisions will be - used. + archived state before expiring. This property is only writable during the creation of a + snapshot. If not specified, the default lifetime of key-value revisions will be used. :vartype retention_period: int :ivar size: The size in bytes of the snapshot. :vartype size: int @@ -303,27 +292,28 @@ class Snapshot(_model_base.Model): status: Optional[Union[str, "_models.SnapshotStatus"]] = rest_field(visibility=["read"]) """The current status of the snapshot. Known values are: \"provisioning\", \"ready\", \"archived\", and \"failed\".""" - filters: List["_models.KeyValueFilter"] = rest_field() + filters: list["_models.KeyValueFilter"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A list of filters used to filter the key-values included in the snapshot. Required.""" - composition_type: Optional[Union[str, "_models.SnapshotComposition"]] = rest_field() - """The composition type describes how the key-values within the snapshot are - composed. The 'key' composition type ensures there are no two key-values - containing the same key. The 'key_label' composition type ensures there are no - two key-values containing the same key and label. Known values are: \"key\" and \"key_label\".""" + composition_type: Optional[Union[str, "_models.SnapshotComposition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The composition type describes how the key-values within the snapshot are composed. The 'key' + composition type ensures there are no two key-values containing the same key. The 'key_label' + composition type ensures there are no two key-values containing the same key and label. Known + values are: \"key\" and \"key_label\".""" created: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") """The time that the snapshot was created.""" expires: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") """The time that the snapshot will expire.""" - retention_period: Optional[int] = rest_field() - """The amount of time, in seconds, that a snapshot will remain in the archived - state before expiring. This property is only writable during the creation of a - snapshot. If not specified, the default lifetime of key-value revisions will be - used.""" + retention_period: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The amount of time, in seconds, that a snapshot will remain in the archived state before + expiring. This property is only writable during the creation of a snapshot. If not specified, + the default lifetime of key-value revisions will be used.""" size: Optional[int] = rest_field(visibility=["read"]) """The size in bytes of the snapshot.""" items_count: Optional[int] = rest_field(visibility=["read"]) """The amount of key-values in the snapshot.""" - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The tags of the snapshot.""" etag: Optional[str] = rest_field(visibility=["read"]) """A value representing the current state of the snapshot.""" @@ -332,10 +322,10 @@ class Snapshot(_model_base.Model): def __init__( self, *, - filters: List["_models.KeyValueFilter"], + filters: list["_models.KeyValueFilter"], composition_type: Optional[Union[str, "_models.SnapshotComposition"]] = None, retention_period: Optional[int] = None, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, ) -> None: ... @overload @@ -349,7 +339,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SnapshotUpdateParameters(_model_base.Model): +class SnapshotUpdateParameters(_Model): """Parameters used to update a snapshot. :ivar status: The desired status of the snapshot. Known values are: "provisioning", "ready", @@ -357,7 +347,9 @@ class SnapshotUpdateParameters(_model_base.Model): :vartype status: str or ~azure.appconfiguration.models.SnapshotStatus """ - status: Optional[Union[str, "_models.SnapshotStatus"]] = rest_field() + status: Optional[Union[str, "_models.SnapshotStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The desired status of the snapshot. Known values are: \"provisioning\", \"ready\", \"archived\", and \"failed\".""" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py index 4c3ef970b6f9..c0d3c00329a7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py @@ -6,6 +6,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + import datetime from typing import Any, Dict, List, Mapping, Optional, overload diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py index c664aa3902d1..d8aed131ebf1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py @@ -1,6 +1,9 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- VERSION = "1.8.2" diff --git a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml index e9b975a7d2b3..56f627d7c113 100644 --- a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml +++ b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml @@ -1,3 +1,63 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +[build-system] +requires = ["setuptools>=77.0.3", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-appconfiguration" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Corporation Azure App Configuration Data Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.10" +keywords = ["azure", "azure sdk"] + +dependencies = [ + "isodate>=0.6.1", + "azure-core>=1.37.0", + "typing-extensions>=4.6.0", +] +dynamic = [ +"version", "readme" +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic] +version = {attr = "azure.appconfiguration._version.VERSION"} +readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", +] + +[tool.setuptools.package-data] +pytyped = ["py.typed"] + [tool.azure-sdk-build] pyright = false black = true diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/check_configuration_settings_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/check_configuration_settings_sample.py index 3e87d03c14a3..ddbcb21ecf28 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/check_configuration_settings_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/check_configuration_settings_sample.py @@ -19,6 +19,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_ENDPOINT_STRING: Endpoint URL used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting from azure.identity import DefaultAzureCredential diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample.py index b3d433567c49..b890f00ebefa 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.core import MatchConditions from azure.core.exceptions import ResourceModifiedError diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample_async.py index e8a0e977d4df..c97fb4aaf469 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio import os from azure.core import MatchConditions diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_entra_id_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_entra_id_sample.py index 91ecbd5ff622..eb2e7c32eefa 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_entra_id_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_entra_id_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_ENDPOINT_STRING: Endpoint URL used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient from azure.identity import DefaultAzureCredential diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample.py index 431a8bc63e15..c9d6225ee6f7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py index 216373ee0f06..a4e2c12fb3dd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_entra_id_and_bleu.py b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_entra_id_and_bleu.py index 2a433764fb2a..1f32e4ecce61 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_entra_id_and_bleu.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_entra_id_and_bleu.py @@ -21,10 +21,10 @@ 2) AZURE_TENANT_ID: Your Azure tenant ID 3) AZURE_CLIENT_ID: Your application (client) ID 4) AZURE_CLIENT_SECRET: Your application client secret - + For Azure Bleu (French Sovereign Cloud): - Use audience: ["https://appconfig.sovcloud-api.fr/"] - + DefaultAzureCredential will attempt multiple authentication methods: - Environment variables (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET) - Managed Identity @@ -33,6 +33,7 @@ - Azure PowerShell - Interactive browser """ + import os from azure.appconfiguration import AzureAppConfigurationClient from azure.identity import DefaultAzureCredential diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample.py index 8cf04f3fe128..4aafd0c6ad9b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample_async.py index 27e402ab5b1f..22060ef3d14b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os import asyncio from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample.py index dd6cdd6b9164..e50b9b5c1501 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample_async.py index d36648445451..ef3334ac1719 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_labels_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os import asyncio from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample.py index defee06696a8..ddc8f7d1ae1e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample_async.py index 0ffdc2f38751..44ffaf91dec2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio import os from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample.py index 693fe1319496..b1db4cee4152 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample_async.py index 46b4137a2fe1..81f551ec6a63 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio import os from azure.appconfiguration import ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample.py index 8af04ce58f40..04d97c198045 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample.py @@ -18,6 +18,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient from azure.core.rest import HttpRequest diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample_async.py index 2995e74c4f77..8f86b1e762cd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample_async.py @@ -18,6 +18,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os import asyncio from azure.appconfiguration.aio import AzureAppConfigurationClient diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py index a6ab605d83fe..7401ab9caf7e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py @@ -18,6 +18,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from uuid import uuid4 from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py index 9e1e33b755e7..7f6e88eab4d0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py @@ -18,6 +18,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio import os from uuid import uuid4 diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample.py index 14ded09f388b..b1dd9b96ed1c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample.py @@ -18,6 +18,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import os from azure.appconfiguration import AzureAppConfigurationClient diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample_async.py index feb44c8a3e29..9c6d53c6cdef 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample_async.py @@ -17,6 +17,7 @@ Set the environment variables with your own values before running the sample: 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. """ + import asyncio import os from azure.appconfiguration.aio import AzureAppConfigurationClient diff --git a/sdk/appconfiguration/azure-appconfiguration/setup.py b/sdk/appconfiguration/azure-appconfiguration/setup.py index 4ad4795294bf..7dade117cd06 100644 --- a/sdk/appconfiguration/azure-appconfiguration/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration/setup.py @@ -11,7 +11,6 @@ import re from setuptools import setup, find_packages - PACKAGE_NAME = "azure-appconfiguration" PACKAGE_PPRINT_NAME = "App Configuration Data" diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/consts.py b/sdk/appconfiguration/azure-appconfiguration/tests/consts.py index c3e6f3844033..a8ac91d7f957 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/consts.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/consts.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client.py index 93a2b4c43ee4..06a63556e8a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_async.py index bbef9e6ae47c..30fa05d74422 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_async.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml b/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml index b9dd8df85061..6de65d0ad69b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml +++ b/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml @@ -1,4 +1,4 @@ -commit: 809688280b9cfd5f6e1da2c645408f3a7ef3d6b8 +commit: 337bb8679bad87f26c74183095df1a0e0967d3b7 repo: Azure/azure-rest-api-specs directory: specification/appconfiguration/data-plane/AppConfiguration additionalDirectories: \ No newline at end of file From c8c513a7048eacb2dcda9e4f9e4906122b9fb237 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 27 May 2026 14:27:27 -0700 Subject: [PATCH 2/5] Fix Patch and updated tests assets --- .../azure-appconfiguration/assets.json | 2 +- .../_generated/_operations/_patch.py | 2 +- .../azure/appconfiguration/_generated/_patch.py | 12 ++++++++++++ .../_generated/aio/_operations/_patch.py | 2 +- .../azure/appconfiguration/_generated/aio/_patch.py | 7 +++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/assets.json b/sdk/appconfiguration/azure-appconfiguration/assets.json index 56fc3830c789..10e27f7102b2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration", - "Tag": "python/appconfiguration/azure-appconfiguration_ea09ae1741" + "Tag": "python/appconfiguration/azure-appconfiguration_e331595b65" } diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py index 02bbb8fbd0fb..aa59b8bbfd41 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py @@ -27,7 +27,7 @@ from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from ._operations import ( - AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, + _AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, ClsType, build_azure_app_configuration_get_key_values_request, build_azure_app_configuration_check_key_values_request, diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py index 455941122974..8d9f67346ac1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py @@ -19,3 +19,15 @@ def patch_sdk(): you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """ + # The generated ``AzureAppConfigurationClient`` subclasses the raw + # ``_AzureAppConfigurationClientOperationsMixin``. The customizations in + # ``_operations/_patch.py`` live on a separate ``AzureAppConfigurationClientOperationsMixin`` + # subclass that the generated client does not pick up. Copy the customized + # members onto the raw mixin so the generated client inherits them. + from ._operations._patch import AzureAppConfigurationClientOperationsMixin as _Patched + from ._operations._operations import _AzureAppConfigurationClientOperationsMixin as _Raw + + for _name, _attr in vars(_Patched).items(): + if _name in ("__dict__", "__weakref__", "__doc__", "__module__", "__qualname__"): + continue + setattr(_Raw, _name, _attr) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py index 9828067dcb8a..a5c082e7d795 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py @@ -25,7 +25,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ._operations import ( - AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, + _AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, ClsType, build_azure_app_configuration_get_key_values_request, build_azure_app_configuration_check_key_values_request, diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py index 455941122974..52c816c9f012 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py @@ -19,3 +19,10 @@ def patch_sdk(): you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """ + from ._operations._patch import AzureAppConfigurationClientOperationsMixin as _Patched + from ._operations._operations import _AzureAppConfigurationClientOperationsMixin as _Raw + + for _name, _attr in vars(_Patched).items(): + if _name in ("__dict__", "__weakref__", "__doc__", "__module__", "__qualname__"): + continue + setattr(_Raw, _name, _attr) From c35abd451da2158d942acab530e3fc950df0ab26 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 1 Jun 2026 13:16:33 -0700 Subject: [PATCH 3/5] Code review items --- .../azure-appconfiguration/assets.json | 2 +- .../_generated/_operations/_patch.py | 4 +- .../_generated/aio/_operations/_patch.py | 4 +- .../_generated/models/_patch.py | 4 +- .../azure/appconfiguration/_models.py | 4 +- .../azure-appconfiguration/pyproject.toml | 2 +- .../azure-appconfiguration/setup.py | 69 ------------------- 7 files changed, 10 insertions(+), 79 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration/setup.py diff --git a/sdk/appconfiguration/azure-appconfiguration/assets.json b/sdk/appconfiguration/azure-appconfiguration/assets.json index 10e27f7102b2..56df8ec329c9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration", - "Tag": "python/appconfiguration/azure-appconfiguration_e331595b65" + "Tag": "python/appconfiguration/azure-appconfiguration_c861e54b5f" } diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py index aa59b8bbfd41..b9daa955827e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py @@ -35,8 +35,8 @@ prep_if_none_match, ) from .. import models as _models -from .._model_base import _deserialize -from .._serialization import Serializer +from .._utils.model_base import _deserialize +from .._utils.serialization import Serializer _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py index a5c082e7d795..5aad6e13e78b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py @@ -32,8 +32,8 @@ ) from ..._operations._operations import prep_if_match, prep_if_none_match from ... import models as _models -from ..._model_base import _deserialize -from ..._serialization import Serializer +from ..._utils.model_base import _deserialize +from ..._utils.serialization import Serializer _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py index c0d3c00329a7..11f59a657781 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py @@ -10,8 +10,8 @@ import datetime from typing import Any, Dict, List, Mapping, Optional, overload -from .. import _model_base -from .._model_base import rest_field +from .._utils import model_base as _model_base +from .._utils.model_base import rest_field class KeyValue(_model_base.Model): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index a53e343f984a..2662ae2bcd8f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpResponse from azure.core.paging import PageIterator, ItemPaged from azure.core.async_paging import AsyncPageIterator, AsyncItemPaged, AsyncList -from ._generated._serialization import Model +from ._generated._utils.serialization import Model from ._generated.models import ( KeyValue, KeyValueFilter, @@ -20,7 +20,7 @@ SnapshotStatus, SnapshotComposition, ) -from ._generated._model_base import _deserialize +from ._generated._utils.model_base import _deserialize ReturnType = TypeVar("ReturnType") diff --git a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml index 56f627d7c113..e29bfbd053b1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml +++ b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml @@ -17,7 +17,7 @@ authors = [ description = "Microsoft Corporation Azure App Configuration Data Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", diff --git a/sdk/appconfiguration/azure-appconfiguration/setup.py b/sdk/appconfiguration/azure-appconfiguration/setup.py deleted file mode 100644 index 7dade117cd06..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -import os -import re -from setuptools import setup, find_packages - -PACKAGE_NAME = "azure-appconfiguration" -PACKAGE_PPRINT_NAME = "App Configuration Data" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - ] - ), - include_package_data=True, - package_data={ - "azure.appconfiguration": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-core>=1.30.0", - "typing-extensions>=4.6.0", - ], - python_requires=">=3.8", -) From 7a1bd524b26183298fccd9dbcab2dc50157bfb39 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 1 Jun 2026 14:12:11 -0700 Subject: [PATCH 4/5] fixing pylint issue --- .../appconfiguration/_azure_appconfiguration_client.py | 6 +++--- .../aio/_azure_appconfiguration_client_async.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 da75582583ba..13568fee5206 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -237,7 +237,7 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> Co snapshot_name = kwargs.pop("snapshot_name", None) if snapshot_name is not None: - command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return ConfigurationSettingPaged( command, snapshot=snapshot_name, @@ -248,7 +248,7 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> Co tags = kwargs.pop("tags_filter", None) key_filter, kwargs = get_key_filter(*args, **kwargs) label_filter, kwargs = get_label_filter(*args, **kwargs) - command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return ConfigurationSettingPaged( command, key=key_filter, @@ -300,7 +300,7 @@ def check_configuration_settings( """ if isinstance(accept_datetime, datetime): accept_datetime = str(accept_datetime) - command = functools.partial(self._impl.check_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.check_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return ConfigurationSettingPaged( command, key=key_filter, diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py index 67082cc03e54..7cbf38af5b62 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py @@ -243,7 +243,7 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> As snapshot_name = kwargs.pop("snapshot_name", None) if snapshot_name is not None: - command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return AsyncConfigurationSettingPaged( command, snapshot=snapshot_name, @@ -254,7 +254,7 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> As tags = kwargs.pop("tags_filter", None) key_filter, kwargs = get_key_filter(*args, **kwargs) label_filter, kwargs = get_label_filter(*args, **kwargs) - command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return AsyncConfigurationSettingPaged( command, key=key_filter, @@ -308,7 +308,7 @@ def check_configuration_settings( if isinstance(accept_datetime, datetime): accept_datetime = str(accept_datetime) - command = functools.partial(self._impl.check_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] + command = functools.partial(self._impl.check_key_values_in_one_page, **kwargs) # type: ignore[attr-defined] # pylint: disable=no-member return AsyncConfigurationSettingPaged( command, key=key_filter, From 270e6729573d0890b019fc5ee51df7e887528e37 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 3 Jun 2026 12:47:07 -0700 Subject: [PATCH 5/5] review items --- .../_generated/_operations/_patch.py | 4 ++-- .../azure/appconfiguration/_generated/_patch.py | 12 ------------ .../_generated/aio/_operations/_patch.py | 4 ++-- .../azure/appconfiguration/_generated/aio/_patch.py | 7 ------- .../azure-appconfiguration/pyproject.toml | 1 + 5 files changed, 5 insertions(+), 23 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py index b9daa955827e..e5fd5ebe5f28 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py @@ -42,7 +42,7 @@ _SERIALIZER.client_side_validation = False -class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): +class _AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): def _build_kv_error_map( self, match_condition: Optional[MatchConditions], @@ -354,7 +354,7 @@ def check_key_values_in_one_page( __all__: List[str] = [ - "AzureAppConfigurationClientOperationsMixin" + "_AzureAppConfigurationClientOperationsMixin" ] # Add all objects you want publicly available to users at this package level diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py index 8d9f67346ac1..455941122974 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py @@ -19,15 +19,3 @@ def patch_sdk(): you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """ - # The generated ``AzureAppConfigurationClient`` subclasses the raw - # ``_AzureAppConfigurationClientOperationsMixin``. The customizations in - # ``_operations/_patch.py`` live on a separate ``AzureAppConfigurationClientOperationsMixin`` - # subclass that the generated client does not pick up. Copy the customized - # members onto the raw mixin so the generated client inherits them. - from ._operations._patch import AzureAppConfigurationClientOperationsMixin as _Patched - from ._operations._operations import _AzureAppConfigurationClientOperationsMixin as _Raw - - for _name, _attr in vars(_Patched).items(): - if _name in ("__dict__", "__weakref__", "__doc__", "__module__", "__qualname__"): - continue - setattr(_Raw, _name, _attr) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py index 5aad6e13e78b..38ce6e38aac8 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py @@ -39,7 +39,7 @@ _SERIALIZER.client_side_validation = False -class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): +class _AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): def _build_kv_error_map( self, match_condition: Optional[MatchConditions], @@ -347,7 +347,7 @@ async def check_key_values_in_one_page( __all__: List[str] = [ - "AzureAppConfigurationClientOperationsMixin" + "_AzureAppConfigurationClientOperationsMixin" ] # Add all objects you want publicly available to users at this package level diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py index 52c816c9f012..455941122974 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py @@ -19,10 +19,3 @@ def patch_sdk(): you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """ - from ._operations._patch import AzureAppConfigurationClientOperationsMixin as _Patched - from ._operations._operations import _AzureAppConfigurationClientOperationsMixin as _Raw - - for _name, _attr in vars(_Patched).items(): - if _name in ("__dict__", "__weakref__", "__doc__", "__module__", "__qualname__"): - continue - setattr(_Raw, _name, _attr) diff --git a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml index e29bfbd053b1..1d937239979e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/pyproject.toml +++ b/sdk/appconfiguration/azure-appconfiguration/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] requires-python = ">=3.10" keywords = ["azure", "azure sdk"]