Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
2 changes: 2 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features Added

- Added `check_configuration_settings()` method to efficiently check for configuration changes using HEAD requests, returning only headers (ETags) without response bodies.

### 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 @@ -258,6 +258,65 @@ 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,
fields: Optional[List[Union[str, ConfigurationSettingFields]]] = None,
**kwargs: Any,
) -> ConfigurationSettingPaged:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect we return the same thing that list does, callers just need to know that the iterable will be empty.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return ItemPaged[ConfigurationSetting]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmyca15 I actually looked into this a bit more and we need to return ConfigurationSettingPaged or we/our customers will have typing issues. This includes updating list to also return this. Note this isn't a breaking change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the problem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type checking fails on iterator = items.by_page(match_conditions=etags) as it doesn't see match_conditions as a valid input.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we need to make ConfigurationSettingPaged public?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you look at the diff since your last review you should see me making it public.

"""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 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: 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)
select = fields
Comment thread
mrm9084 marked this conversation as resolved.
Outdated
if select:
select = ["locked" if x == "read_only" else x for x in select]
tags = tags_filter
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,
select=select,
tags=tags,
page_iterator_class=ConfigurationSettingPropertiesPaged,
)

@distributed_trace
def get_configuration_setting(
self,
Expand Down
Loading