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..388d1c32d0a2 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/_metadata.json @@ -0,0 +1,7 @@ +{ + "apiVersion": "2023-11-01", + "commit": "4dfa9d8a653b7bc568485929b5d1d17385be5ab0", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/appconfiguration/AppConfiguration", + "emitterVersion": "0.47.0" +} \ 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..d7ff9cb3fdfb --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/apiview-properties.json @@ -0,0 +1,57 @@ +{ + "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" + } +} \ 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/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py index 4dd855d6d711..e478141d10e9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py @@ -1,50 +1,32 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# 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=wrong-import-position -from ._azure_appconfiguration_client import AzureAppConfigurationClient -from ._constants import FILTER_PERCENTAGE, FILTER_TARGETING, FILTER_TIME_WINDOW -from ._models import ( - ConfigurationSetting, - FeatureFlagConfigurationSetting, - SecretReferenceConfigurationSetting, - ConfigurationSettingsFilter, - ConfigurationSnapshot, - ConfigurationSettingLabel, -) -from ._generated.models import ( - SnapshotStatus, - LabelFields, - SnapshotFields, - ConfigurationSettingFields, - SnapshotComposition, -) +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import AzureAppConfigurationClient # type: ignore from ._version import VERSION -from ._azure_appconfiguration_error import ResourceReadOnlyError __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + __all__ = [ "AzureAppConfigurationClient", - "ConfigurationSetting", - "ResourceReadOnlyError", - "FeatureFlagConfigurationSetting", - "SecretReferenceConfigurationSetting", - "ConfigurationSnapshot", - "SnapshotStatus", - "SnapshotFields", - "SnapshotComposition", - "LabelFields", - "ConfigurationSettingFields", - "ConfigurationSettingsFilter", - "ConfigurationSettingLabel", - "FILTER_PERCENTAGE", - "FILTER_TARGETING", - "FILTER_TIME_WINDOW", ] +__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/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py deleted file mode 100644 index 538b507114fc..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ /dev/null @@ -1,774 +0,0 @@ -# ------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# ------------------------------------------------------------------------- -import functools -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, overload, cast -from azure.core import MatchConditions -from azure.core.paging import ItemPaged -from azure.core.credentials import TokenCredential, AzureKeyCredential -from azure.core.pipeline.policies import BearerTokenCredentialPolicy -from azure.core.polling import LROPoller -from azure.core.tracing.decorator import distributed_trace -from azure.core.exceptions import ResourceNotModifiedError -from azure.core.rest import HttpRequest, HttpResponse -from ._azure_appconfiguration_error import ResourceReadOnlyError -from ._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy -from ._generated import AzureAppConfigurationClient as AzureAppConfigurationClientGenerated -from ._generated.models import ( - SnapshotStatus, - SnapshotFields, - SnapshotComposition, - LabelFields, - ConfigurationSettingFields, - SnapshotUpdateParameters, -) -from ._models import ( - ConfigurationSetting, - ConfigurationSettingPropertiesPaged, - ConfigurationSettingsFilter, - ConfigurationSnapshot, - ConfigurationSettingLabel, -) -from ._utils import ( - get_key_filter, - get_label_filter, - parse_connection_string, -) -from ._sync_token import SyncTokenPolicy - - -class AzureAppConfigurationClient: - """Represents a client that calls restful API of Azure App Configuration service. - - :param str base_url: Base url of the service. - :param credential: An object which can provide secrets for the app configuration service - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default - value may result in unsupported behavior. - :paramtype api_version: str - - """ - - # pylint:disable=protected-access - def __init__(self, base_url: str, credential: TokenCredential, **kwargs: Any) -> None: - try: - if not base_url.lower().startswith("http"): - base_url = f"https://{base_url}" - except AttributeError as exc: - raise ValueError("Base URL must be a string.") from exc - - if not credential: - raise ValueError("Missing credential") - - credential_scopes = [f"{base_url.strip('/')}/.default"] - self._sync_token_policy = SyncTokenPolicy() - - if isinstance(credential, AzureKeyCredential): - id_credential = kwargs.pop("id_credential") - kwargs.update( - { - "authentication_policy": AppConfigRequestsCredentialsPolicy(credential, base_url, id_credential), - } - ) - elif isinstance(credential, TokenCredential): - kwargs.update( - { - "authentication_policy": BearerTokenCredentialPolicy(credential, *credential_scopes, **kwargs), - } - ) - else: - raise TypeError( - f"Unsupported credential: {type(credential)}. Use an instance of token credential from azure.identity" - ) - # mypy doesn't compare the credential type hint with the API surface in patch.py - self._impl = AzureAppConfigurationClientGenerated( - base_url, credential, per_call_policies=self._sync_token_policy, **kwargs # type: ignore[arg-type] - ) - - @classmethod - def from_connection_string(cls, connection_string: str, **kwargs: Any) -> "AzureAppConfigurationClient": - """Create AzureAppConfigurationClient from a Connection String. - - :param str connection_string: Connection String - (one of the access keys of the Azure App Configuration resource) - used to access the Azure App Configuration. - :return: An AzureAppConfigurationClient authenticated with the connection string - :rtype: ~azure.appconfiguration.AzureAppConfigurationClient - - Example - - .. code-block:: python - - from azure.appconfiguration import AzureAppConfigurationClient - - connection_str = "" - client = AzureAppConfigurationClient.from_connection_string(connection_str) - """ - endpoint, id_credential, secret = parse_connection_string(connection_string) - # AzureKeyCredential type is for internal use, it's not exposed in public API. - return cls( - credential=AzureKeyCredential(secret), # type: ignore[arg-type] - base_url=endpoint, - id_credential=id_credential, - **kwargs, - ) - - @distributed_trace - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs a network request using the client's existing pipeline. - - The request URL can be relative to the vault URL. The service API version used for the request is the same as - the client's unless otherwise specified. This method does not raise if the response is an error; to raise an - exception, call `raise_for_status()` on the returned response object. For more information about how to send - custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request. - - :param request: The network request you want to make. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - return self._impl.send_request(request, stream=stream, **kwargs) - - @overload - def list_configuration_settings( - self, - *, - key_filter: Optional[str] = None, - label_filter: Optional[str] = None, - tags_filter: Optional[List[str]] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> ItemPaged[ConfigurationSetting]: - """List the configuration settings stored in the configuration service, optionally filtered by - key, label, tags and accept_datetime. For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-key-value?pivots=v23-11#supported-filters. - - :keyword key_filter: Filter results based on their keys. '*' can be used as wildcard in the beginning or end - of the filter. - :paramtype key_filter: str or None - :keyword label_filter: Filter results based on their label. '*' can be used as wildcard in the beginning or end - of the filter. - :paramtype label_filter: str or None - :keyword tags_filter: Filter results based on their tags. - :paramtype tags_filter: list[str] or None - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError` - - Example - - .. code-block:: python - - from datetime import datetime, timedelta - - accept_datetime = datetime.utcnow() + timedelta(days=-1) - - all_listed = client.list_configuration_settings() - for item in all_listed: - pass # do something - - filtered_listed = client.list_configuration_settings( - label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime) - ) - for item in filtered_listed: - pass # do something - """ - - @overload - def list_configuration_settings( - self, - *, - snapshot_name: str, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> ItemPaged[ConfigurationSetting]: - """List the configuration settings stored under a snapshot in the configuration service, optionally filtered by - fields to present in return. - - :keyword str snapshot_name: The snapshot name. - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - - @distributed_trace - def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> ItemPaged[ConfigurationSetting]: - accept_datetime = kwargs.pop("accept_datetime", None) - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - select = kwargs.pop("fields", None) - if select: - select = ["locked" if x == "read_only" else x for x in select] - snapshot_name = kwargs.pop("snapshot_name", None) - - if snapshot_name is not None: - return self._impl.get_key_values( # type: ignore[return-value] - snapshot=snapshot_name, - accept_datetime=accept_datetime, - select=select, - cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs], - **kwargs, - ) - 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] - return ItemPaged( - command, - key=key_filter, - label=label_filter, - accept_datetime=accept_datetime, - select=select, - tags=tags, - page_iterator_class=ConfigurationSettingPropertiesPaged, - ) - - @distributed_trace - def get_configuration_setting( - self, - key: str, - label: Optional[str] = None, - etag: Optional[str] = "*", - match_condition: MatchConditions = MatchConditions.Unconditionally, - *, - accept_datetime: Optional[Union[datetime, str]] = None, - **kwargs: Any, - ) -> Union[None, ConfigurationSetting]: - """Get the matched ConfigurationSetting from Azure App Configuration service - - :param key: Key of the ConfigurationSetting - :type key: str - :param label: Label used to identify the ConfigurationSetting. Default is `None`. - :type label: str or None - :param etag: Check if the ConfigurationSetting is changed. Set None to skip checking etag - :type etag: str or None - :param match_condition: The match condition to use upon the etag - :type match_condition: ~azure.core.MatchConditions - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :return: The matched ConfigurationSetting object - :rtype: ~azure.appconfiguration.ConfigurationSetting or None - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - fetched_config_setting = client.get_configuration_setting( - key="MyKey", label="MyLabel" - ) - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - try: - key_value = self._impl.get_key_value( - key=key, - label=label, - accept_datetime=accept_datetime, - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value) - except ResourceNotModifiedError: - return None - - @distributed_trace - def add_configuration_setting( - self, configuration_setting: ConfigurationSetting, **kwargs: Any - ) -> ConfigurationSetting: - """Add a ConfigurationSetting instance into the Azure App Configuration service. - - :param configuration_setting: The ConfigurationSetting object to be added - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :return: The ConfigurationSetting object returned from the App Configuration service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - config_setting = ConfigurationSetting( - key="MyKey", - label="MyLabel", - value="my value", - content_type="my content type", - tags={"my tag": "my tag value"} - ) - added_config_setting = client.add_configuration_setting(config_setting) - """ - key_value = configuration_setting._to_generated() - key_value_added = self._impl._put_key_value( - entity=key_value, - key=key_value.key, # type: ignore - label=key_value.label, - match_condition=MatchConditions.IfMissing, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value_added) - - @distributed_trace - def set_configuration_setting( - self, - configuration_setting: ConfigurationSetting, - match_condition: MatchConditions = MatchConditions.Unconditionally, - *, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSetting: - """Add or update a ConfigurationSetting. - If the configuration setting identified by key and label does not exist, this is a create. - Otherwise this is an update. - - :param configuration_setting: The ConfigurationSetting to be added (if not exists) \ - or updated (if exists) to the service - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :param match_condition: The match condition to use upon the etag - :type match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSetting is changed. \ - Will use the value from param configuration_setting if not set. - :paramtype etag: str or None - :return: The ConfigurationSetting returned from the service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \ - :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - config_setting = ConfigurationSetting( - key="MyKey", - label="MyLabel", - value="my set value", - content_type="my set content type", - tags={"my set tag": "my set tag value"} - ) - returned_config_setting = client.set_configuration_setting(config_setting) - """ - key_value = configuration_setting._to_generated() - error_map: Dict[int, Any] = {409: ResourceReadOnlyError} - key_value_set = self._impl._put_key_value( - entity=key_value, - key=key_value.key, # type: ignore - label=key_value.label, - etag=etag or configuration_setting.etag, - match_condition=match_condition, - error_map=error_map, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value_set) - - @distributed_trace - def delete_configuration_setting( # pylint:disable=delete-operation-wrong-return-type - self, - key: str, - label: Optional[str] = None, - *, - etag: Optional[str] = None, - match_condition: MatchConditions = MatchConditions.Unconditionally, - **kwargs: Any, - ) -> Union[None, ConfigurationSetting]: - """Delete a ConfigurationSetting if it exists - - :param key: Key used to identify the ConfigurationSetting - :type key: str - :param label: Label used to identify the ConfigurationSetting. Default is `None`. - :type label: str or None - :keyword etag: Check if the ConfigurationSetting is changed. Set None to skip checking etag - :paramtype etag: str or None - :keyword match_condition: The match condition to use upon the etag - :paramtype match_condition: ~azure.core.MatchConditions - :return: The deleted ConfigurationSetting returned from the service, or None if it doesn't exist. - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \ - :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - deleted_config_setting = client.delete_configuration_setting( - key="MyKey", label="MyLabel" - ) - """ - error_map: Dict[int, Any] = {409: ResourceReadOnlyError} - key_value_deleted = self._impl.delete_key_value( - key=key, - label=label, - etag=etag, - match_condition=match_condition, - error_map=error_map, - **kwargs, - ) - if key_value_deleted: - return ConfigurationSetting._from_generated(key_value_deleted) - return None - - @distributed_trace - def list_revisions( - self, - key_filter: Optional[str] = None, - label_filter: Optional[str] = None, - *, - tags_filter: Optional[List[str]] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> ItemPaged[ConfigurationSetting]: - """ - Find the ConfigurationSetting revision history, optionally filtered by key, label, tags and accept_datetime. - For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters. - - :param key_filter: Filter results based on their keys. '*' can be used as wildcard in the beginning or end - of the filter. - :type key_filter: str or None - :param label_filter: Filter results based on their label. '*' can be used as wildcard in the beginning or end - of the filter. - :type label_filter: str or None - :keyword tags_filter: Filter results based on their tags. - :paramtype tags_filter: list[str] or None - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError` - - Example - - .. code-block:: python - - from datetime import datetime, timedelta - - accept_datetime = datetime.utcnow() + timedelta(days=-1) - - all_revisions = client.list_revisions() - for item in all_revisions: - pass # do something - - filtered_revisions = client.list_revisions( - label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime) - ) - for item in filtered_revisions: - pass # do something - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - if fields: - fields = ["locked" if x == "read_only" else x for x in fields] - - return self._impl.get_revisions( # type: ignore[return-value] - label=label_filter, - key=key_filter, - accept_datetime=accept_datetime, - select=fields, - tags=tags_filter, - cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs], - **kwargs, - ) - - @distributed_trace - def set_read_only( - self, - configuration_setting: ConfigurationSetting, - read_only: bool = True, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - **kwargs: Any, - ) -> ConfigurationSetting: - """Set a configuration setting read only - - :param configuration_setting: The ConfigurationSetting to be set read only - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :param read_only: Set the read only setting if true, else clear the read only setting - :type read_only: bool - :keyword match_condition: The match condition to use upon the etag - :paramtype match_condition: ~azure.core.MatchConditions - :return: The ConfigurationSetting returned from the service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError` - - Example - - .. code-block:: python - - config_setting = client.get_configuration_setting( - key="MyKey", label="MyLabel" - ) - - read_only_config_setting = client.set_read_only(config_setting) - read_only_config_setting = client.set_read_only(config_setting, read_only=False) - """ - if read_only: - key_value = self._impl.put_lock( - key=configuration_setting.key, - label=configuration_setting.label, - etag=configuration_setting.etag, - match_condition=match_condition, - **kwargs, - ) - else: - key_value = self._impl.delete_lock( - key=configuration_setting.key, - label=configuration_setting.label, - etag=configuration_setting.etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value) - - @distributed_trace - def list_labels( - self, - *, - name: Optional[str] = None, - after: Optional[str] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, LabelFields]]] = None, - **kwargs: Any, - ) -> ItemPaged[ConfigurationSettingLabel]: - """Gets a list of labels. - - :keyword name: A filter for the name of the returned labels. '*' can be used as wildcard - in the beginning or end of the filter. For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-labels?pivots=v23-11#supported-filters. - :paramtype name: str or None - :keyword after: Instructs the server to return elements that appear after the element referred to - by the specified token. - :paramtype after: str or None - :keyword accept_datetime: Requests the server to respond with the state of the resource at the - specified time. - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.LabelFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.LabelFields] or None - :return: An iterator of labels. - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSettingLabel] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - return self._impl.get_labels( # type: ignore[return-value] - name=name, - after=after, - accept_datetime=accept_datetime, - select=fields, - cls=lambda objs: [ConfigurationSettingLabel(name=x.name) for x in objs], - **kwargs, - ) - - @distributed_trace - def begin_create_snapshot( - self, - name: str, - filters: List[ConfigurationSettingsFilter], - *, - composition_type: Optional[Union[str, SnapshotComposition]] = None, - retention_period: Optional[int] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any, - ) -> LROPoller[ConfigurationSnapshot]: - """Create a snapshot of the configuration settings. - - :param name: The name of the configuration snapshot to create. - :type name: str - :param filters: A list of filters used to filter the configuration settings by key field and label field - included in the configuration snapshot. - :type filters: list[~azure.appconfiguration.ConfigurationSettingsFilter] - :keyword composition_type: The composition type describes how the key-values within the configuration - snapshot are composed. Known values are: "key" and "key_label". 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. - :paramtype composition_type: str or ~azure.appconfiguration.SnapshotComposition or None - :keyword retention_period: The amount of time, in seconds, that a configuration snapshot will remain in the - archived state before expiring. This property is only writable during the creation of a configuration - snapshot. If not specified, will set to 2592000(30 days). If specified, should be - in range 3600(1 hour) to 7776000(90 days). - :paramtype retention_period: int or None - :keyword tags: The tags of the configuration snapshot. - :paramtype tags: dict[str, str] or None - :return: A poller for create configuration snapshot operation. Call `result()` on this object to wait for the - operation to complete and get the created snapshot. - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.ConfigurationSnapshot] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - snapshot = ConfigurationSnapshot( - filters=filters, composition_type=composition_type, retention_period=retention_period, tags=tags - ) - return cast( - LROPoller[ConfigurationSnapshot], - self._impl.begin_create_snapshot( - name=name, entity=snapshot._to_generated(), cls=ConfigurationSnapshot._from_deserialized, **kwargs - ), - ) - - @distributed_trace - def archive_snapshot( - self, - name: str, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSnapshot: - """Archive a configuration setting snapshot. It will update the status of a snapshot from "ready" to "archived". - The retention period will start to count, the snapshot will expire when the entire retention period elapses. - - :param name: The name of the configuration setting snapshot to archive. - :type name: str - :keyword match_condition: The match condition to use upon the etag. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. - :paramtype etag: str or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = self._impl._update_snapshot( - name=name, - entity=SnapshotUpdateParameters(status=SnapshotStatus.ARCHIVED), - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace - def recover_snapshot( - self, - name: str, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSnapshot: - """Recover a configuration setting snapshot. It will update the status of a snapshot from "archived" to "ready". - - :param name: The name of the configuration setting snapshot to recover. - :type name: str - :keyword match_condition: The match condition to use upon the etag. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. - :paramtype etag: str or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = self._impl._update_snapshot( - name=name, - entity=SnapshotUpdateParameters(status=SnapshotStatus.READY), - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace - def get_snapshot( - self, name: str, *, fields: Optional[List[Union[str, SnapshotFields]]] = None, **kwargs: Any - ) -> ConfigurationSnapshot: - """Get a configuration setting snapshot. - - :param name: The name of the configuration setting snapshot to retrieve. - :type name: str - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.SnapshotFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.SnapshotFields] or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = self._impl.get_snapshot(name=name, select=fields, **kwargs) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace - def list_snapshots( - self, - *, - name: Optional[str] = None, - fields: Optional[List[Union[str, SnapshotFields]]] = None, - status: Optional[List[Union[str, SnapshotStatus]]] = None, - **kwargs: Any, - ) -> ItemPaged[ConfigurationSnapshot]: - """List the configuration setting snapshots stored in the configuration service, optionally filtered by - snapshot name, snapshot status and fields to present in return. - - :keyword name: Filter results based on snapshot name. - :paramtype name: str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.SnapshotFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.SnapshotFields] or None - :keyword status: Filter results based on snapshot keys. Available status see - :class:`~azure.appconfiguration.SnapshotStatus`. - :paramtype status: list[str] or list[~azure.appconfiguration.SnapshotStatus] or None - :return: An iterator of :class:`~azure.appconfiguration.ConfigurationSnapshot` - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSnapshot] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - return self._impl.get_snapshots( # type: ignore[return-value] - name=name, - select=fields, - status=status, - cls=lambda objs: [ConfigurationSnapshot._from_generated(x) for x in objs], - **kwargs, - ) - - def update_sync_token(self, token: str) -> None: - """Add a sync token to the internal list of tokens. - - :param str token: The sync token to be added to the internal list of tokens - """ - if not self._sync_token_policy: - raise AttributeError( - "Client has no sync token policy, possibly because it was not provided during instantiation." - ) - self._sync_token_policy.add_token(token) - - def close(self) -> None: - """Close all connections made by the client""" - self._impl._client.close() - - def __enter__(self) -> "AzureAppConfigurationClient": - self._impl.__enter__() - return self - - def __exit__(self, *args: Any) -> None: - self._impl.__exit__(*args) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_error.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_error.py deleted file mode 100644 index da2c96acf2c0..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_error.py +++ /dev/null @@ -1,14 +0,0 @@ -# ------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# ------------------------------------------------------------------------- -from azure.core.exceptions import HttpResponseError - - -class ResourceReadOnlyError(HttpResponseError): - """An error response with status code 409 - - The key is read-only. - - To allow modification unlock it first.""" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py deleted file mode 100644 index c96c85f66420..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_requests.py +++ /dev/null @@ -1,79 +0,0 @@ -# ------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# ------------------------------------------------------------------------- - -import hashlib -import base64 -import hmac -from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.policies import HTTPPolicy -from ._utils import get_current_utc_time - - -class AppConfigRequestsCredentialsPolicy(HTTPPolicy): - """Implementation of request-oauthlib except and retry logic.""" - - def __init__(self, credential: AzureKeyCredential, endpoint: str, id_credential: str): - super(AppConfigRequestsCredentialsPolicy, self).__init__() - self._credential = credential - self._host = str(endpoint[8:]) - self._id_credential = id_credential - - def _signed_request(self, request): - verb = request.http_request.method.upper() - - # Get the path and query from url, which looks like https://host/path/query - query_url = str(request.http_request.url[len(self._host) + 8 :]) - # Need URL() to get a correct encoded key value, from "%2A" to "*", when transport is in type AioHttpTransport. - # There's a similar scenario in azure-storage-blob, the check logic is from there. - try: - from yarl import URL - from azure.core.pipeline.transport import ( # pylint:disable=non-abstract-transport-import,no-name-in-module - AioHttpTransport, - ) - - if ( - isinstance(request.context.transport, AioHttpTransport) - or isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport) - or isinstance( - getattr(getattr(request.context.transport, "_transport", None), "_transport", None), - AioHttpTransport, - ) - ): - query_url = str(URL(query_url)) - except (ImportError, TypeError): - pass - signed_headers = "x-ms-date;host;x-ms-content-sha256" - - utc_now = get_current_utc_time() - if request.http_request.body is None: - request.http_request.body = "" - content_digest = hashlib.sha256((request.http_request.body.encode("utf-8"))).digest() - content_hash = base64.b64encode(content_digest).decode("utf-8") - - string_to_sign = verb + "\n" + query_url + "\n" + utc_now + ";" + self._host + ";" + content_hash - - decoded_secret = base64.b64decode(self._credential.key) - digest = hmac.new(decoded_secret, string_to_sign.encode("utf-8"), hashlib.sha256).digest() - signature = base64.b64encode(digest).decode("utf-8") - - signature_header = { - "x-ms-date": utc_now, - "x-ms-content-sha256": content_hash, - "Authorization": "HMAC-SHA256 Credential=" - + self._id_credential - + "&SignedHeaders=" - + signed_headers - + "&Signature=" - + signature, - } - - request.http_request.headers.update(signature_header) - - return request - - def send(self, request): - self._signed_request(request) - return self.next.send(request) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_client.py similarity index 93% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_client.py index e1bab02c1961..c083fcc37ef7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_client.py @@ -16,20 +16,20 @@ from azure.core.rest import HttpRequest, HttpResponse from ._configuration import AzureAppConfigurationClientConfiguration -from ._operations import AzureAppConfigurationClientOperationsMixin -from ._serialization import Deserializer, Serializer +from ._operations._operations import _AzureAppConfigurationClientOperationsMixin +from ._utils.serialization import Deserializer, Serializer 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". @@ -42,6 +42,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/_configuration.py similarity index 96% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_configuration.py index 559ee3e9dcbe..993b84af5459 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_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,8 +25,8 @@ 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". diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py deleted file mode 100644 index ddbe3f930fc3..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py +++ /dev/null @@ -1,32 +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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import AzureAppConfigurationClient # type: ignore -from .._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureAppConfigurationClient", -] -__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/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py deleted file mode 100644 index e88a8132fef7..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_patch.py +++ /dev/null @@ -1,192 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - - -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -import urllib.parse -from typing import Any, Iterable, List, Optional, Union, MutableMapping, Type -from azure.core import MatchConditions -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - ResourceModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from ._operations import ( - AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, - ClsType, - build_azure_app_configuration_get_key_values_request, -) -from .. import models as _models -from .._model_base import _deserialize - - -class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): - @distributed_trace - def get_key_values_in_one_page( - self, - *, - key: Optional[str] = None, - label: Optional[str] = None, - sync_token: Optional[str] = None, - after: Optional[str] = None, - accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, - etag: Optional[str] = None, - match_condition: Optional[MatchConditions] = None, - continuation_token: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.KeyValue"]: - """Gets a list of key-values in one page. - - Gets a list of key-values in one page. - - :keyword key: A filter used to match keys. Syntax reference: - 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. - :paramtype label: 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 accept_datetime: Requests the server to respond with the state of the resource at the - specified - time. Default value is None. - :paramtype accept_datetime: str - :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. 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. - :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 - :param str continuation_token: An opaque continuation token. - :return: An iterator like instance of KeyValue - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.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) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - if match_condition == MatchConditions.IfNotModified: - error_map[412] = ResourceModifiedError - elif match_condition == MatchConditions.IfPresent: - error_map[412] = ResourceNotFoundError - elif match_condition == MatchConditions.IfMissing: - error_map[412] = ResourceExistsError - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_azure_app_configuration_get_key_values_request( - key=key, - label=label, - sync_token=sync_token, - after=after, - accept_datetime=accept_datetime, - select=select, - snapshot=snapshot, - tags=tags, - etag=etag, - match_condition=match_condition, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - _request = prepare_request(continuation_token) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = response.headers - deserialized = pipeline_response.http_response.json() - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - -__all__: List[str] = [ - "AzureAppConfigurationClientOperationsMixin" -] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py deleted file mode 100644 index f63ec1343e47..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/__init__.py +++ /dev/null @@ -1,29 +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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import AzureAppConfigurationClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureAppConfigurationClient", -] -__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/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py deleted file mode 100644 index fd79a4eb3b4c..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_patch.py +++ /dev/null @@ -1,189 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -import urllib.parse -from typing import Any, AsyncIterable, List, Optional, Union, MutableMapping, Type -from azure.core import MatchConditions -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - ResourceModifiedError, - map_error, -) -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from ._operations import ( - AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated, - ClsType, - build_azure_app_configuration_get_key_values_request, -) -from ... import models as _models -from ..._model_base import _deserialize - - -class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated): - @distributed_trace_async - async def get_key_values_in_one_page( - self, - *, - key: Optional[str] = None, - label: Optional[str] = None, - sync_token: Optional[str] = None, - after: Optional[str] = None, - accept_datetime: Optional[str] = None, - select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None, - snapshot: Optional[str] = None, - tags: Optional[List[str]] = None, - etag: Optional[str] = None, - match_condition: Optional[MatchConditions] = None, - continuation_token: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.KeyValue"]: - """Gets a list of key-values in one page. - - Gets a list of key-values in one page. - - :keyword key: A filter used to match keys. Syntax reference: - 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. - :paramtype label: 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 accept_datetime: Requests the server to respond with the state of the resource at the - specified - time. Default value is None. - :paramtype accept_datetime: str - :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.KeyValueFields] - :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. - :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 - :param str continuation_token: An opaque continuation token. - :return: An iterator like instance of KeyValue - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.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) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - if match_condition == MatchConditions.IfNotModified: - error_map[412] = ResourceModifiedError - elif match_condition == MatchConditions.IfPresent: - error_map[412] = ResourceNotFoundError - elif match_condition == MatchConditions.IfMissing: - error_map[412] = ResourceExistsError - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_azure_app_configuration_get_key_values_request( - key=key, - label=label, - sync_token=sync_token, - after=after, - accept_datetime=accept_datetime, - select=select, - snapshot=snapshot, - tags=tags, - etag=etag, - match_condition=match_condition, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - _request = prepare_request(continuation_token) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.Error, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = response.headers - deserialized = pipeline_response.http_response.json() - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - -__all__: List[str] = [ - "AzureAppConfigurationClientOperationsMixin" -] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/appconfiguration/azure-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/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py deleted file mode 100644 index 4c3ef970b6f9..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_patch.py +++ /dev/null @@ -1,91 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -import datetime -from typing import Any, Dict, List, Mapping, Optional, overload - -from .. import _model_base -from .._model_base import rest_field - - -class KeyValue(_model_base.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. - :vartype key: str - :ivar label: The label the key-value belongs to. - :vartype label: str - :ivar content_type: The content type of the value stored within the key-value. - :vartype content_type: str - :ivar value: The value of the key-value. - :vartype value: str - :ivar last_modified: A date representing the last time the key-value was modified. - :vartype last_modified: ~datetime.datetime - :ivar tags: The tags of the key-value. - :vartype tags: dict[str, str] - :ivar locked: Indicates whether the key-value is locked. - :vartype locked: bool - :ivar etag: A value representing the current state of the resource. - :vartype etag: str - """ - - key: str = rest_field() - """The key of the key-value.""" - label: Optional[str] = rest_field() - """The label the key-value belongs to.""" - content_type: Optional[str] = rest_field() - """The content type of the value stored within the key-value.""" - value: Optional[str] = rest_field() - """The value of the key-value.""" - last_modified: Optional[datetime.datetime] = rest_field(format="rfc3339") - """A date representing the last time the key-value was modified.""" - tags: Optional[Dict[str, str]] = rest_field() - """The tags of the key-value.""" - locked: Optional[bool] = rest_field() - """Indicates whether the key-value is locked.""" - etag: Optional[str] = rest_field() - """A value representing the current state of the resource.""" - - @overload - def __init__( - self, - *, - key: Optional[str] = None, - label: Optional[str] = None, - content_type: Optional[str] = None, - value: Optional[str] = None, - last_modified: Optional[datetime.datetime] = None, - tags: Optional[Dict[str, str]] = None, - locked: Optional[bool] = None, - etag: Optional[str] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -__all__: List[str] = ["KeyValue"] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/appconfiguration/azure-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/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py deleted file mode 100644 index 6bf229d3530e..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ /dev/null @@ -1,655 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -import json -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, cast, Callable - -from azure.core.rest import HttpResponse -from azure.core.paging import PageIterator -from azure.core.async_paging import AsyncPageIterator -from ._generated._serialization import Model -from ._generated.models import ( - KeyValue, - KeyValueFilter, - Snapshot as GeneratedConfigurationSnapshot, - SnapshotStatus, - SnapshotComposition, -) -from ._generated._model_base import _deserialize - - -class ConfigurationSetting(Model): - """A setting, defined by a unique combination of a key and label.""" - - value: str - """The value of the configuration setting.""" - etag: str - """A value representing the current state of the resource.""" - key: str - """The key of the configuration setting.""" - label: str - """The label of the configuration setting.""" - content_type: Optional[str] - """The content_type of the configuration setting.""" - last_modified: datetime - """A date representing the last time the key-value was modified.""" - read_only: bool - """Indicates whether the key-value is locked.""" - tags: Dict[str, str] - """The tags assigned to the configuration setting.""" - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - "key": {"key": "key", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "content_type": {"key": "content_type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "last_modified": {"key": "last_modified", "type": "iso-8601"}, - "read_only": {"key": "read_only", "type": "bool"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - kind = "Generic" - content_type = None - - def __init__(self, **kwargs: Any) -> None: - super(ConfigurationSetting, self).__init__(**kwargs) - self.key = kwargs.get("key", None) - self.label = kwargs.get("label", None) - self.value = kwargs.get("value", None) - self.etag = kwargs.get("etag", None) - self.content_type = kwargs.get("content_type", None) - self.last_modified = kwargs.get("last_modified", None) - self.read_only = kwargs.get("read_only", None) - self.tags = kwargs.get("tags", {}) - - @classmethod - def _from_generated(cls, key_value: KeyValue) -> "ConfigurationSetting": - # pylint:disable=protected-access - if key_value.content_type is not None: - try: - if key_value.content_type.startswith( - FeatureFlagConfigurationSetting._feature_flag_content_type - ) and key_value.key.startswith( # type: ignore - FeatureFlagConfigurationSetting._key_prefix - ): - config_setting = FeatureFlagConfigurationSetting._from_generated(key_value) - if key_value.value: - config_setting.value = key_value.value - return config_setting - if key_value.content_type.startswith( - SecretReferenceConfigurationSetting._secret_reference_content_type - ): - return SecretReferenceConfigurationSetting._from_generated(key_value) - except (KeyError, AttributeError): - pass - - return cls( - key=key_value.key, - label=key_value.label, - value=key_value.value, - content_type=key_value.content_type, - last_modified=key_value.last_modified, - tags=key_value.tags, - read_only=key_value.locked, - etag=key_value.etag, - ) - - def _to_generated(self) -> KeyValue: - return KeyValue( - key=self.key, - label=self.label, - value=self.value, - content_type=self.content_type, - last_modified=self.last_modified, - tags=self.tags, - locked=self.read_only, - etag=self.etag, - ) - - -class FeatureFlagConfigurationSetting(ConfigurationSetting): # pylint: disable=too-many-instance-attributes - """A configuration setting that stores a feature flag value.""" - - etag: str - """A value representing the current state of the resource.""" - feature_id: str - """The identity of the configuration setting.""" - key: str - """The key of the configuration setting.""" - enabled: bool - """The value indicating whether the feature flag is enabled. A feature is OFF if enabled is false. - If enabled is true, then the feature is ON if there are no conditions or if all conditions are satisfied.""" - filters: Optional[List[Dict[str, Any]]] - """Filters that must run on the client and be evaluated as true for the feature - to be considered enabled.""" - label: str - """The label used to group this configuration setting with others.""" - display_name: str - """The name for the feature to use for display rather than the ID.""" - description: str - """The description of the feature.""" - content_type: str - """The content_type of the configuration setting.""" - last_modified: datetime - """A date representing the last time the key-value was modified.""" - read_only: bool - """Indicates whether the key-value is locked.""" - tags: Dict[str, str] - """The tags assigned to the configuration setting.""" - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - "feature_id": {"key": "feature_id", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "content_type": {"key": "_feature_flag_content_type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "last_modified": {"key": "last_modified", "type": "iso-8601"}, - "read_only": {"key": "read_only", "type": "bool"}, - "tags": {"key": "tags", "type": "{str}"}, - } - _key_prefix = ".appconfig.featureflag/" - _feature_flag_content_type = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8" - kind = "FeatureFlag" - - def __init__( # pylint: disable=super-init-not-called - self, - feature_id: str, - *, - enabled: bool = False, - filters: Optional[List[Dict[str, Any]]] = None, - **kwargs: Any, - ) -> None: - """ - :param feature_id: The identity of the configuration setting. - :type feature_id: str - :keyword enabled: The value indicating whether the feature flag is enabled. - A feature is OFF if enabled is false. If enabled is true, then the feature is ON - if there are no conditions or if all conditions are satisfied. Default value of this property is False. - :paramtype enabled: bool - :keyword filters: Filters that must run on the client and be evaluated as true for the feature - to be considered enabled. - :paramtype filters: list[dict[str, Any]] or None - """ - if "value" in kwargs: - raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") - self.feature_id = feature_id - self.key = kwargs.get("key", None) or (self._key_prefix + self.feature_id) - self.label = kwargs.get("label", None) - self.content_type = kwargs.get("content_type", self._feature_flag_content_type) - self.last_modified = kwargs.get("last_modified", None) - self.tags = kwargs.get("tags", {}) - self.read_only = kwargs.get("read_only", None) - self.etag = kwargs.get("etag", None) - self.description = kwargs.get("description", None) - self.display_name = kwargs.get("display_name", None) - self.filters = [] if filters is None else filters - self.enabled = enabled - self._value = json.dumps( - {"id": self.feature_id, "enabled": self.enabled, "conditions": {"client_filters": self.filters}} - ) - - @property - def value(self) -> str: - """The value of the configuration setting. - - :rtype: str - """ - try: - temp = json.loads(self._value) - temp["id"] = self.feature_id - temp["enabled"] = self.enabled - temp["display_name"] = self.display_name - temp["description"] = self.description - if "conditions" not in temp.keys(): - temp["conditions"] = {} - temp["conditions"]["client_filters"] = self.filters - self._value = json.dumps(temp) - return self._value - except (json.JSONDecodeError, ValueError): - return self._value - - @value.setter - def value(self, new_value: str) -> None: - try: - temp = json.loads(new_value) - temp["id"] = self.feature_id - self._value = json.dumps(temp) - self.enabled = temp.get("enabled", False) - self.display_name = temp.get("display_name", None) - self.description = temp.get("description", None) - self.filters = None - conditions = temp.get("conditions", None) - if conditions: - self.filters = conditions.get("client_filters", None) - except (json.JSONDecodeError, ValueError): - self._value = new_value - self.enabled = False - self.filters = None - - @classmethod - def _from_generated(cls, key_value: KeyValue) -> "FeatureFlagConfigurationSetting": - enabled = False - filters = None - display_name = None - description = None - feature_id = None - try: - temp = json.loads(key_value.value) # type: ignore - if isinstance(temp, dict): - enabled = temp.get("enabled", False) - display_name = temp.get("display_name") - description = temp.get("description") - feature_id = temp.get("id") - - if "conditions" in temp.keys(): - filters = temp["conditions"].get("client_filters") - except (ValueError, json.JSONDecodeError): - pass - - return cls( - feature_id=feature_id, # type: ignore - key=key_value.key, - label=key_value.label, - content_type=key_value.content_type, - last_modified=key_value.last_modified, - tags=key_value.tags, - read_only=key_value.locked, - etag=key_value.etag, - enabled=enabled, - filters=filters, - display_name=display_name, - description=description, - ) - - def _to_generated(self) -> KeyValue: - return KeyValue( - key=self.key, - label=self.label, - value=self.value, - content_type=self.content_type, - last_modified=self.last_modified, - tags=self.tags, - locked=self.read_only, - etag=self.etag, - ) - - -class SecretReferenceConfigurationSetting(ConfigurationSetting): - """A configuration value that references a configuration setting secret.""" - - etag: str - """A value representing the current state of the resource.""" - key: str - """The key of the configuration setting.""" - secret_id: Optional[str] - """The identity of the configuration setting.""" - label: str - """The label used to group this configuration setting with others.""" - content_type: str - """The content_type of the configuration setting.""" - last_modified: datetime - """A date representing the last time the key-value was modified.""" - read_only: bool - """Indicates whether the key-value is locked.""" - tags: Dict[str, str] - """The tags assigned to the configuration setting.""" - - _attribute_map = { - "etag": {"key": "etag", "type": "str"}, - "key": {"key": "key", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "content_type": {"key": "content_type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "last_modified": {"key": "last_modified", "type": "iso-8601"}, - "read_only": {"key": "read_only", "type": "bool"}, - "tags": {"key": "tags", "type": "{str}"}, - } - _secret_reference_content_type = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" - kind = "SecretReference" - - def __init__(self, key: str, secret_id: str, **kwargs: Any) -> None: # pylint: disable=super-init-not-called - """ - :param key: The key of the configuration setting. - :type key: str - :param secret_id: The identity of the configuration setting. - :type secret_id: str - """ - if "value" in kwargs: - raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") - self.key = key - self.label = kwargs.pop("label", None) - self.content_type = kwargs.get("content_type", self._secret_reference_content_type) - self.etag = kwargs.get("etag", None) - self.last_modified = kwargs.get("last_modified", None) - self.read_only = kwargs.get("read_only", None) - self.tags = kwargs.get("tags", {}) - self.secret_id = secret_id - self._value = json.dumps({"uri": secret_id}) - - @property - def value(self) -> str: - """The value of the configuration setting. - - :rtype: str - """ - try: - temp = json.loads(self._value) - temp["uri"] = self.secret_id - self._value = json.dumps(temp) - return self._value - except (json.JSONDecodeError, ValueError): - return self._value - - @value.setter - def value(self, new_value: str) -> None: - try: - temp = json.loads(new_value) - self._value = new_value - self.secret_id = temp.get("uri") - except (json.JSONDecodeError, ValueError): - self._value = new_value - self.secret_id = None - - @classmethod - def _from_generated(cls, key_value: KeyValue) -> "SecretReferenceConfigurationSetting": - secret_uri = None - try: - temp = json.loads(key_value.value) # type: ignore - secret_uri = temp.get("uri") - if not secret_uri: - secret_uri = temp.get("secret_uri") - except (ValueError, json.JSONDecodeError): - pass - - return cls( - key=key_value.key, # type: ignore - label=key_value.label, - secret_id=secret_uri, # type: ignore - last_modified=key_value.last_modified, - tags=key_value.tags, - read_only=key_value.locked, - etag=key_value.etag, - ) - - def _to_generated(self) -> KeyValue: - return KeyValue( - key=self.key, - label=self.label, - value=self.value, - content_type=self.content_type, - last_modified=self.last_modified, - tags=self.tags, - locked=self.read_only, - etag=self.etag, - ) - - -class ConfigurationSettingsFilter: - """Enables filtering of configuration settings.""" - - key: str - """Filters configuration settings by their key field. Required.""" - label: Optional[str] - """Filters configuration settings by their label field.""" - tags: Optional[List[str]] - """Filters key-values by their tags field.""" - - def __init__(self, *, key: str, label: Optional[str] = None, tags: Optional[List[str]] = None) -> None: - """ - :keyword key: Filters configuration settings by their key field. Required. - :paramtype key: str - :keyword label: Filters configuration settings by their label field. - :paramtype label: str or None - :keyword tags: Filters key-values by their tags field. - :paramtype tags: list[str] or None - """ - self.key = key - self.label = label - self.tags = tags - - -class ConfigurationSnapshot: # pylint: disable=too-many-instance-attributes - """A point-in-time snapshot of configuration settings.""" - - name: Optional[str] - """The name of the configuration snapshot.""" - status: Optional[Union[str, SnapshotStatus]] - """The current status of the snapshot. Known values are: "provisioning", "ready", - "archived", and "failed".""" - filters: List[ConfigurationSettingsFilter] - """A list of filters used to filter the key-values included in the configuration snapshot. Required.""" - composition_type: Optional[Union[str, SnapshotComposition]] - """The composition type describes how the key-values within the configuration 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] - """The time that the configuration snapshot was created.""" - expires: Optional[datetime] - """The time that the configuration snapshot will expire.""" - retention_period: Optional[int] - """The amount of time, in seconds, that a configuration snapshot will remain in the - archived state before expiring. This property is only writable during the creation of a configuration - snapshot. If not specified, the default lifetime of key-value revisions will be used.""" - size: Optional[int] - """The size in bytes of the configuration snapshot.""" - items_count: Optional[int] - """The amount of key-values in the configuration snapshot.""" - tags: Optional[Dict[str, str]] - """The tags of the configuration snapshot.""" - etag: Optional[str] - """A value representing the current state of the configuration snapshot.""" - - def __init__( - self, - filters: List[ConfigurationSettingsFilter], - *, - composition_type: Optional[Union[str, SnapshotComposition]] = None, - retention_period: Optional[int] = None, - tags: Optional[Dict[str, str]] = None, - ) -> None: - """ - :param filters: A list of filters used to filter the key-values included in the configuration snapshot. - Required. - :type filters: list[~azure.appconfiguration.ConfigurationSettingsFilter] - :keyword composition_type: The composition type describes how the key-values within the configuration - snapshot are composed. The 'key' composition type ensures there are no two key-values - containing the same key. The 'key_label' composition type ensures there are no two key-values - containing the same key and label. Known values are: "key" and "key_label". - :paramtype composition_type: str or None - :keyword retention_period: The amount of time, in seconds, that a configuration snapshot will remain in the - archived state before expiring. This property is only writable during the creation of a configuration - snapshot. If not specified, the default lifetime of key-value revisions will be used. - :paramtype retention_period: int or None - :keyword tags: The tags of the configuration snapshot. - :paramtype tags: dict[str, str] or None - """ - self.name = None - self.status = None - self.filters = filters - self.composition_type = composition_type - self.created = None - self.expires = None - self.retention_period = retention_period - self.size = None - self.items_count = None - self.tags = tags - self.etag = None - - @classmethod - def _from_generated(cls, generated: GeneratedConfigurationSnapshot) -> "ConfigurationSnapshot": - if generated is None: - return generated - - filters = [] - if generated.filters: - for config_setting_filter in generated.filters: - filters.append( - ConfigurationSettingsFilter( - key=config_setting_filter.key, - label=config_setting_filter.label, - tags=config_setting_filter.tags, - ) - ) - snapshot = cls( - filters=filters, - composition_type=cast(SnapshotComposition, generated.composition_type), - retention_period=generated.retention_period, - tags=generated.tags, - ) - snapshot.name = generated.name - snapshot.status = generated.status - snapshot.created = generated.created - snapshot.expires = generated.expires - snapshot.size = generated.size - snapshot.items_count = generated.items_count - snapshot.etag = generated.etag - - return snapshot - - @classmethod - def _from_deserialized( - cls, - response: HttpResponse, # pylint:disable=unused-argument - deserialized: GeneratedConfigurationSnapshot, - response_headers: Dict, # pylint:disable=unused-argument - ) -> "ConfigurationSnapshot": - if deserialized is None: - return deserialized - filters = [] - if deserialized.filters: - for config_setting_filter in deserialized.filters: - filters.append( - ConfigurationSettingsFilter( - key=config_setting_filter.key, - label=config_setting_filter.label, - tags=config_setting_filter.tags, - ) - ) - snapshot = cls( - filters=filters, - composition_type=cast(SnapshotComposition, deserialized.composition_type), - retention_period=deserialized.retention_period, - tags=deserialized.tags, - ) - snapshot.name = deserialized.name - snapshot.status = deserialized.status - snapshot.created = deserialized.created - snapshot.expires = deserialized.expires - snapshot.size = deserialized.size - snapshot.items_count = deserialized.items_count - snapshot.etag = deserialized.etag - - return snapshot - - def _to_generated(self) -> GeneratedConfigurationSnapshot: - config_setting_filters = [] - for kv_filter in self.filters: - config_setting_filters.append(KeyValueFilter(key=kv_filter.key, label=kv_filter.label, tags=kv_filter.tags)) - return GeneratedConfigurationSnapshot( - filters=config_setting_filters, - composition_type=self.composition_type, - retention_period=self.retention_period, - tags=self.tags, - ) - - -class ConfigurationSettingLabel: - """The label info of a configuration setting.""" - - name: Optional[str] - """The name of the ConfigurationSetting label.""" - - def __init__(self, *, name: Optional[str] = None) -> None: - """ - :keyword name: The configuration setting label name. - :paramtype composition_type: str or None - """ - self.name = name - - -def _return_deserialized_and_headers(_, deserialized, response_headers): - return deserialized, response_headers - - -class ConfigurationSettingPropertiesPaged(PageIterator): - """An iterable of ConfigurationSetting properties.""" - - etag: str - """The etag of current page.""" - - def __init__(self, command: Callable, **kwargs: Any): - super(ConfigurationSettingPropertiesPaged, self).__init__( - self._get_next_cb, - self._extract_data_cb, - continuation_token=kwargs.get("continuation_token"), - ) - self._command = command - self._key = kwargs.get("key") - self._label = kwargs.get("label") - self._accept_datetime = kwargs.get("accept_datetime") - self._select = kwargs.get("select") - self._tags = kwargs.get("tags") - self._deserializer = lambda objs: [ - ConfigurationSetting._from_generated(x) for x in objs # pylint:disable=protected-access - ] - - def _get_next_cb(self, continuation_token, **kwargs): - return self._command( - key=self._key, - label=self._label, - accept_datetime=self._accept_datetime, - select=self._select, - tags=self._tags, - continuation_token=continuation_token, - cls=kwargs.pop("cls", None) or _return_deserialized_and_headers, - ) - - def _extract_data_cb(self, get_next_return): - deserialized, response_headers = get_next_return - list_of_elem = _deserialize(List[KeyValue], deserialized["items"]) - self.etag = response_headers.pop("ETag") - return deserialized.get("@nextLink") or None, iter(self._deserializer(list_of_elem)) - - -class ConfigurationSettingPropertiesPagedAsync(AsyncPageIterator): - """An iterable of ConfigurationSetting properties.""" - - etag: str - """The etag of current page.""" - - def __init__(self, command: Callable, **kwargs: Any): - super(ConfigurationSettingPropertiesPagedAsync, self).__init__( - self._get_next_cb, - self._extract_data_cb, - continuation_token=kwargs.get("continuation_token"), - ) - self._command = command - self._key = kwargs.get("key") - self._label = kwargs.get("label") - self._accept_datetime = kwargs.get("accept_datetime") - self._select = kwargs.get("select") - self._tags = kwargs.get("tags") - self._deserializer = lambda objs: [ - ConfigurationSetting._from_generated(x) for x in objs # pylint:disable=protected-access - ] - - async def _get_next_cb(self, continuation_token, **kwargs): - return await self._command( - key=self._key, - label=self._label, - accept_datetime=self._accept_datetime, - select=self._select, - tags=self._tags, - continuation_token=continuation_token, - cls=kwargs.pop("cls", None) or _return_deserialized_and_headers, - ) - - async def _extract_data_cb(self, get_next_return): - deserialized, response_headers = get_next_return - list_of_elem = _deserialize(List[KeyValue], deserialized["items"]) - self.etag = response_headers.pop("ETag") - return deserialized.get("@nextLink") or None, iter(self._deserializer(list_of_elem)) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/__init__.py similarity index 84% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/__init__.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/__init__.py index a90b04c612d7..933fcd7d1b55 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/__init__.py @@ -12,14 +12,11 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import AzureAppConfigurationClientOperationsMixin # type: ignore 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/_operations/_operations.py similarity index 96% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/_operations.py index 919a641512d1..2973835cbbb7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_operations/_operations.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_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, Dict, IO, Iterator, List, 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,15 +33,12 @@ 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 + +JSON = MutableMapping[str, Any] T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -87,8 +84,8 @@ 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: @@ -903,8 +900,8 @@ def build_azure_app_configuration_check_revisions_request( # pylint: disable=na 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 +913,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. @@ -993,7 +990,7 @@ 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 +1006,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1021,8 +1018,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 +1029,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 +1058,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 +1079,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1107,16 +1104,18 @@ def get_key_values( 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 +1134,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. @@ -1214,7 +1214,7 @@ 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 +1230,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1258,10 +1258,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 +1278,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 +1342,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1440,13 +1443,11 @@ 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.json()) 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")) @@ -1597,7 +1598,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1694,7 +1695,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) deserialized = None @@ -1802,7 +1803,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1823,7 +1824,7 @@ def get_snapshots( 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. @@ -1903,7 +1904,7 @@ 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 +1920,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1976,7 +1977,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2066,16 +2067,14 @@ 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.json()) 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: @@ -2138,7 +2137,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) if _stream: @@ -2207,7 +2206,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2510,7 +2509,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2599,7 +2598,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2621,7 +2620,7 @@ def get_labels( accept_datetime: Optional[str] = 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. @@ -2702,7 +2701,7 @@ 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 +2717,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2796,7 +2795,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2885,7 +2884,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2982,7 +2981,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -3012,16 +3011,18 @@ def get_revisions( 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,7 +3038,8 @@ 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] @@ -3102,7 +3104,7 @@ 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 +3120,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -3143,10 +3145,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 +3166,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 +3212,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/_patch.py similarity index 61% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_patch.py similarity index 61% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_patch.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_sync_token.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_sync_token.py deleted file mode 100644 index c1ab0d8e8541..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_sync_token.py +++ /dev/null @@ -1,116 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- -from typing import Any, Dict, Optional -from threading import Lock -from azure.core.pipeline import PipelineRequest, PipelineResponse -from azure.core.pipeline.policies import SansIOHTTPPolicy - - -class SyncToken: - """The sync token structure - - :param str token_id: The id of sync token. - :param str value: The value of sync token. - :param int sequence_number: The sequence number of sync token. - """ - - def __init__(self, token_id, value, sequence_number): - self.token_id = token_id - self.value = value - self.sequence_number = sequence_number - - def __str__(self): - return f"{self.token_id}={self.value}" - - @classmethod - def from_sync_token_string(cls, sync_token): - try: - position = sync_token.index(";sn=") - sequence_number = int(sync_token[position + 4 :]) - id_value = sync_token[:position] - position = id_value.index("=") - token_id = id_value[:position] - value = id_value[position + 1 :] - return SyncToken(token_id, value, sequence_number) - except ValueError: - return None - - -class SyncTokenPolicy(SansIOHTTPPolicy): - """A simple policy that enable the given callback with the response. - - :keyword callback raw_response_hook: Callback function. Will be invoked on response. - """ - - def __init__(self, **kwargs: Any) -> None: # pylint: disable=unused-argument - self._sync_token_header = "Sync-Token" - self._sync_tokens: Dict[str, Any] = {} - self._lock = Lock() - - def on_request(self, request: PipelineRequest) -> None: - """This is executed before sending the request to the next policy. - :param request: The PipelineRequest object. - :type request: ~azure.core.pipeline.PipelineRequest - """ - with self._lock: - sync_token_header = ",".join(str(x) for x in self._sync_tokens.values()) - if sync_token_header: - request.http_request.headers.update({self._sync_token_header: sync_token_header}) - - def on_response(self, request: PipelineRequest, response: PipelineResponse) -> None: - """This is executed after the request comes back from the policy. - - :param request: The PipelineRequest object. - :type request: ~azure.core.pipeline.PipelineRequest - :param response: The PipelineResponse object. - :type response: ~azure.core.pipeline.PipelineResponse - """ - sync_token_header = response.http_response.headers.get(self._sync_token_header) - if not sync_token_header: - return - sync_token_strings = sync_token_header.split(",") - if not sync_token_strings: - return - for sync_token_string in sync_token_strings: - sync_token = SyncToken.from_sync_token_string(sync_token_string) - self._update_sync_token(sync_token) - - def add_token(self, full_raw_tokens: str) -> None: - raw_tokens = full_raw_tokens.split(",") - for raw_token in raw_tokens: - sync_token = SyncToken.from_sync_token_string(raw_token) - self._update_sync_token(sync_token) - - def _update_sync_token(self, sync_token: Optional[SyncToken]) -> None: - if not sync_token: - return - with self._lock: - existing_token = self._sync_tokens.get(sync_token.token_id, None) - if not existing_token: - self._sync_tokens[sync_token.token_id] = sync_token - return - if existing_token.sequence_number < sync_token.sequence_number: - self._sync_tokens[sync_token.token_id] = sync_token diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py deleted file mode 100644 index 9b058b0049fb..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py +++ /dev/null @@ -1,62 +0,0 @@ -# ------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# ------------------------------------------------------------------------- - -from datetime import datetime -from typing import Optional, Tuple, Dict, Any - - -def parse_connection_string(connection_string: str) -> Tuple[str, str, str]: - # connection_string looks like Endpoint=https://xxxxx;Id=xxxxx;Secret=xxxx - segments = connection_string.split(";") - if len(segments) != 3: - raise ValueError("Invalid connection string.") - - endpoint = "" - id_ = "" - secret = "" - for segment in segments: - segment = segment.strip() - if segment.startswith("Endpoint"): - endpoint = str(segment[17:]) - elif segment.startswith("Id"): - id_ = str(segment[3:]) - elif segment.startswith("Secret"): - secret = str(segment[7:]) - else: - raise ValueError("Invalid connection string.") - - if not endpoint or not id_ or not secret: - raise ValueError("Invalid connection string.") - - return endpoint, id_, secret - - -def get_current_utc_time() -> str: - return str(datetime.utcnow().strftime("%b, %d %Y %H:%M:%S.%f ")) + "GMT" - - -def get_key_filter(*args: Optional[str], **kwargs: Any) -> Tuple[Optional[str], Dict[str, Any]]: - key_filter = None - if len(args) > 0: - key_filter = args[0] - if "key_filter" in kwargs: - raise TypeError( - "AzureAppConfigurationClient.list_configuration_settings() got multiple values for argument " - "'key_filter'" - ) - return key_filter or kwargs.pop("key_filter", None), kwargs - - -def get_label_filter(*args: Optional[str], **kwargs: Any) -> Tuple[Optional[str], Dict[str, Any]]: - label_filter = None - if len(args) > 1: - label_filter = args[1] - if "label_filter" in kwargs: - raise TypeError( - "AzureAppConfigurationClient.list_configuration_settings() got multiple values for argument " - "'label_filter'" - ) - return label_filter or kwargs.pop("label_filter", None), kwargs diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/__init__.py similarity index 58% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/__init__.py index 1f7f465d51d2..8026245c2abc 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/__init__.py @@ -1,11 +1,6 @@ -# ------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. # -------------------------------------------------------------------------- - -FILTER_TIME_WINDOW = "Microsoft.TimeWindow" - -FILTER_PERCENTAGE = "Microsoft.Percentage" - -FILTER_TARGETING = "Microsoft.Targeting" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/model_base.py similarity index 92% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/model_base.py index 6a6e1f38b17e..49d5c7259389 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_model_base.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/model_base.py @@ -2,8 +2,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. +# 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,6 +22,7 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET +from collections.abc import MutableMapping from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError @@ -28,11 +30,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] @@ -347,7 +344,7 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object +class _MyMutableMapping(MutableMapping[str, typing.Any]): def __init__(self, data: typing.Dict[str, typing.Any]) -> None: self._data = data @@ -373,50 +370,97 @@ 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]: + """ + 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) @@ -597,7 +641,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) 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__: @@ -633,7 +677,7 @@ 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]: @@ -894,6 +938,35 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _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, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + class _RestField: def __init__( self, diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/serialization.py similarity index 93% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils/serialization.py index e2ad51869908..eb86ea23c965 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_serialization.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_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 @@ -48,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -61,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +165,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"(? 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, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +393,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 @@ -563,7 +477,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"} @@ -626,7 +540,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) @@ -736,8 +650,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 +695,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 +719,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 +749,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 +769,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 """ @@ -1192,7 +1106,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 +1132,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 +1165,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): @@ -1429,7 +1343,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 +1355,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. @@ -1488,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :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 """ @@ -1502,7 +1416,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 +1631,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 +1713,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 +1759,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. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1936,7 +1850,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 +1863,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 +1878,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 +1896,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 +1909,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 +1927,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 +1943,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 +1958,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 +1981,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 +2019,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/_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/_utils/utils.py index cd4cb43c3298..927adb7c8ae2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_vendor.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_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/_version.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py index 9b3cbd9ff37d..be71c81bd282 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.7.2" +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/__init__.py index 243f403a5362..f63ec1343e47 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/__init__.py @@ -1,14 +1,29 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# 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=wrong-import-position -from ._azure_appconfiguration_client_async import AzureAppConfigurationClient +from typing import TYPE_CHECKING -__all__ = ["AzureAppConfigurationClient"] +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import AzureAppConfigurationClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureAppConfigurationClient", +] +__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/aio/_azure_appconfiguration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py deleted file mode 100644 index d10e46951958..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py +++ /dev/null @@ -1,782 +0,0 @@ -# ------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# ------------------------------------------------------------------------- -import functools -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, overload, cast -from azure.core import MatchConditions -from azure.core.async_paging import AsyncItemPaged -from azure.core.credentials import AzureKeyCredential -from azure.core.credentials_async import AsyncTokenCredential -from azure.core.pipeline.policies import AsyncBearerTokenCredentialPolicy -from azure.core.polling import AsyncLROPoller -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.exceptions import ResourceNotModifiedError -from azure.core.rest import AsyncHttpResponse, HttpRequest -from ._sync_token_async import AsyncSyncTokenPolicy -from .._azure_appconfiguration_error import ResourceReadOnlyError -from .._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy -from .._generated.aio import AzureAppConfigurationClient as AzureAppConfigurationClientGenerated -from .._generated.models import ( - SnapshotStatus, - SnapshotFields, - SnapshotComposition, - LabelFields, - ConfigurationSettingFields, - SnapshotUpdateParameters, -) -from .._models import ( - ConfigurationSetting, - ConfigurationSettingPropertiesPagedAsync, - ConfigurationSettingsFilter, - ConfigurationSnapshot, - ConfigurationSettingLabel, -) -from .._utils import ( - get_key_filter, - get_label_filter, - parse_connection_string, -) - - -class AzureAppConfigurationClient: - """Represents a client that calls restful API of Azure App Configuration service. - - :param str base_url: Base url of the service. - :param credential: An object which can provide secrets for the app configuration service - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default - value may result in unsupported behavior. - :paramtype api_version: str - - This is the async version of :class:`~azure.appconfiguration.AzureAppConfigurationClient` - - """ - - # pylint:disable=protected-access - def __init__(self, base_url: str, credential: AsyncTokenCredential, **kwargs: Any) -> None: - try: - if not base_url.lower().startswith("http"): - base_url = f"https://{base_url}" - except AttributeError as exc: - raise ValueError("Base URL must be a string.") from exc - - if not credential: - raise ValueError("Missing credential") - - credential_scopes = [f"{base_url.strip('/')}/.default"] - self._sync_token_policy = AsyncSyncTokenPolicy() - - if isinstance(credential, AzureKeyCredential): - id_credential = kwargs.pop("id_credential") - kwargs.update( - { - "authentication_policy": AppConfigRequestsCredentialsPolicy(credential, base_url, id_credential), - } - ) - elif hasattr(credential, "get_token"): # AsyncFakeCredential is not an instance of AsyncTokenCredential - kwargs.update( - { - "authentication_policy": AsyncBearerTokenCredentialPolicy(credential, *credential_scopes, **kwargs), - } - ) - else: - raise TypeError( - f"Unsupported credential: {type(credential)}. Use an instance of token credential from azure.identity" - ) - # mypy doesn't compare the credential type hint with the API surface in patch.py - self._impl = AzureAppConfigurationClientGenerated( - base_url, credential, per_call_policies=self._sync_token_policy, **kwargs # type: ignore[arg-type] - ) - - @classmethod - def from_connection_string(cls, connection_string: str, **kwargs: Any) -> "AzureAppConfigurationClient": - """Create AzureAppConfigurationClient from a Connection String. - This is the async version of :class:`~azure.appconfiguration.AzureAppConfigurationClient` - - :param str connection_string: Connection String - (one of the access keys of the Azure App Configuration resource) - used to access the Azure App Configuration. - :return: An AzureAppConfigurationClient authenticated with the connection string - :rtype: ~azure.appconfiguration.AzureAppConfigurationClient - - Example - - .. code-block:: python - - from azure.appconfiguration.aio import AzureAppConfigurationClient - - connection_str = "" - async_client = AzureAppConfigurationClient.from_connection_string(connection_str) - """ - endpoint, id_credential, secret = parse_connection_string(connection_string) - # AzureKeyCredential type is for internal use, it's not exposed in public API. - return cls( - credential=AzureKeyCredential(secret), # type: ignore[arg-type] - base_url=endpoint, - id_credential=id_credential, - **kwargs, - ) - - @distributed_trace_async - async def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> AsyncHttpResponse: - """Runs a network request using the client's existing pipeline. - - The request URL can be relative to the vault URL. The service API version used for the request is the same as - the client's unless otherwise specified. This method does not raise if the response is an error; to raise an - exception, call `raise_for_status()` on the returned response object. For more information about how to send - custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request. - - :param request: The network request you want to make. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - return await self._impl.send_request(request, stream=stream, **kwargs) - - @overload - def list_configuration_settings( - self, - *, - key_filter: Optional[str] = None, - label_filter: Optional[str] = None, - tags_filter: Optional[List[str]] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> AsyncItemPaged[ConfigurationSetting]: - """List the configuration settings stored in the configuration service, optionally filtered by - key, label, tags and accept_datetime. For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-key-value?pivots=v23-11#supported-filters. - - :keyword key_filter: Filter results based on their keys. '*' can be used as wildcard in the beginning or end - of the filter. - :paramtype key_filter: str or None - :keyword label_filter: Filter results based on their label. '*' can be used as wildcard in the beginning or end - of the filter. - :paramtype label_filter: str or None - :keyword tags_filter: Filter results based on their tags. - :paramtype tags_filter: list[str] or None - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An async iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError` - - Example - - .. code-block:: python - - from datetime import datetime, timedelta - - accept_datetime = datetime.utcnow() + timedelta(days=-1) - - all_listed = async_client.list_configuration_settings() - async for item in all_listed: - pass # do something - - filtered_listed = async_client.list_configuration_settings( - label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime) - ) - async for item in filtered_listed: - pass # do something - """ - - @overload - def list_configuration_settings( - self, - *, - snapshot_name: str, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> AsyncItemPaged[ConfigurationSetting]: - """List the configuration settings stored under a snapshot in the configuration service, optionally filtered by - accept_datetime and fields to present in return. - - :keyword str snapshot_name: The snapshot name. - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An async iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.paging.AsyncItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - - @distributed_trace - def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> AsyncItemPaged[ConfigurationSetting]: - accept_datetime = kwargs.pop("accept_datetime", None) - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - - select = kwargs.pop("fields", None) - if select: - select = ["locked" if x == "read_only" else x for x in select] - snapshot_name = kwargs.pop("snapshot_name", None) - - if snapshot_name is not None: - return self._impl.get_key_values( # type: ignore[return-value] - snapshot=snapshot_name, - accept_datetime=accept_datetime, - select=select, - cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs], - **kwargs, - ) - 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] - return AsyncItemPaged( - command, - key=key_filter, - label=label_filter, - accept_datetime=accept_datetime, - select=select, - tags=tags, - page_iterator_class=ConfigurationSettingPropertiesPagedAsync, - ) - - @distributed_trace_async - async def get_configuration_setting( - self, - key: str, - label: Optional[str] = None, - etag: Optional[str] = "*", - match_condition: MatchConditions = MatchConditions.Unconditionally, - *, - accept_datetime: Optional[Union[datetime, str]] = None, - **kwargs: Any, - ) -> Union[None, ConfigurationSetting]: - """Get the matched ConfigurationSetting from Azure App Configuration service - - :param key: Key of the ConfigurationSetting - :type key: str - :param label: Label used to identify the ConfigurationSetting. Default is `None`. - :type label: str or None - :param etag: Check if the ConfigurationSetting is changed. Set None to skip checking etag - :type etag: str or None - :param match_condition: The match condition to use upon the etag - :type match_condition: ~azure.core.MatchConditions - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :return: The matched ConfigurationSetting object - :rtype: ~azure.appconfiguration.ConfigurationSetting or None - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - # in async function - fetched_config_setting = await async_client.get_configuration_setting( - key="MyKey", label="MyLabel" - ) - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - try: - key_value = await self._impl.get_key_value( - key=key, - label=label, - accept_datetime=accept_datetime, - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value) - except ResourceNotModifiedError: - return None - - @distributed_trace_async - async def add_configuration_setting( - self, configuration_setting: ConfigurationSetting, **kwargs: Any - ) -> ConfigurationSetting: - """Add a ConfigurationSetting instance into the Azure App Configuration service. - - :param configuration_setting: The ConfigurationSetting object to be added - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :return: The ConfigurationSetting object returned from the App Configuration service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - # in async function - config_setting = ConfigurationSetting( - key="MyKey", - label="MyLabel", - value="my value", - content_type="my content type", - tags={"my tag": "my tag value"} - ) - added_config_setting = await async_client.add_configuration_setting(config_setting) - """ - key_value = configuration_setting._to_generated() - key_value_added = await self._impl._put_key_value( - entity=key_value, - key=key_value.key, # type: ignore - label=key_value.label, - match_condition=MatchConditions.IfMissing, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value_added) - - @distributed_trace_async - async def set_configuration_setting( - self, - configuration_setting: ConfigurationSetting, - match_condition: MatchConditions = MatchConditions.Unconditionally, - *, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSetting: - """Add or update a ConfigurationSetting. - If the configuration setting identified by key and label does not exist, this is a create. - Otherwise this is an update. - - :param configuration_setting: The ConfigurationSetting to be added (if not exists) - or updated (if exists) to the service - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :param match_condition: The match condition to use upon the etag - :type match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSetting is changed. \ - Will use the value from param configuration_setting if not set. - :paramtype etag: str or None - :return: The ConfigurationSetting returned from the service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \ - :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - # in async function - config_setting = ConfigurationSetting( - key="MyKey", - label="MyLabel", - value="my set value", - content_type="my set content type", - tags={"my set tag": "my set tag value"} - ) - returned_config_setting = await async_client.set_configuration_setting(config_setting) - """ - key_value = configuration_setting._to_generated() - error_map: Dict[int, Any] = {409: ResourceReadOnlyError} - key_value_set = await self._impl._put_key_value( - entity=key_value, - key=key_value.key, # type: ignore - label=key_value.label, - etag=etag or configuration_setting.etag, - match_condition=match_condition, - error_map=error_map, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value_set) - - @distributed_trace_async - async def delete_configuration_setting( - self, - key: str, - label: Optional[str] = None, - *, - etag: Optional[str] = None, - match_condition: MatchConditions = MatchConditions.Unconditionally, - **kwargs: Any, - ) -> Union[None, ConfigurationSetting]: - """Delete a ConfigurationSetting if it exists - - :param key: Key used to identify the ConfigurationSetting - :type key: str - :param label: Label used to identify the ConfigurationSetting. Default is `None`. - :type label: str - :keyword etag: Check if the ConfigurationSetting is changed. Set None to skip checking etag - :paramtype etag: str or None - :keyword match_condition: The match condition to use upon the etag - :paramtype match_condition: ~azure.core.MatchConditions - :return: The deleted ConfigurationSetting returned from the service, or None if it doesn't exist. - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \ - :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotModifiedError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError`, \ - :class:`~azure.core.exceptions.ResourceExistsError` - - Example - - .. code-block:: python - - # in async function - deleted_config_setting = await async_client.delete_configuration_setting( - key="MyKey", label="MyLabel" - ) - """ - error_map: Dict[int, Any] = {409: ResourceReadOnlyError} - key_value_deleted = await self._impl.delete_key_value( - key=key, - label=label, - etag=etag, - match_condition=match_condition, - error_map=error_map, - **kwargs, - ) - if key_value_deleted: - return ConfigurationSetting._from_generated(key_value_deleted) - return None - - @distributed_trace - def list_revisions( - self, - key_filter: Optional[str] = None, - label_filter: Optional[str] = None, - *, - tags_filter: Optional[List[str]] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None, - **kwargs: Any, - ) -> AsyncItemPaged[ConfigurationSetting]: - """ - Find the ConfigurationSetting revision history, optionally filtered by key, label, tags and accept_datetime. - For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters. - - :param key_filter: Filter results based on their keys. '*' can be used as wildcard in the beginning or end - of the filter. - :type key_filter: str or None - :param label_filter: Filter results based on their label. '*' can be used as wildcard in the beginning or end - of the filter. - :type label_filter: str or None - :keyword tags_filter: Filter results based on their tags. - :paramtype tags_filter: list[str] or None - :keyword accept_datetime: Retrieve ConfigurationSetting that existed at this datetime - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.ConfigurationSettingFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None - :return: An async iterator of :class:`~azure.appconfiguration.ConfigurationSetting` - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.ConfigurationSetting] - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError` - - Example - - .. code-block:: python - - # in async function - from datetime import datetime, timedelta - - accept_datetime = datetime.utcnow() + timedelta(days=-1) - - all_revisions = async_client.list_revisions() - async for item in all_revisions: - pass # do something - - filtered_revisions = async_client.list_revisions( - label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime) - ) - async for item in filtered_revisions: - pass # do something - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - if fields: - fields = ["locked" if x == "read_only" else x for x in fields] - - return self._impl.get_revisions( # type: ignore[return-value] - label=label_filter, - key=key_filter, - accept_datetime=accept_datetime, - select=fields, - tags=tags_filter, - cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs], - **kwargs, - ) - - @distributed_trace_async - async def set_read_only( - self, - configuration_setting: ConfigurationSetting, - read_only: bool = True, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - **kwargs: Any, - ) -> ConfigurationSetting: - """Set a configuration setting read only - - :param configuration_setting: The ConfigurationSetting to be set read only - :type configuration_setting: ~azure.appconfiguration.ConfigurationSetting - :param read_only: Set the read only setting if true, else clear the read only setting - :type read_only: bool - :keyword match_condition: The match condition to use upon the etag - :paramtype match_condition: ~azure.core.MatchConditions - :return: The ConfigurationSetting returned from the service - :rtype: ~azure.appconfiguration.ConfigurationSetting - :raises: :class:`~azure.core.exceptions.HttpResponseError`, \ - :class:`~azure.core.exceptions.ClientAuthenticationError`, \ - :class:`~azure.core.exceptions.ResourceNotFoundError` - - Example - - .. code-block:: python - - config_setting = await async_client.get_configuration_setting( - key="MyKey", label="MyLabel" - ) - - read_only_config_setting = await async_client.set_read_only(config_setting) - read_only_config_setting = await client.set_read_only(config_setting, read_only=False) - """ - if read_only: - key_value = await self._impl.put_lock( - key=configuration_setting.key, - label=configuration_setting.label, - etag=configuration_setting.etag, - match_condition=match_condition, - **kwargs, - ) - else: - key_value = await self._impl.delete_lock( - key=configuration_setting.key, - label=configuration_setting.label, - etag=configuration_setting.etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSetting._from_generated(key_value) - - @distributed_trace - def list_labels( - self, - *, - name: Optional[str] = None, - after: Optional[str] = None, - accept_datetime: Optional[Union[datetime, str]] = None, - fields: Optional[List[Union[str, LabelFields]]] = None, - **kwargs: Any, - ) -> AsyncItemPaged[ConfigurationSettingLabel]: - """Gets a list of labels. - - :keyword name: A filter for the name of the returned labels. '*' can be used as wildcard - in the beginning or end of the filter. For more information about supported filters, see - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-labels?pivots=v23-11#supported-filters. - :paramtype name: str or None - :keyword after: Instructs the server to return elements that appear after the element referred to - by the specified token. - :paramtype after: str or None - :keyword accept_datetime: Requests the server to respond with the state of the resource at the - specified time. - :paramtype accept_datetime: ~datetime.datetime or str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.LabelFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.LabelFields] or None - :return: An async iterator of labels. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.ConfigurationSettingLabel] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - if isinstance(accept_datetime, datetime): - accept_datetime = str(accept_datetime) - return self._impl.get_labels( # type: ignore[return-value] - name=name, - after=after, - accept_datetime=accept_datetime, - select=fields, - cls=lambda objs: [ConfigurationSettingLabel(name=x.name) for x in objs], - **kwargs, - ) - - @distributed_trace_async - async def begin_create_snapshot( - self, - name: str, - filters: List[ConfigurationSettingsFilter], - *, - composition_type: Optional[Union[str, SnapshotComposition]] = None, - retention_period: Optional[int] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any, - ) -> AsyncLROPoller[ConfigurationSnapshot]: - """Create a snapshot of the configuration settings. - - :param name: The name of the configuration snapshot to create. - :type name: str - :param filters: A list of filters used to filter the configuration settings by key field and label field - included in the configuration snapshot. - :type filters: list[~azure.appconfiguration.ConfigurationSettingsFilter] - :keyword composition_type: The composition type describes how the key-values within the configuration - snapshot are composed. Known values are: "key" and "key_label". 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. - :paramtype composition_type: str or ~azure.appconfiguration.SnapshotComposition or None - :keyword retention_period: The amount of time, in seconds, that a configuration snapshot will remain in the - archived state before expiring. This property is only writable during the creation of a configuration - snapshot. If not specified, will set to 2592000(30 days). If specified, should be - in range 3600(1 hour) to 7776000(90 days). - :paramtype retention_period: int or None - :keyword tags: The tags of the configuration snapshot. - :paramtype tags: dict[str, str] or None - :return: A poller for create configuration snapshot operation. Call `result()` on this object to wait for the - operation to complete and get the created snapshot. - :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.ConfigurationSnapshot] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - snapshot = ConfigurationSnapshot( - filters=filters, composition_type=composition_type, retention_period=retention_period, tags=tags - ) - return cast( - AsyncLROPoller[ConfigurationSnapshot], - await self._impl.begin_create_snapshot( - name=name, entity=snapshot._to_generated(), cls=ConfigurationSnapshot._from_deserialized, **kwargs - ), - ) - - @distributed_trace_async - async def archive_snapshot( - self, - name: str, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSnapshot: - """Archive a configuration setting snapshot. It will update the status of a snapshot from "ready" to "archived". - The retention period will start to count, the snapshot will expire when the entire retention period elapses. - - :param name: The name of the configuration setting snapshot to archive. - :type name: str - :keyword match_condition: The match condition to use upon the etag. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. - :paramtype etag: str or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = await self._impl._update_snapshot( - name=name, - entity=SnapshotUpdateParameters(status=SnapshotStatus.ARCHIVED), - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace_async - async def recover_snapshot( - self, - name: str, - *, - match_condition: MatchConditions = MatchConditions.Unconditionally, - etag: Optional[str] = None, - **kwargs: Any, - ) -> ConfigurationSnapshot: - """Recover a configuration setting snapshot. It will update the status of a snapshot from "archived" to "ready". - - :param name: The name of the configuration setting snapshot to recover. - :type name: str - :keyword match_condition: The match condition to use upon the etag. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword etag: Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. - :paramtype etag: str or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = await self._impl._update_snapshot( - name=name, - entity=SnapshotUpdateParameters(status=SnapshotStatus.READY), - etag=etag, - match_condition=match_condition, - **kwargs, - ) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace_async - async def get_snapshot( - self, name: str, *, fields: Optional[List[Union[str, SnapshotFields]]] = None, **kwargs: Any - ) -> ConfigurationSnapshot: - """Get a configuration setting snapshot. - - :param name: The name of the configuration setting snapshot to retrieve. - :type name: str - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.SnapshotFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.SnapshotFields] or None - :return: The ConfigurationSnapshot returned from the service. - :rtype: ~azure.appconfiguration.ConfigurationSnapshot - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - generated_snapshot = await self._impl.get_snapshot(name=name, select=fields, **kwargs) - return ConfigurationSnapshot._from_generated(generated_snapshot) - - @distributed_trace - def list_snapshots( - self, - *, - name: Optional[str] = None, - fields: Optional[List[Union[str, SnapshotFields]]] = None, - status: Optional[List[Union[str, SnapshotStatus]]] = None, - **kwargs: Any, - ) -> AsyncItemPaged[ConfigurationSnapshot]: - """List the configuration setting snapshots stored in the configuration service, optionally filtered by - snapshot name, snapshot status and fields to present in return. - - :keyword name: Filter results based on snapshot name. - :paramtype name: str or None - :keyword fields: Specify which fields to include in the results. If not specified, will include all fields. - Available fields see :class:`~azure.appconfiguration.SnapshotFields`. - :paramtype fields: list[str] or list[~azure.appconfiguration.SnapshotFields] or None - :keyword status: Filter results based on snapshot keys. Available status see - :class:`~azure.appconfiguration.SnapshotStatus`. - :paramtype status: list[str] or list[~azure.appconfiguration.SnapshotStatus] or None - :return: An iterator of :class:`~azure.appconfiguration.ConfigurationSnapshot` - :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSnapshot] - :raises: :class:`~azure.core.exceptions.HttpResponseError` - """ - return self._impl.get_snapshots( # type: ignore[return-value] - name=name, - select=fields, - status=status, - cls=lambda objs: [ConfigurationSnapshot._from_generated(x) for x in objs], - **kwargs, - ) - - async def update_sync_token(self, token: str) -> None: - """Add a sync token to the internal list of tokens. - - :param str token: The sync token to be added to the internal list of tokens - """ - - await self._sync_token_policy.add_token(token) - - async def close(self) -> None: - """Close all connections made by the client""" - await self._impl._client.close() - - async def __aenter__(self) -> "AzureAppConfigurationClient": - await self._impl.__aenter__() - return self - - async def __aexit__(self, *args: Any) -> None: - await self._impl.__aexit__(*args) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_client.py similarity index 93% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_client.py index 7959eac63eaa..fceba980d46f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_client.py @@ -15,21 +15,21 @@ 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._operations import _AzureAppConfigurationClientOperationsMixin 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". @@ -44,6 +44,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/aio/_configuration.py similarity index 96% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_configuration.py index 6af3e3412b3b..faf2eb85d350 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/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,8 +25,8 @@ 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". diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/__init__.py similarity index 84% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/__init__.py index a90b04c612d7..933fcd7d1b55 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/__init__.py @@ -12,14 +12,11 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import AzureAppConfigurationClientOperationsMixin # type: ignore 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/aio/_operations/_operations.py similarity index 95% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/_operations.py index 8c754c8e8a79..46296f7115f9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_operations/_operations.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/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, Dict, IO, List, 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,17 @@ 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 .._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]] -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 +79,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. @@ -159,7 +156,7 @@ 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 +172,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -187,8 +184,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 +195,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 +224,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 +245,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -273,16 +270,18 @@ def get_key_values( 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 +300,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. @@ -380,7 +380,7 @@ 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 +396,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -424,10 +424,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 +444,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 +508,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -606,13 +609,11 @@ 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.json()) 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")) @@ -763,7 +764,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -860,7 +861,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) deserialized = None @@ -968,7 +969,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -989,7 +990,7 @@ def get_snapshots( 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. @@ -1069,7 +1070,7 @@ 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 +1086,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1144,7 +1145,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1234,16 +1235,14 @@ 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.json()) 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: @@ -1306,7 +1305,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) if _stream: @@ -1375,7 +1374,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1679,7 +1678,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1768,7 +1767,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1790,7 +1789,7 @@ def get_labels( accept_datetime: Optional[str] = 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. @@ -1871,7 +1870,7 @@ 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 +1886,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -1965,7 +1964,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2054,7 +2053,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2151,7 +2150,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2181,16 +2180,18 @@ def get_revisions( 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,7 +2207,8 @@ 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] @@ -2271,7 +2273,7 @@ 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 +2289,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2312,10 +2314,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 +2335,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 +2381,7 @@ 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.json()) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_operations/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_sync_token_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_sync_token_async.py deleted file mode 100644 index efff90353314..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_sync_token_async.py +++ /dev/null @@ -1,91 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- -from typing import Any, Dict, Optional -from asyncio import Lock # pylint: disable=do-not-import-asyncio -from azure.core.pipeline import PipelineRequest, PipelineResponse -from azure.core.pipeline.policies import SansIOHTTPPolicy - -from .._sync_token import SyncToken - - -class AsyncSyncTokenPolicy(SansIOHTTPPolicy): - """A simple policy that enable the given callback with the response. - - :keyword callback raw_response_hook: Callback function. Will be invoked on response. - """ - - def __init__(self, **kwargs: Any) -> None: # pylint: disable=unused-argument - self._sync_token_header = "Sync-Token" - self._sync_tokens: Dict[str, Any] = {} - self._lock = Lock() - - async def on_request(self, request: PipelineRequest) -> None: # pylint: disable=invalid-overridden-method - """This is executed before sending the request to the next policy. - - :param request: The PipelineRequest object. - :type request: ~azure.core.pipeline.PipelineRequest - """ - async with self._lock: - sync_token_header = ",".join(str(x) for x in self._sync_tokens.values()) - if sync_token_header: - request.http_request.headers.update({self._sync_token_header: sync_token_header}) - - async def on_response( # pylint: disable=invalid-overridden-method - self, request: PipelineRequest, response: PipelineResponse - ) -> None: - """This is executed after the request comes back from the policy. - - :param request: The PipelineRequest object. - :type request: ~azure.core.pipeline.PipelineRequest - :param response: The PipelineResponse object. - :type response: ~azure.core.pipeline.PipelineResponse - """ - sync_token_header = response.http_response.headers.get(self._sync_token_header) - if not sync_token_header: - return - sync_token_strings = sync_token_header.split(",") - if not sync_token_strings: - return - for sync_token_string in sync_token_strings: - sync_token = SyncToken.from_sync_token_string(sync_token_string) - await self._update_sync_token(sync_token) - - async def add_token(self, full_raw_tokens: str) -> None: - raw_tokens = full_raw_tokens.split(",") - for raw_token in raw_tokens: - sync_token = SyncToken.from_sync_token_string(raw_token) - await self._update_sync_token(sync_token) - - async def _update_sync_token(self, sync_token: Optional[SyncToken]) -> None: - if not sync_token: - return - async with self._lock: - existing_token = self._sync_tokens.get(sync_token.token_id, None) - if not existing_token: - self._sync_tokens[sync_token.token_id] = sync_token - return - if existing_token.sequence_number < sync_token.sequence_number: - self._sync_tokens[sync_token.token_id] = sync_token diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/__init__.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_enums.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_enums.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_enums.py diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_models.py similarity index 80% rename from sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py rename to sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_models.py index 5187502a03ec..aba7beb944ff 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/models/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_models.py @@ -12,14 +12,13 @@ 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 @@ -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 @@ -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,27 +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 + 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 @@ -258,12 +254,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", @@ -303,9 +296,11 @@ 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() + 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 @@ -314,7 +309,7 @@ class Snapshot(_model_base.Model): """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() + 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 @@ -323,7 +318,7 @@ class Snapshot(_model_base.Model): """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.""" @@ -349,7 +344,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 +352,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/models/_patch.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/models/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value.py new file mode 100644 index 000000000000..145636c9b96a --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_value.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValue.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_match.py new file mode 100644 index 000000000000..5dc96035afed --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_value_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValue_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_none_match.py new file mode 100644 index 000000000000..ae8db69ef5e8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_value_if_none_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_value_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValue_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values.py new file mode 100644 index 000000000000..ae17c88f5e18 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_values.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_values() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValues.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_match.py new file mode 100644 index 000000000000..f0a36f5944c1 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_match.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_values_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_values() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValues_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_none_match.py new file mode 100644 index 000000000000..cdb832e2c08b --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_key_values_if_none_match.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_key_values_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_key_values() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeyValues_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_keys.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_keys.py new file mode 100644 index 000000000000..29003383fa72 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_keys.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_keys.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_keys() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckKeys.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_labels.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_labels.py new file mode 100644 index 000000000000..36d52038d6a9 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_labels.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_labels.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_labels() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckLabels.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_revisions.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_revisions.py new file mode 100644 index 000000000000..be3887160b76 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_revisions.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_revisions.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_revisions() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckRevisions.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot.py new file mode 100644 index 000000000000..946bc0a61d07 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_snapshot.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckSnapshot.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_match.py new file mode 100644 index 000000000000..45559d8f3ee9 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_snapshot_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckSnapshot_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_none_match.py new file mode 100644 index 000000000000..b1d77b84db2e --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshot_if_none_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_snapshot_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/CheckSnapshot_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshots.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshots.py new file mode 100644 index 000000000000..239bbd5fb9bd --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/check_snapshots.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python check_snapshots.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.check_snapshots() + print(response) + + +# x-ms-original-file: 2023-11-01/CheckSnapshots.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/create_snapshot.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/create_snapshot.py new file mode 100644 index 000000000000..8f0d970ba073 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/create_snapshot.py @@ -0,0 +1,34 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python create_snapshot.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.begin_create_snapshot( + name="Prod-2022-08-01", + entity={"filters": [{"key": "app1/*", "label": "Production"}], "retention_period": 3600}, + ).result() + print(response) + + +# x-ms-original-file: 2023-11-01/CreateSnapshot.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value.py new file mode 100644 index 000000000000..2fd331990b21 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python delete_key_value.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.delete_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/DeleteKeyValue.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value_if_match.py new file mode 100644 index 000000000000..130008815f80 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_key_value_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python delete_key_value_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.delete_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/DeleteKeyValue_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock.py new file mode 100644 index 000000000000..0e04f06fa5ce --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python delete_lock.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.delete_lock( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/DeleteLock.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock_if_match.py new file mode 100644 index 000000000000..3a186865d522 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/delete_lock_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python delete_lock_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.delete_lock( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/DeleteLock_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value.py new file mode 100644 index 000000000000..a4db921bbb75 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_value.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetKeyValue.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_match.py new file mode 100644 index 000000000000..1d67d1b8d77c --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_value_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetKeyValue_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_none_match.py new file mode 100644 index 000000000000..fddbfdd55ce0 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_value_if_none_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_value_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_value( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetKeyValue_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values.py new file mode 100644 index 000000000000..7d82b6c03c24 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_values.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_values() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetKeyValues.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_match.py new file mode 100644 index 000000000000..d853bc905679 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_match.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_values_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_values() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetKeyValues_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_none_match.py new file mode 100644 index 000000000000..62fe7d97b386 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_key_values_if_none_match.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_key_values_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_key_values() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetKeyValues_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_keys.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_keys.py new file mode 100644 index 000000000000..c3104084fb73 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_keys.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_keys.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_keys() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetKeys.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_labels.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_labels.py new file mode 100644 index 000000000000..0820f8a91bc5 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_labels.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_labels.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_labels() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetLabels.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_operation_status.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_operation_status.py new file mode 100644 index 000000000000..752297da4f48 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_operation_status.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_operation_status.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_operation_details( + snapshot="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_revisions.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_revisions.py new file mode 100644 index 000000000000..f9a8350f79a3 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_revisions.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_revisions.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_revisions() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetRevisions.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot.py new file mode 100644 index 000000000000..165f683f9a9e --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_snapshot.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetSnapshot.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_failed.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_failed.py new file mode 100644 index 000000000000..f081cacb0148 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_failed.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_snapshot_failed.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetSnapshot_Failed.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_match.py new file mode 100644 index 000000000000..4e94dbf5ac41 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_snapshot_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetSnapshot_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_none_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_none_match.py new file mode 100644 index 000000000000..3444b06b2f89 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshot_if_none_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_snapshot_if_none_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_snapshot( + name="Prod-2022-08-01", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/GetSnapshot_IfNoneMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshots.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshots.py new file mode 100644 index 000000000000..d2db2465c1db --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/get_snapshots.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python get_snapshots.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.get_snapshots() + for item in response: + print(item) + + +# x-ms-original-file: 2023-11-01/GetSnapshots.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock.py new file mode 100644 index 000000000000..7fc810e8a5ef --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python put_lock.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.put_lock( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/PutLock.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock_if_match.py b/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock_if_match.py new file mode 100644 index 000000000000..2767cf4995f8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_samples/put_lock_if_match.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +from azure.appconfiguration import AzureAppConfigurationClient + +""" +# PREREQUISITES + pip install azure-appconfiguration +# USAGE + python put_lock_if_match.py +""" + + +def main(): + client = AzureAppConfigurationClient( + endpoint="https://{exampleAppConfigurationName}.azconfig.io", + credential="CREDENTIAL", + ) + + response = client.put_lock( + key="Message", + ) + print(response) + + +# x-ms-original-file: 2023-11-01/PutLock_IfMatch.json +if __name__ == "__main__": + main() diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration/generated_tests/conftest.py new file mode 100644 index 000000000000..4a951d947504 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_tests/conftest.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + azureappconfiguration_subscription_id = os.environ.get( + "AZUREAPPCONFIGURATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + azureappconfiguration_tenant_id = os.environ.get( + "AZUREAPPCONFIGURATION_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + azureappconfiguration_client_id = os.environ.get( + "AZUREAPPCONFIGURATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + azureappconfiguration_client_secret = os.environ.get( + "AZUREAPPCONFIGURATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azureappconfiguration_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=azureappconfiguration_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azureappconfiguration_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azureappconfiguration_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration.py new file mode 100644 index 000000000000..3729657ec88c --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration.py @@ -0,0 +1,215 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import AzureAppConfigurationClientTestBase, AzureAppConfigurationPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureAppConfiguration(AzureAppConfigurationClientTestBase): + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_keys(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_keys() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_keys(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_keys() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_key_values(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_key_values() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_key_values(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_key_values() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_key_value(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_delete_key_value(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.delete_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_key_value(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_snapshots(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_snapshots() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_snapshots(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_snapshots() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_snapshot(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_snapshot( + name="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_operation_details(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_operation_details( + snapshot="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_begin_create_snapshot(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.begin_create_snapshot( + name="str", + entity={ + "filters": [{"key": "str", "label": "str", "tags": ["str"]}], + "name": "str", + "composition_type": "str", + "created": "2020-02-20 00:00:00", + "etag": "str", + "expires": "2020-02-20 00:00:00", + "items_count": 0, + "retention_period": 0, + "size": 0, + "status": "str", + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_snapshot(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_snapshot( + name="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_labels(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_labels() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_labels(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_labels() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_put_lock(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.put_lock( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_delete_lock(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.delete_lock( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_get_revisions(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.get_revisions() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy + def test_check_revisions(self, azureappconfiguration_endpoint): + client = self.create_client(endpoint=azureappconfiguration_endpoint) + response = client.check_revisions() + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration_async.py b/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration_async.py new file mode 100644 index 000000000000..02b33d04d03f --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_tests/test_azure_app_configuration_async.py @@ -0,0 +1,218 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import AzureAppConfigurationPreparer +from testpreparer_async import AzureAppConfigurationClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureAppConfigurationAsync(AzureAppConfigurationClientTestBaseAsync): + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_keys(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = client.get_keys() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_keys(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_keys() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_key_values(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = client.get_key_values() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_key_values(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_key_values() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_key_value(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.get_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_delete_key_value(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.delete_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_key_value(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_key_value( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_snapshots(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = client.get_snapshots() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_snapshots(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_snapshots() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_snapshot(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.get_snapshot( + name="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_operation_details(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.get_operation_details( + snapshot="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_begin_create_snapshot(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await ( + await client.begin_create_snapshot( + name="str", + entity={ + "filters": [{"key": "str", "label": "str", "tags": ["str"]}], + "name": "str", + "composition_type": "str", + "created": "2020-02-20 00:00:00", + "etag": "str", + "expires": "2020-02-20 00:00:00", + "items_count": 0, + "retention_period": 0, + "size": 0, + "status": "str", + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_snapshot(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_snapshot( + name="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_labels(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = client.get_labels() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_labels(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_labels() + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_put_lock(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.put_lock( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_delete_lock(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.delete_lock( + key="str", + ) + + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_get_revisions(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = client.get_revisions() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @AzureAppConfigurationPreparer() + @recorded_by_proxy_async + async def test_check_revisions(self, azureappconfiguration_endpoint): + client = self.create_async_client(endpoint=azureappconfiguration_endpoint) + response = await client.check_revisions() + + # please add some check logic here by yourself + # ... diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer.py b/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer.py new file mode 100644 index 000000000000..96540c3f4d8e --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer.py @@ -0,0 +1,28 @@ +# 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. +# -------------------------------------------------------------------------- +from azure.appconfiguration import AzureAppConfigurationClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class AzureAppConfigurationClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(AzureAppConfigurationClient) + return self.create_client_from_credential( + AzureAppConfigurationClient, + credential=credential, + endpoint=endpoint, + ) + + +AzureAppConfigurationPreparer = functools.partial( + PowerShellPreparer, + "azureappconfiguration", + azureappconfiguration_endpoint="https://fake_azureappconfiguration_endpoint.com", +) diff --git a/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer_async.py b/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer_async.py new file mode 100644 index 000000000000..71f0697b659c --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# 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. +# -------------------------------------------------------------------------- +from azure.appconfiguration.aio import AzureAppConfigurationClient +from devtools_testutils import AzureRecordedTestCase + + +class AzureAppConfigurationClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(AzureAppConfigurationClient, is_async=True) + return self.create_client_from_credential( + AzureAppConfigurationClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py index 833e15969c8f..052ca6843512 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py index e96883a68078..fe23690694f2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/appconfiguration/azure-appconfiguration/setup.py b/sdk/appconfiguration/azure-appconfiguration/setup.py index 4ad4795294bf..8bb3dccb5a31 100644 --- a/sdk/appconfiguration/azure-appconfiguration/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration/setup.py @@ -5,7 +5,7 @@ # 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 @@ -14,9 +14,10 @@ PACKAGE_NAME = "azure-appconfiguration" PACKAGE_PPRINT_NAME = "App Configuration Data" +PACKAGE_NAMESPACE = "azure.appconfiguration" -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") +# a.b.c => a/b/c +package_folder_path = PACKAGE_NAMESPACE.replace(".", "/") # Version extraction inspired from 'requests' with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: @@ -29,20 +30,19 @@ setup( name=PACKAGE_NAME, version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + description="Microsoft Corporation {} 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", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", keywords="azure, azure sdk", classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -66,5 +66,5 @@ "azure-core>=1.30.0", "typing-extensions>=4.6.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/consts.py b/sdk/appconfiguration/azure-appconfiguration/tests/consts.py index c45e334b7cae..ad77451a9708 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/preparers.py b/sdk/appconfiguration/azure-appconfiguration/tests/preparers.py index 767af0838038..8e82d6e33b41 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/preparers.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/preparers.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. 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 daeb1935e391..56f65693426e 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=line-too-long,useless-suppression,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_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_aad_async.py index fc5f6e6c6aa0..e44a577d0421 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_aad_async.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_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_appconfiguration_client_async.py index a3521c3e9275..f525a2d73de3 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=line-too-long,useless-suppression,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 c758b76ab535..2b9a0a4f9af4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml +++ b/sdk/appconfiguration/azure-appconfiguration/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/appconfiguration/AppConfiguration -commit: 809688280b9cfd5f6e1da2c645408f3a7ef3d6b8 +commit: 4dfa9d8a653b7bc568485929b5d1d17385be5ab0 repo: Azure/azure-rest-api-specs -additionalDirectories: \ No newline at end of file +additionalDirectories: