Skip to content

Commit 13675f0

Browse files
author
Yalin Li
authored
[AppConfig] Address apiview feedback (Azure#31999)
1 parent 9fe6b4b commit 13675f0

File tree

10 files changed

+69
-46
lines changed

10 files changed

+69
-46
lines changed

sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
### Features Added
66

77
### Breaking Changes
8+
- Rename parameter `name` in `list_snapshot_configuration_settings()` to `snapshot_name`.
9+
- Remove keyword argument `accept_datetime` in `list_snapshot_configuration_settings()`.
10+
- Rename `Snapshot` property `items_count` to `item_count`.
11+
- Publish enum `SnapshotStatus`, and accept the type for `status` parameter in `list_snapshots()` and `status` property in `Snapshot` model.
812

913
### Bugs Fixed
1014

sdk/appconfiguration/azure-appconfiguration/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ for snapshot in client.list_snapshots():
311311
<!-- SNIPPET:snapshot_samples.list_snapshot_configuration_settings -->
312312

313313
```python
314-
for config_setting in client.list_snapshot_configuration_settings(name=snapshot_name):
314+
for config_setting in client.list_snapshot_configuration_settings(snapshot_name=snapshot_name):
315315
print_configuration_setting(config_setting)
316316
```
317317

@@ -410,7 +410,7 @@ async for snapshot in client.list_snapshots():
410410
<!-- SNIPPET:snapshot_samples_async.list_snapshot_configuration_settings -->
411411

412412
```python
413-
async for config_setting in client.list_snapshot_configuration_settings(name=snapshot_name):
413+
async for config_setting in client.list_snapshot_configuration_settings(snapshot_name=snapshot_name):
414414
print_configuration_setting(config_setting)
415415
```
416416

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Snapshot,
1919
ConfigurationSettingFilter,
2020
)
21+
from ._generated.models import SnapshotStatus
2122
from ._version import VERSION
2223
from ._azure_appconfiguration_error import ResourceReadOnlyError
2324

@@ -29,6 +30,7 @@
2930
"FeatureFlagConfigurationSetting",
3031
"SecretReferenceConfigurationSetting",
3132
"Snapshot",
33+
"SnapshotStatus",
3234
"ConfigurationSettingFilter",
3335
"FILTER_PERCENTAGE",
3436
"FILTER_TARGETING",

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from ._azure_appconfiguration_credential import AppConfigConnectionStringCredential
3636
from ._generated import AzureAppConfiguration
3737
from ._generated._configuration import AzureAppConfigurationConfiguration
38-
from ._generated.models import SnapshotStatus, SnapshotUpdateParameters
38+
from ._generated.models import SnapshotUpdateParameters, SnapshotStatus
3939
from ._models import ConfigurationSetting, ConfigurationSettingFilter, Snapshot
4040
from ._utils import (
4141
get_endpoint_from_connection_string,
@@ -562,15 +562,18 @@ def begin_create_snapshot(
562562
:param filters: A list of filters used to filter the configuration settings by key field and label field
563563
included in the snapshot.
564564
:type filters: list[~azure.appconfiguration.ConfigurationSettingFilter]
565-
:keyword str composition_type: The composition type describes how the key-values
565+
:keyword composition_type: The composition type describes how the key-values
566566
within the snapshot are composed. Known values are: "key" and "key_label". The "key" composition type
567567
ensures there are no two key-values containing the same key. The 'key_label' composition type ensures
568568
there are no two key-values containing the same key and label.
569-
:keyword int retention_period: The amount of time, in seconds, that a snapshot will remain in the
569+
:type composition_type: str or None
570+
:keyword retention_period: The amount of time, in seconds, that a snapshot will remain in the
570571
archived state before expiring. This property is only writable during the creation of a
571572
snapshot. If not specified, will set to 2592000(30 days). If specified, should be
572573
in range 3600(1 hour) to 7776000(90 days).
573-
:keyword dict[str, str] tags: The tags of the snapshot.
574+
:type retention_period: int or None
575+
:keyword tags: The tags of the snapshot.
576+
:type tags: dict[str, str] or None
574577
:return: A poller for create snapshot operation. Call `result()` on this object to wait for the
575578
operation to complete and get the created snapshot.
576579
:rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.Snapshot]
@@ -605,7 +608,8 @@ def archive_snapshot(
605608
:type name: str
606609
:keyword match_condition: The match condition to use upon the etag.
607610
:type match_condition: ~azure.core.MatchConditions
608-
:keyword str etag: Check if the Snapshot is changed. Set None to skip checking etag.
611+
:keyword etag: Check if the Snapshot is changed. Set None to skip checking etag.
612+
:type etag: str or None
609613
:return: The Snapshot returned from the service.
610614
:rtype: ~azure.appconfiguration.Snapshot
611615
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -647,7 +651,8 @@ def recover_snapshot(
647651
:type name: str
648652
:keyword match_condition: The match condition to use upon the etag.
649653
:type match_condition: ~azure.core.MatchConditions
650-
:keyword str etag: Check if the Snapshot is changed. Set None to skip checking etag.
654+
:keyword etag: Check if the Snapshot is changed. Set None to skip checking etag.
655+
:type etag: str or None
651656
:return: The Snapshot returned from the service.
652657
:rtype: ~azure.appconfiguration.Snapshot
653658
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -680,7 +685,8 @@ def get_snapshot(self, name: str, *, fields: Optional[List[str]] = None, **kwarg
680685
681686
:param name: The name of the configuration setting snapshot to retrieve.
682687
:type name: str
683-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields.
688+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
689+
:type fields: list[str] or None
684690
:return: The Snapshot returned from the service.
685691
:rtype: ~azure.appconfiguration.Snapshot
686692
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -699,15 +705,18 @@ def list_snapshots(
699705
*,
700706
name: Optional[str] = None,
701707
fields: Optional[List[str]] = None,
702-
status: Optional[List[str]] = None,
708+
status: Optional[List[Union[str, SnapshotStatus]]] = None,
703709
**kwargs
704710
) -> ItemPaged[Snapshot]:
705711
"""List the configuration setting snapshots stored in the configuration service, optionally filtered by
706712
snapshot name, snapshot status and fields to present in return.
707713
708-
:keyword str name: Filter results based on snapshot name.
709-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields.
710-
:keyword list[str] status: Filter results based on snapshot keys.
714+
:keyword name: Filter results based on snapshot name.
715+
:type name: str or None
716+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
717+
:type fields: list[str] or None
718+
:keyword status: Filter results based on snapshot keys.
719+
:type status: list[str] or list[~azure.appconfiguration.SnapshotStatus] or None
711720
:return: An iterator of :class:`~azure.appconfiguration.Snapshot`
712721
:rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.Snapshot]
713722
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -725,14 +734,14 @@ def list_snapshots(
725734

726735
@distributed_trace
727736
def list_snapshot_configuration_settings(
728-
self, name: str, *, accept_datetime: Optional[str] = None, fields: Optional[List[str]] = None, **kwargs
737+
self, snapshot_name: str, *, fields: Optional[List[str]] = None, **kwargs
729738
) -> ItemPaged[ConfigurationSetting]:
730739
"""List the configuration settings stored under a snapshot in the configuration service, optionally filtered by
731740
accept_datetime and fields to present in return.
732741
733-
:param str name: The snapshot name.
734-
:keyword str accept_datetime: Filter out ConfigurationSetting created after this datetime
735-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields
742+
:param str snapshot_name: The snapshot name.
743+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
744+
:type fields: list[str] or None
736745
:return: An iterator of :class:`~azure.appconfiguration.ConfigurationSetting`
737746
:rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.ConfigurationSetting]
738747
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -743,8 +752,7 @@ def list_snapshot_configuration_settings(
743752
try:
744753
return self._impl.get_key_values( # type: ignore
745754
select=fields,
746-
snapshot=name,
747-
accept_datetime=accept_datetime,
755+
snapshot=snapshot_name,
748756
cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs],
749757
**kwargs
750758
)

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from ._generated._serialization import Model
1212
from ._generated.models import (
1313
KeyValue,
14-
Snapshot as GeneratedSnapshot,
1514
KeyValueFilter,
15+
Snapshot as GeneratedSnapshot,
16+
SnapshotStatus,
1617
)
1718

1819
if sys.version_info >= (3, 8):
@@ -409,7 +410,7 @@ class Snapshot: # pylint: disable=too-many-instance-attributes
409410

410411
name: Optional[str]
411412
"""The name of the snapshot."""
412-
status: Optional[str]
413+
status: Optional[Union[str, SnapshotStatus]]
413414
"""The current status of the snapshot. Known values are: "provisioning", "ready",
414415
"archived", and "failed"."""
415416
filters: List[ConfigurationSettingFilter]
@@ -429,7 +430,7 @@ class Snapshot: # pylint: disable=too-many-instance-attributes
429430
snapshot. If not specified, the default lifetime of key-value revisions will be used."""
430431
size: Optional[int]
431432
"""The size in bytes of the snapshot."""
432-
items_count: Optional[int]
433+
item_count: Optional[int]
433434
"""The amount of key-values in the snapshot."""
434435
tags: Optional[Dict[str, str]]
435436
"""The tags of the snapshot."""
@@ -468,7 +469,7 @@ def __init__(
468469
self.expires = None
469470
self.retention_period = retention_period
470471
self.size = None
471-
self.items_count = None
472+
self.item_count = None
472473
self.tags = tags
473474
self.etag = None
474475

@@ -494,7 +495,7 @@ def _from_generated(cls, generated: GeneratedSnapshot) -> "Snapshot":
494495
snapshot.created = generated.created
495496
snapshot.expires = generated.expires
496497
snapshot.size = generated.size
497-
snapshot.items_count = generated.items_count
498+
snapshot.item_count = generated.items_count
498499
snapshot.etag = generated.etag
499500

500501
return snapshot
@@ -525,7 +526,7 @@ def _from_deserialized( # pylint:disable=unused-argument
525526
snapshot.created = deserialized.created
526527
snapshot.expires = deserialized.expires
527528
snapshot.size = deserialized.size
528-
snapshot.items_count = deserialized.items_count
529+
snapshot.item_count = deserialized.items_count
529530
snapshot.etag = deserialized.etag
530531

531532
return snapshot

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_appconfiguration_client_async.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from .._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy
2929
from .._azure_appconfiguration_credential import AppConfigConnectionStringCredential
3030
from .._generated.aio import AzureAppConfiguration
31-
from .._generated.models import SnapshotStatus, SnapshotUpdateParameters
31+
from .._generated.models import SnapshotUpdateParameters, SnapshotStatus
3232
from .._models import ConfigurationSetting, ConfigurationSettingFilter, Snapshot
3333
from .._user_agent import USER_AGENT
3434
from .._utils import (
@@ -551,15 +551,18 @@ async def begin_create_snapshot(
551551
:param filters: A list of filters used to filter the configuration settings by key field and label field
552552
included in the snapshot.
553553
:type filters: list[~azure.appconfiguration.ConfigurationSettingFilter]
554-
:keyword str composition_type: The composition type describes how the key-values
554+
:keyword composition_type: The composition type describes how the key-values
555555
within the snapshot are composed. Known values are: "key" and "key_label". The "key" composition type
556556
ensures there are no two key-values containing the same key. The 'key_label' composition type ensures
557557
there are no two key-values containing the same key and label.
558-
:keyword int retention_period: The amount of time, in seconds, that a snapshot will remain in the
558+
:type composition_type: str or None
559+
:keyword retention_period: The amount of time, in seconds, that a snapshot will remain in the
559560
archived state before expiring. This property is only writable during the creation of a
560561
snapshot. If not specified, will set to 2592000(30 days). If specified, should be
561562
in range 3600(1 hour) to 7776000(90 days).
562-
:keyword dict[str, str] tags: The tags of the snapshot.
563+
:type retention_period: int or None
564+
:keyword tags: The tags of the snapshot.
565+
:type tags: dict[str, str] or None
563566
:return: An async poller for create snapshot operation. Call `result()` on this object to wait for the
564567
operation to complete and get the created snapshot.
565568
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.appconfiguration.Snapshot]
@@ -594,7 +597,8 @@ async def archive_snapshot(
594597
:type name: str
595598
:keyword match_condition: The match condition to use upon the etag.
596599
:type match_condition: ~azure.core.MatchConditions
597-
:keyword str etag: Check if the Snapshot is changed. Set None to skip checking etag.
600+
:keyword etag: Check if the Snapshot is changed. Set None to skip checking etag.
601+
:type etag: str or None
598602
:return: The Snapshot returned from the service.
599603
:rtype: ~azure.appconfiguration.Snapshot
600604
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -636,7 +640,8 @@ async def recover_snapshot(
636640
:type name: str
637641
:keyword match_condition: The match condition to use upon the etag.
638642
:type match_condition: ~azure.core.MatchConditions
639-
:keyword str etag: Check if the Snapshot is changed. Set None to skip checking etag.
643+
:keyword etag: Check if the Snapshot is changed. Set None to skip checking etag.
644+
:type etag: str or None
640645
:return: The Snapshot returned from the service.
641646
:rtype: ~azure.appconfiguration.Snapshot
642647
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -669,7 +674,8 @@ async def get_snapshot(self, name: str, *, fields: Optional[List[str]] = None, *
669674
670675
:param name: The name of the configuration setting snapshot to retrieve.
671676
:type name: str
672-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields.
677+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
678+
:type fields: list[str] or None
673679
:return: The Snapshot returned from the service.
674680
:rtype: ~azure.appconfiguration.Snapshot
675681
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -688,15 +694,18 @@ def list_snapshots(
688694
*,
689695
name: Optional[str] = None,
690696
fields: Optional[List[str]] = None,
691-
status: Optional[List[str]] = None,
697+
status: Optional[List[Union[str, SnapshotStatus]]] = None,
692698
**kwargs
693699
) -> AsyncItemPaged[Snapshot]:
694700
"""List the configuration setting snapshots stored in the configuration service, optionally filtered by
695701
snapshot name, snapshot status and fields to present in return.
696702
697-
:keyword str name: Filter results based on snapshot name.
698-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields.
699-
:keyword list[str] status: Filter results based on snapshot keys.
703+
:keyword name: Filter results based on snapshot name.
704+
:type name: str or None
705+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
706+
:type fields: list[str] or None
707+
:keyword status: Filter results based on snapshot keys.
708+
:type status: list[str] or list[~azure.appconfiguration.SnapshotStatus] or None
700709
:return: An async iterator of :class:`~azure.appconfiguration.Snapshot`
701710
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.Snapshot]
702711
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -714,14 +723,14 @@ def list_snapshots(
714723

715724
@distributed_trace
716725
def list_snapshot_configuration_settings(
717-
self, name: str, *, accept_datetime: Optional[str] = None, fields: Optional[List[str]] = None, **kwargs
726+
self, snapshot_name: str, *, fields: Optional[List[str]] = None, **kwargs
718727
) -> AsyncItemPaged[ConfigurationSetting]:
719728
"""List the configuration settings stored under a snapshot in the configuration service, optionally filtered by
720729
accept_datetime and fields to present in return.
721730
722-
:param str name: The snapshot name.
723-
:keyword str accept_datetime: Filter out ConfigurationSetting created after this datetime.
724-
:keyword list[str] fields: Specify which fields to include in the results. Leave None to include all fields.
731+
:param str snapshot_name: The snapshot name.
732+
:keyword fields: Specify which fields to include in the results. Leave None to include all fields.
733+
:type fields: list[str] or None
725734
:return: An async iterator of :class:`~azure.appconfiguration.ConfigurationSetting`
726735
:rtype: ~azure.core.paging.AsyncItemPaged[~azure.appconfiguration.ConfigurationSetting]
727736
:raises: :class:`~azure.core.exceptions.HttpResponseError`
@@ -732,8 +741,7 @@ def list_snapshot_configuration_settings(
732741
try:
733742
return self._impl.get_key_values( # type: ignore
734743
select=fields,
735-
snapshot=name,
736-
accept_datetime=accept_datetime,
744+
snapshot=snapshot_name,
737745
cls=lambda objs: [ConfigurationSetting._from_generated(x) for x in objs],
738746
**kwargs
739747
)

sdk/appconfiguration/azure-appconfiguration/samples/snapshot_samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def main():
6565
print("")
6666

6767
# [START list_snapshot_configuration_settings]
68-
for config_setting in client.list_snapshot_configuration_settings(name=snapshot_name):
68+
for config_setting in client.list_snapshot_configuration_settings(snapshot_name=snapshot_name):
6969
print_configuration_setting(config_setting)
7070
# [END list_snapshot_configuration_settings]
7171

sdk/appconfiguration/azure-appconfiguration/samples/snapshot_samples_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async def main():
6868
print("")
6969

7070
# [START list_snapshot_configuration_settings]
71-
async for config_setting in client.list_snapshot_configuration_settings(name=snapshot_name):
71+
async for config_setting in client.list_snapshot_configuration_settings(snapshot_name=snapshot_name):
7272
print_configuration_setting(config_setting)
7373
# [END list_snapshot_configuration_settings]
7474

sdk/appconfiguration/azure-appconfiguration/samples/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ def print_snapshot(snapshot):
3030
print(f"expires: {snapshot.expires}")
3131
print(f"retention_period: {snapshot.retention_period}")
3232
print(f"size: {snapshot.size}")
33-
print(f"items_count: {snapshot.items_count}")
33+
print(f"item_count: {snapshot.item_count}")
3434
print(f"tags: {snapshot.tags}")
3535
print(f"etag: {snapshot.etag}")

sdk/appconfiguration/azure-appconfiguration/tests/testcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _assert_snapshots(self, snapshot: Snapshot, expected_snapshot: Snapshot):
100100
for index, filter in enumerate(snapshot.filters):
101101
assert filter.key == expected_snapshot.filters[index].key
102102
assert filter.label == expected_snapshot.filters[index].label
103-
assert snapshot.items_count == expected_snapshot.items_count
103+
assert snapshot.item_count == expected_snapshot.item_count
104104
assert snapshot.name == expected_snapshot.name
105105
assert snapshot.retention_period == expected_snapshot.retention_period
106106
assert snapshot.size == expected_snapshot.size

0 commit comments

Comments
 (0)