Skip to content

Commit 275dc10

Browse files
author
Yalin Li
authored
[AppConfig] Add "list labels" and "filter by tags" supports (#35210)
1 parent e3c8990 commit 275dc10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1530
-1278
lines changed

sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
## 1.6.1 (Unreleased)
44

55
### Features Added
6-
7-
### Breaking Changes
6+
- Added operation `list_labels()` for listing configuration setting labels.
7+
- Supported filtering by configuration setting tags in `list_configuration_settings()` and `list_revisions()`.
8+
- Added a new property tags to ConfigurationSettingsFilter to support filtering settings with tags filter for snapshot.
89

910
### Bugs Fixed
1011
- Fixed a bug where the `feature_id` of `FeatureFlagConfigurationSetting` will be different from `id` customer field, and may overwrite the original customer-defined value if different from the `FeatureFlagConfigurationSetting` key suffix.
1112

1213
### Other Changes
14+
- Updated the default `api_version` to "2023-11-01".
15+
- Published enum `LabelFields` and model `ConfigurationSettingLabel`.
16+
- Published enum `SnapshotFields`, and accepted the type for `fields` parameter in `get_snapshot()` and `list_snapshots()`.
17+
- Published enum `ConfigurationSettingFields`, and accepted the type for `fields` parameter in `list_configuration_settings()` and `list_revisions()`.
18+
- Published enum `SnapshotComposition`, and accepted the type for `ConfigurationSnapshot` property `composition_type` and `begion_create_snapshot()` kwarg `composition_type`.
1319

1420
## 1.6.0 (2024-04-09)
1521

sdk/appconfiguration/azure-appconfiguration/README.md

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ There are two ways to store a Configuration Setting:
179179

180180
- add_configuration_setting creates a setting only if the setting does not already exist in the store.
181181

182-
<!-- SNIPPET:hello_world_advanced_sample.create_config_setting -->
182+
<!-- SNIPPET:hello_world_sample.create_config_setting -->
183183

184184
```python
185185
config_setting = ConfigurationSetting(
@@ -192,7 +192,7 @@ added_config_setting = client.add_configuration_setting(config_setting)
192192

193193
- set_configuration_setting creates a setting if it doesn't exist or overrides an existing setting.
194194

195-
<!-- SNIPPET:hello_world_advanced_sample.set_config_setting -->
195+
<!-- SNIPPET:hello_world_sample.set_config_setting -->
196196

197197
```python
198198
added_config_setting.value = "new value"
@@ -202,11 +202,33 @@ updated_config_setting = client.set_configuration_setting(added_config_setting)
202202

203203
<!-- END SNIPPET -->
204204

205+
### Set and clear read-only for a configuration setting.
206+
207+
- Set a configuration setting to be read-only.
208+
209+
<!-- SNIPPET:read_only_sample.set_read_only -->
210+
211+
```python
212+
read_only_config_setting = client.set_read_only(updated_config_setting)
213+
```
214+
215+
<!-- END SNIPPET -->
216+
217+
- Clear read-only for a configuration setting.
218+
219+
<!-- SNIPPET:read_only_sample.clear_read_only -->
220+
221+
```python
222+
read_write_config_setting = client.set_read_only(updated_config_setting, False)
223+
```
224+
225+
<!-- END SNIPPET -->
226+
205227
### Get a Configuration Setting
206228

207229
Get a previously stored Configuration Setting.
208230

209-
<!-- SNIPPET:hello_world_advanced_sample.get_config_setting -->
231+
<!-- SNIPPET:hello_world_sample.get_config_setting -->
210232

211233
```python
212234
fetched_config_setting = client.get_configuration_setting(key="MyKey", label="MyLabel")
@@ -218,49 +240,84 @@ fetched_config_setting = client.get_configuration_setting(key="MyKey", label="My
218240

219241
Delete an existing Configuration Setting.
220242

221-
<!-- SNIPPET:hello_world_advanced_sample.delete_config_setting -->
243+
<!-- SNIPPET:hello_world_sample.delete_config_setting -->
222244

223245
```python
224-
client.delete_configuration_setting(
225-
key="MyKey",
226-
label="MyLabel",
227-
)
246+
client.delete_configuration_setting(key="MyKey", label="MyLabel")
228247
```
229248

230249
<!-- END SNIPPET -->
231250

232251
### List Configuration Settings
233252

234-
List all configuration settings filtered with label_filter and/or key_filter.
253+
List all configuration settings filtered with label_filter and/or key_filter and/or tags_filter.
254+
255+
<!-- SNIPPET:list_configuration_settings_sample.list_configuration_settings -->
256+
257+
```python
258+
config_settings = client.list_configuration_settings(key_filter="MyKey*", tags_filter=["my tag1=my tag1 value"])
259+
for config_setting in config_settings:
260+
print(config_setting)
261+
```
262+
263+
<!-- END SNIPPET -->
264+
265+
### List revisions
266+
267+
List revision history of configuration settings filtered with label_filter and/or key_filter and/or tags_filter.
268+
269+
<!-- SNIPPET:list_revision_sample.list_revisions -->
270+
271+
```python
272+
items = client.list_revisions(key_filter="MyKey", tags_filter=["my tag=my tag value"])
273+
for item in items:
274+
print(item)
275+
```
276+
277+
<!-- END SNIPPET -->
278+
279+
### List labels
280+
281+
List labels of all configuration settings.
235282

236-
<!-- SNIPPET:hello_world_advanced_sample.list_config_setting -->
283+
<!-- SNIPPET:list_labels_sample.list_labels -->
237284

238285
```python
239-
config_settings = client.list_configuration_settings(label_filter="MyLabel")
240-
for item in config_settings:
241-
print_configuration_setting(item)
286+
print("List all labels in resource")
287+
config_settings = client.list_labels()
288+
for config_setting in config_settings:
289+
print(config_setting)
290+
291+
print("List labels by exact match")
292+
config_settings = client.list_labels(name="my label1")
293+
for config_setting in config_settings:
294+
print(config_setting)
295+
296+
print("List labels by wildcard")
297+
config_settings = client.list_labels(name="my label*")
298+
for config_setting in config_settings:
299+
print(config_setting)
242300
```
243301

244302
<!-- END SNIPPET -->
245303

246304
### Create a Snapshot
247305

248-
<!-- SNIPPET:snapshot_samples.create_snapshot -->
306+
<!-- SNIPPET:snapshot_sample.create_snapshot -->
249307

250308
```python
251309
from azure.appconfiguration import ConfigurationSettingsFilter
252310

253311
filters = [ConfigurationSettingsFilter(key="my_key1", label="my_label1")]
254312
response = client.begin_create_snapshot(name=snapshot_name, filters=filters)
255313
created_snapshot = response.result()
256-
print_snapshot(created_snapshot)
257314
```
258315

259316
<!-- END SNIPPET -->
260317

261318
### Get a Snapshot
262319

263-
<!-- SNIPPET:snapshot_samples.get_snapshot -->
320+
<!-- SNIPPET:snapshot_sample.get_snapshot -->
264321

265322
```python
266323
received_snapshot = client.get_snapshot(name=snapshot_name)
@@ -270,52 +327,50 @@ received_snapshot = client.get_snapshot(name=snapshot_name)
270327

271328
### Archive a Snapshot
272329

273-
<!-- SNIPPET:snapshot_samples.archive_snapshot -->
330+
<!-- SNIPPET:snapshot_sample.archive_snapshot -->
274331

275332
```python
276333
archived_snapshot = client.archive_snapshot(name=snapshot_name)
277-
print_snapshot(archived_snapshot)
278334
```
279335

280336
<!-- END SNIPPET -->
281337

282338
### Recover a Snapshot
283339

284-
<!-- SNIPPET:snapshot_samples.recover_snapshot -->
340+
<!-- SNIPPET:snapshot_sample.recover_snapshot -->
285341

286342
```python
287343
recovered_snapshot = client.recover_snapshot(name=snapshot_name)
288-
print_snapshot(recovered_snapshot)
289344
```
290345

291346
<!-- END SNIPPET -->
292347

293348
### List Snapshots
294349

295-
<!-- SNIPPET:snapshot_samples.list_snapshots -->
350+
<!-- SNIPPET:snapshot_sample.list_snapshots -->
296351

297352
```python
298353
for snapshot in client.list_snapshots():
299-
print_snapshot(snapshot)
354+
print(snapshot)
300355
```
301356

302357
<!-- END SNIPPET -->
303358

304359
### List Configuration Settings of a Snapshot
305360

306-
<!-- SNIPPET:snapshot_samples.list_configuration_settings_for_snapshot -->
361+
<!-- SNIPPET:snapshot_sample.list_configuration_settings_for_snapshot -->
307362

308363
```python
309364
for config_setting in client.list_configuration_settings(snapshot_name=snapshot_name):
310-
print_configuration_setting(config_setting)
365+
print(config_setting)
311366
```
312367

313368
<!-- END SNIPPET -->
314369

315370
### Async APIs
316371

317372
Async client is supported.
318-
To use the async client library, import the AzureAppConfigurationClient from package azure.appconfiguration.aio instead of azure.appconfiguration
373+
To use the async client library, import the AzureAppConfigurationClient from package azure.appconfiguration.aio instead of azure.appconfiguration.
319374

320375
<!-- SNIPPET:hello_world_sample_async.create_app_config_client -->
321376

@@ -325,88 +380,31 @@ from azure.appconfiguration.aio import AzureAppConfigurationClient
325380

326381
CONNECTION_STRING = os.environ["APPCONFIGURATION_CONNECTION_STRING"]
327382

328-
# Create app config client
383+
# Create an app config client
329384
client = AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING)
330385
```
331386

332387
<!-- END SNIPPET -->
333388

334-
This async AzureAppConfigurationClient has the same method signatures as the sync ones except that they're async.
335-
For instance, to retrieve a Configuration Setting asynchronously, async_client can be used:
389+
This async AzureAppConfigurationClient has the same method signatures as the sync ones except that they're async.\
390+
For instance, retrieve a Configuration Setting asynchronously:
336391

337-
<!-- SNIPPET:hello_world_advanced_sample_async.get_config_setting -->
392+
<!-- SNIPPET:hello_world_sample_async.get_config_setting -->
338393

339394
```python
340395
fetched_config_setting = await client.get_configuration_setting(key="MyKey", label="MyLabel")
341396
```
342397

343398
<!-- END SNIPPET -->
344399

345-
To use list_configuration_settings, call it synchronously and iterate over the returned async iterator asynchronously
346-
347-
<!-- SNIPPET:hello_world_advanced_sample_async.list_config_setting -->
348-
349-
```python
350-
config_settings = client.list_configuration_settings(label_filter="MyLabel")
351-
async for item in config_settings:
352-
print_configuration_setting(item)
353-
```
354-
355-
<!-- END SNIPPET -->
356-
357-
<!-- SNIPPET:snapshot_samples_async.create_snapshot -->
358-
359-
```python
360-
from azure.appconfiguration import ConfigurationSettingsFilter
361-
362-
filters = [ConfigurationSettingsFilter(key="my_key1", label="my_label1")]
363-
response = await client.begin_create_snapshot(name=snapshot_name, filters=filters)
364-
created_snapshot = await response.result()
365-
print_snapshot(created_snapshot)
366-
```
367-
368-
<!-- END SNIPPET -->
369-
370-
<!-- SNIPPET:snapshot_samples_async.get_snapshot -->
371-
372-
```python
373-
received_snapshot = await client.get_snapshot(name=snapshot_name)
374-
```
375-
376-
<!-- END SNIPPET -->
377-
378-
<!-- SNIPPET:snapshot_samples_async.archive_snapshot -->
379-
380-
```python
381-
archived_snapshot = await client.archive_snapshot(name=snapshot_name)
382-
print_snapshot(archived_snapshot)
383-
```
384-
385-
<!-- END SNIPPET -->
386-
387-
<!-- SNIPPET:snapshot_samples_async.recover_snapshot -->
388-
389-
```python
390-
recovered_snapshot = await client.recover_snapshot(name=snapshot_name)
391-
print_snapshot(recovered_snapshot)
392-
```
393-
394-
<!-- END SNIPPET -->
395-
396-
<!-- SNIPPET:snapshot_samples_async.list_snapshots -->
397-
398-
```python
399-
async for snapshot in client.list_snapshots():
400-
print_snapshot(snapshot)
401-
```
402-
403-
<!-- END SNIPPET -->
400+
To list configuration settings, call `list_configuration_settings` operation synchronously and iterate over the returned async iterator asynchronously:
404401

405-
<!-- SNIPPET:snapshot_samples_async.list_configuration_settings_for_snapshot -->
402+
<!-- SNIPPET:list_configuration_settings_sample_async.list_configuration_settings -->
406403

407404
```python
408-
async for config_setting in client.list_configuration_settings(snapshot_name=snapshot_name):
409-
print_configuration_setting(config_setting)
405+
config_settings = client.list_configuration_settings(key_filter="MyKey*", tags_filter=["my tag1=my tag1 value"])
406+
async for config_setting in config_settings:
407+
print(config_setting)
410408
```
411409

412410
<!-- END SNIPPET -->
@@ -421,11 +419,13 @@ See the [troubleshooting guide][troubleshooting_guide] for details on how to dia
421419

422420
Several App Configuration client library samples are available to you in this GitHub repository. These include:
423421
- [Hello world](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py)
424-
- [Hello world with labels](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_advanced_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_advanced_sample_async.py)
422+
- [List configuration settings](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/list_configuration_settings_sample_async.py)
425423
- [Make a configuration setting readonly](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/read_only_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/hello_world_sample_async.py)
426424
- [Read revision history](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/list_revision_sample_async.py)
427425
- [Get a setting if changed](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/conditional_operation_sample_async.py)
428-
- [Create, retrieve and update status of a configuration settings snapshot](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_samples.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_samples_async.py)
426+
- [Create, retrieve and update status of a configuration settings snapshot](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/snapshot_sample_async.py)
427+
- [Send custom HTTP requests](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/send_request_sample_async.py)
428+
- [Update AzureAppConfigurationClient sync_token](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample.py) / [Async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/sync_token_sample_async.py)
429429

430430
For more details see the [samples README](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/samples/README.md).
431431

sdk/appconfiguration/azure-appconfiguration/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/appconfiguration/azure-appconfiguration",
5-
"Tag": "python/appconfiguration/azure-appconfiguration_27c8f82a12"
5+
"Tag": "python/appconfiguration/azure-appconfiguration_6552b5023e"
66
}

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
ConfigurationSetting,
1616
FeatureFlagConfigurationSetting,
1717
SecretReferenceConfigurationSetting,
18-
ConfigurationSnapshot,
1918
ConfigurationSettingsFilter,
19+
ConfigurationSnapshot,
20+
ConfigurationSettingLabel,
21+
)
22+
from ._generated.models import (
23+
SnapshotStatus,
24+
LabelFields,
25+
SnapshotFields,
26+
ConfigurationSettingFields,
27+
SnapshotComposition,
2028
)
21-
from ._generated.models import SnapshotStatus
2229
from ._version import VERSION
2330
from ._azure_appconfiguration_error import ResourceReadOnlyError
2431

@@ -31,7 +38,12 @@
3138
"SecretReferenceConfigurationSetting",
3239
"ConfigurationSnapshot",
3340
"SnapshotStatus",
41+
"SnapshotFields",
42+
"SnapshotComposition",
43+
"LabelFields",
44+
"ConfigurationSettingFields",
3445
"ConfigurationSettingsFilter",
46+
"ConfigurationSettingLabel",
3547
"FILTER_PERCENTAGE",
3648
"FILTER_TARGETING",
3749
"FILTER_TIME_WINDOW",

0 commit comments

Comments
 (0)