Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Features Added

- Added `check_configuration_settings()` method to efficiently check for configuration changes using HEAD requests, returning only headers (ETags) without response bodies.
- `list_configuration_settings()` and `check_configuration_settings()` now return `ConfigurationSettingPaged` (sync) / `ConfigurationSettingPagedAsync` (async) to expose the `by_page(match_conditions=...)` API and per-page `etag` attribute for change detection.
- `ConfigurationSettingPaged` and `ConfigurationSettingPagedAsync` are now publicly exported from `azure.appconfiguration`.

### Breaking Changes

### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion sdk/appconfiguration/azure-appconfiguration/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/appconfiguration/azure-appconfiguration",
"Tag": "python/appconfiguration/azure-appconfiguration_64742b5702"
"Tag": "python/appconfiguration/azure-appconfiguration_ea09ae1741"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
ConfigurationSettingsFilter,
ConfigurationSnapshot,
ConfigurationSettingLabel,
ConfigurationSettingPaged,
AsyncConfigurationSettingPaged,
)
from ._generated.models import (
SnapshotStatus,
Expand All @@ -44,6 +46,8 @@
"ConfigurationSettingFields",
"ConfigurationSettingsFilter",
"ConfigurationSettingLabel",
"ConfigurationSettingPaged",
"AsyncConfigurationSettingPaged",
"FILTER_PERCENTAGE",
"FILTER_TARGETING",
"FILTER_TIME_WINDOW",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ def list_configuration_settings(
accept_datetime: Optional[Union[datetime, str]] = None,
fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None,
**kwargs: Any,
) -> ItemPaged[ConfigurationSetting]:
) -> ConfigurationSettingPaged:
"""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
:keyword key_filter: Filter results based on their keys. '*' can be used as wildcard at the 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
:keyword label_filter: Filter results based on their label. '*' can be used as wildcard at the end
of the filter.
:paramtype label_filter: str or None
:keyword tags_filter: Filter results based on their tags.
Expand All @@ -183,7 +183,7 @@ def list_configuration_settings(
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]
:rtype: ~azure.appconfiguration.ConfigurationSettingPaged
:raises: :class:`~azure.core.exceptions.HttpResponseError`, \
:class:`~azure.core.exceptions.ClientAuthenticationError`

Expand Down Expand Up @@ -213,7 +213,7 @@ def list_configuration_settings(
snapshot_name: str,
fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None,
**kwargs: Any,
) -> ItemPaged[ConfigurationSetting]:
) -> ConfigurationSettingPaged:
"""List the configuration settings stored under a snapshot in the configuration service, optionally filtered by
fields to present in return.

Expand All @@ -222,12 +222,12 @@ def list_configuration_settings(
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]
:rtype: ~azure.appconfiguration.ConfigurationSettingPaged
:raises: :class:`~azure.core.exceptions.HttpResponseError`
"""

@distributed_trace
def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> ItemPaged[ConfigurationSetting]:
def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> ConfigurationSettingPaged:
accept_datetime = kwargs.pop("accept_datetime", None)
if isinstance(accept_datetime, datetime):
accept_datetime = str(accept_datetime)
Expand All @@ -237,12 +237,13 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> It
snapshot_name = kwargs.pop("snapshot_name", None)

if snapshot_name is not None:
return self._impl.get_key_values( # type: ignore[return-value]
command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined]
return ConfigurationSettingPaged(
command,
snapshot=snapshot_name,
accept_datetime=accept_datetime,
select=select,
cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs],
**kwargs,
page_iterator_class=ConfigurationSettingPropertiesPaged,
)
tags = kwargs.pop("tags_filter", None)
key_filter, kwargs = get_key_filter(*args, **kwargs)
Expand All @@ -258,6 +259,57 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> It
page_iterator_class=ConfigurationSettingPropertiesPaged,
)

@distributed_trace
def check_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,
**kwargs: Any,
) -> ConfigurationSettingPaged:
Comment thread
mrm9084 marked this conversation as resolved.
"""Check configuration settings using a HEAD request, returning only headers without the
response body. This is useful for efficiently checking if settings have changed by comparing ETags.

:keyword key_filter: Filter results based on their keys. '*' can be used as wildcard at the end
of the filter.
:paramtype key_filter: str or None
:keyword label_filter: Filter results based on their label. '*' can be used as wildcard at the 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
:paramtype fields: list[str] or list[~azure.appconfiguration.ConfigurationSettingFields] or None
:return: A pager intended for :meth:`by_page` iteration to inspect page headers (for example, ``etag``)
and detect changed pages. This operation issues HEAD requests and does not return full
:class:`~azure.appconfiguration.ConfigurationSetting` bodies when iterated item by item.
:rtype: ~azure.appconfiguration.ConfigurationSettingPaged
:raises: :class:`~azure.core.exceptions.HttpResponseError`, \
Comment thread
mrm9084 marked this conversation as resolved.
:class:`~azure.core.exceptions.ClientAuthenticationError`

Example

.. code-block:: python

items = client.check_configuration_settings(key_filter="my_key*")
for page in items.by_page():
print(page.etag) # etag for this page
"""
if isinstance(accept_datetime, datetime):
accept_datetime = str(accept_datetime)
command = functools.partial(self._impl.check_key_values_in_one_page, **kwargs) # type: ignore[attr-defined]
return ConfigurationSettingPaged(
command,
key=key_filter,
label=label_filter,
accept_datetime=accept_datetime,
tags=tags_filter,
page_iterator_class=ConfigurationSettingPropertiesPaged,
)

@distributed_trace
def get_configuration_setting(
self,
Expand Down Expand Up @@ -473,10 +525,10 @@ def list_revisions(
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
:param key_filter: Filter results based on their keys. '*' can be used as wildcard at the 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
:param label_filter: Filter results based on their label. '*' can be used as wildcard at the end
of the filter.
:type label_filter: str or None
:keyword tags_filter: Filter results based on their tags.
Expand Down
Loading