From 5f23239333cd6dbdebd5df3f2c3449758648c451 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Jun 2021 14:31:06 -0400 Subject: [PATCH 01/60] adding docstrings for displayname and description --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 69722cd73b23..f171da666981 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -123,6 +123,10 @@ class FeatureFlagConfigurationSetting( :type filters: list[dict[str, Any]] :param label: :type label: str + :param display_name: + :type display_name: str + :param description: + :type description: str :param content_type: :type content_type: str :ivar last_modified: From 184451f1c06132e1f55fc04640a2b2f37875bc32 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Jun 2021 14:40:10 -0400 Subject: [PATCH 02/60] changing key -> feature_id --- .../azure/appconfiguration/_models.py | 12 ++++----- .../tests/test_azure_configuration_client.py | 26 +++++++++---------- .../test_azure_configuration_client_aad.py | 10 +++---- ...st_azure_configuration_client_aad_async.py | 10 +++---- .../test_azure_configuration_client_async.py | 10 +++---- .../tests/test_consistency.py | 9 ++++--- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index f171da666981..1c58d4ddba11 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -113,8 +113,8 @@ class FeatureFlagConfigurationSetting( :ivar etag: Entity tag (etag) of the object :vartype etag: str - :ivar key: - :vartype key: str + :ivar feature_id: + :vartype feature_id: str :ivar value: The value of the configuration setting :vartype value: str :ivar enabled: @@ -139,7 +139,7 @@ class FeatureFlagConfigurationSetting( _attribute_map = { "etag": {"key": "etag", "type": "str"}, - "key": {"key": "key", "type": "str"}, + "feature_id": {"key": "key", "type": "str"}, "label": {"key": "label", "type": "str"}, "content_type": {"key": "content_type", "type": "str"}, "value": {"key": "value", "type": "str"}, @@ -158,7 +158,7 @@ def __init__(self, feature_id, enabled, filters=[], **kwargs): # pylint: disabl super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) if not feature_id.startswith(self.key_prefix): feature_id = self.key_prefix + feature_id - self.key = feature_id + self.feature_id = 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) @@ -171,7 +171,7 @@ def __init__(self, feature_id, enabled, filters=[], **kwargs): # pylint: disabl def _validate(self): # type: () -> None - if not self.key.startswith(self.key_prefix): + if not self.feature_id.startswith(self.key_prefix): raise ValueError("All FeatureFlagConfigurationSettings should be prefixed with {}.".format(self.key_prefix)) if not (self.value is None or isinstance(self.value, dict)): raise ValueError("Expect 'value' to be a dictionary.") @@ -250,7 +250,7 @@ def _to_generated(self): # type: () -> KeyValue return KeyValue( - key=self.key, + key=self.feature_id, label=self.label, value=json.dumps(self.value), # NOTE: This has to be added for valid json content_type=self.content_type, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 8ffa613bcc4a..aa441386f981 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -550,7 +550,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.key) + client.delete_configuration_setting(changed_flag.feature_id) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -635,7 +635,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.key) + client.delete_configuration_setting(updated_sent_config.feature_id) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -660,7 +660,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_custom(self, client): @@ -685,7 +685,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -733,7 +733,7 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_breaking1(self, client): @@ -751,7 +751,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking2', @@ -767,7 +767,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) # This will show up as a Custom filter new = FeatureFlagConfigurationSetting( @@ -784,7 +784,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking4', @@ -797,7 +797,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking5', @@ -814,7 +814,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking6', @@ -827,7 +827,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking7', @@ -839,7 +839,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) new = FeatureFlagConfigurationSetting( 'breaking8', @@ -852,7 +852,7 @@ def test_breaking1(self, client): ) new.feature_flag_content_type = "fakeyfakey" client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.key) + new1 = client.get_configuration_setting(new.feature_id) @app_config_decorator def test_breaking2(self, client): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index bfffa59edc3d..17fa6f8fd284 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -533,7 +533,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.key) + client.delete_configuration_setting(changed_flag.feature_id) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -618,7 +618,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.key) + client.delete_configuration_setting(updated_sent_config.feature_id) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -643,7 +643,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_custom(self, client): @@ -668,7 +668,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -716,4 +716,4 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.key) \ No newline at end of file + client.delete_configuration_setting(new_sent.feature_id) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 20a6ddb440bf..6c11191f91cc 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -538,7 +538,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.key) + client.delete_configuration_setting(changed_flag.feature_id) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -624,7 +624,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.key) + client.delete_configuration_setting(updated_sent_config.feature_id) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -649,7 +649,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_custom(self, client): @@ -674,7 +674,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -722,4 +722,4 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.key) \ No newline at end of file + client.delete_configuration_setting(new_sent.feature_id) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 5042ba86a5e0..5595dd7914a2 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -565,7 +565,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.key) + client.delete_configuration_setting(changed_flag.feature_id) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -651,7 +651,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.key) + client.delete_configuration_setting(updated_sent_config.feature_id) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -676,7 +676,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_custom(self, client): @@ -701,7 +701,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -749,7 +749,7 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.key) + client.delete_configuration_setting(new_sent.feature_id) class TestAppConfig(object): @pytest.mark.live_test_only diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index 772facbaa876..a3d970e75ab3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -44,7 +44,10 @@ class AppConfigurationClientTest(AzureTestCase): def _assert_same_keys(self, key1, key2): assert type(key1) == type(key2) - assert key1.key == key2.key + try: + assert key1.key == key2.key + except AttributeError: + assert key1.feature_id == key2.feature_id assert key1.label == key2.label assert key1.content_type == key2.content_type assert key1.tags == key2.tags @@ -101,7 +104,7 @@ def test_update_json_by_value(self, client): set_flag = client.set_configuration_setting(set_flag) assert isinstance(set_flag, FeatureFlagConfigurationSetting) assert set_flag.enabled == False - assert set_flag.key.endswith(key) + assert set_flag.feature_id.endswith(key) @app_config_decorator def test_feature_flag_invalid_json(self, client): @@ -186,4 +189,4 @@ def test_feature_flag_set_enabled(self, client): def test_feature_flag_prefix(self, client): key = self.get_resource_name("key") feature_flag = FeatureFlagConfigurationSetting(key, True) - assert feature_flag.key.startswith(".appconfig.featureflag/") + assert feature_flag.feature_id.startswith(".appconfig.featureflag/") From 42454620dce4d7516f121d0af37948ecdaea7af4 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Jun 2021 15:02:01 -0400 Subject: [PATCH 03/60] fixing up secret reference for consistency --- .../azure/appconfiguration/_models.py | 19 ++++++++++--------- .../tests/test_azure_configuration_client.py | 8 ++++---- .../test_azure_configuration_client_aad.py | 8 ++++---- ...st_azure_configuration_client_aad_async.py | 10 +++++----- .../test_azure_configuration_client_async.py | 10 +++++----- .../tests/test_consistency.py | 2 +- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 1c58d4ddba11..c05e9f5bf1b9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ import json +import six from typing import Dict, Optional, Any, List, Union from msrest.serialization import Model from ._generated.models import KeyValue @@ -270,8 +271,8 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting): :vartype etag: str :ivar key: :vartype key: str - :ivar secret_uri: - :vartype secret_uri: str + :ivar secret_id: + :vartype secret_id: str :param label: :type label: str :param content_type: @@ -301,9 +302,8 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting): ) kind = "SecretReference" - def __init__(self, key, secret_uri, label=None, **kwargs): + def __init__(self, key, secret_id, label=None, **kwargs): # type: (str, str, Optional[str], **Any) -> None - self._secret_uri = secret_uri super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) self.key = key self.label = label @@ -314,16 +314,18 @@ def __init__(self, key, secret_uri, label=None, **kwargs): self.last_modified = kwargs.get("last_modified", None) self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) - self.value = {"secret_uri": self._secret_uri} + self.value = secret_id + if not isinstance(secret_id, dict) and isinstance(secret_id, six.string_types): + self.value = {"secret_uri": secret_id} @property - def secret_uri(self): + def secret_id(self): # type: () -> str self._validate() return self.value['secret_uri'] - @secret_uri.setter - def secret_uri(self, value): + @secret_id.setter + def secret_id(self, value): if self.value is None or isinstance(self.value, dict): if self.value is None: self.value = {} @@ -349,7 +351,6 @@ def _from_generated(cls, key_value): return cls( key=key_value.key, - secret_uri=key_value.value[u"secret_uri"], label=key_value.label, secret_id=key_value.value, last_modified=key_value.last_modified, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index aa441386f981..c1c669220be1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -484,7 +484,7 @@ def _assert_same_keys(self, key1, key2): assert key1.enabled == key2.enabled assert len(key1.filters) == len(key2.filters) elif isinstance(key1, SecretReferenceConfigurationSetting): - assert key1.secret_uri == key2.secret_uri + assert key1.secret_id == key2.secret_id else: assert key1.value == key2.value @@ -565,15 +565,15 @@ def test_config_setting_secret_reference(self, client): assert isinstance(updated_flag, SecretReferenceConfigurationSetting) new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" - updated_flag.secret_uri = new_uri + updated_flag.secret_id = new_uri assert updated_flag.value['secret_uri'] == new_uri updated_flag.value = {'secret_uri': new_uri2} - assert updated_flag.secret_uri == new_uri2 + assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): set_flag.value = "bad_value" - _ = set_flag.secret_uri + _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 17fa6f8fd284..637caaa69f05 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -466,7 +466,7 @@ def _assert_same_keys(self, key1, key2): assert key1.enabled == key2.enabled assert len(key1.filters) == len(key2.filters) elif isinstance(key1, SecretReferenceConfigurationSetting): - assert key1.secret_uri == key2.secret_uri + assert key1.secret_id == key2.secret_id else: assert key1.value == key2.value @@ -548,15 +548,15 @@ def test_config_setting_secret_reference(self, client): assert isinstance(updated_flag, SecretReferenceConfigurationSetting) new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" - updated_flag.secret_uri = new_uri + updated_flag.secret_id = new_uri assert updated_flag.value['secret_uri'] == new_uri updated_flag.value = {'secret_uri': new_uri2} - assert updated_flag.secret_uri == new_uri2 + assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): set_flag.value = "bad_value" - _ = set_flag.secret_uri + _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 6c11191f91cc..8dc98dc2ecfc 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -507,7 +507,7 @@ def _assert_same_keys(self, key1, key2): assert key1.enabled == key2.enabled assert len(key1.filters) == len(key2.filters) elif isinstance(key1, SecretReferenceConfigurationSetting): - assert key1.secret_uri == key2.secret_uri + assert key1.secret_id == key2.secret_id else: assert key1.value == key2.value @@ -547,22 +547,22 @@ def test_config_setting_secret_reference(self, client): set_flag = client.set_configuration_setting(secret_reference) self._assert_same_keys(secret_reference, set_flag) - set_flag.secret_uri = "https://test-test.vault.azure.net/new_secrets/connectionString" + set_flag.secret_id = "https://test-test.vault.azure.net/new_secrets/connectionString" updated_flag = client.set_configuration_setting(set_flag) self._assert_same_keys(set_flag, updated_flag) assert isinstance(updated_flag, SecretReferenceConfigurationSetting) new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" - updated_flag.secret_uri = new_uri + updated_flag.secret_id = new_uri assert updated_flag.value['secret_uri'] == new_uri updated_flag.value = {'secret_uri': new_uri2} - assert updated_flag.secret_uri == new_uri2 + assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): set_flag.value = "bad_value" - _ = set_flag.secret_uri + _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 5595dd7914a2..c53f9a698223 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -534,7 +534,7 @@ def _assert_same_keys(self, key1, key2): assert key1.enabled == key2.enabled assert len(key1.filters) == len(key2.filters) elif isinstance(key1, SecretReferenceConfigurationSetting): - assert key1.secret_uri == key2.secret_uri + assert key1.secret_id == key2.secret_id else: assert key1.value == key2.value @@ -574,22 +574,22 @@ def test_config_setting_secret_reference(self, client): set_flag = client.set_configuration_setting(secret_reference) self._assert_same_keys(secret_reference, set_flag) - set_flag.secret_uri = "https://test-test.vault.azure.net/new_secrets/connectionString" + set_flag.secret_id = "https://test-test.vault.azure.net/new_secrets/connectionString" updated_flag = client.set_configuration_setting(set_flag) self._assert_same_keys(set_flag, updated_flag) assert isinstance(updated_flag, SecretReferenceConfigurationSetting) new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" - updated_flag.secret_uri = new_uri + updated_flag.secret_id = new_uri assert updated_flag.value['secret_uri'] == new_uri updated_flag.value = {'secret_uri': new_uri2} - assert updated_flag.secret_uri == new_uri2 + assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): set_flag.value = "bad_value" - _ = set_flag.secret_uri + _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index a3d970e75ab3..e93c156cb078 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -56,7 +56,7 @@ def _assert_same_keys(self, key1, key2): assert key1.enabled == key2.enabled assert len(key1.filters) == len(key2.filters) elif isinstance(key1, SecretReferenceConfigurationSetting): - assert key1.secret_uri == key2.secret_uri + assert key1.secret_id == key2.secret_id else: assert key1.value == key2.value From 565be7094470de48f9324a74c07f2720d51ebab0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Jun 2021 15:44:57 -0400 Subject: [PATCH 04/60] pylint fix --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index c05e9f5bf1b9..a8ef8fa3a1d3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -3,8 +3,8 @@ # Licensed under the MIT License. # ------------------------------------ import json -import six from typing import Dict, Optional, Any, List, Union +import six from msrest.serialization import Model from ._generated.models import KeyValue From 971ba34cfe2341bda245c6312b8d55afbe62d9fc Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 16:46:48 -0400 Subject: [PATCH 05/60] updates to clients --- .../_azure_appconfiguration_client.py | 38 ++++++------ .../aio/_azure_configuration_client_async.py | 61 +++++++++---------- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 2931b1d52348..8a7a9db888cc 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Optional, Any +from typing import Optional, Any, Union, TYPE_CHECKING from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.pipeline import Pipeline @@ -39,13 +39,9 @@ from ._sync_token import SyncTokenPolicy from ._user_agent import USER_AGENT -try: - from typing import TYPE_CHECKING -except ImportError: - TYPE_CHECKING = False - if TYPE_CHECKING: from azure.core.paging import ItemPaged + from azure.core.credentials import TokenCredential class AzureAppConfigurationClient: @@ -53,7 +49,7 @@ class AzureAppConfigurationClient: :param str base_url: base url of the service :param credential: An object which can provide secrets for the app configuration service - :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` + :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials.TokenCredential` :keyword Pipeline pipeline: If omitted, the standard pipeline is used. :keyword HttpTransport transport: If omitted, the standard pipeline is used. :keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used. @@ -63,7 +59,7 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access def __init__(self, base_url, credential, **kwargs): - # type: (str, Any, **Any) -> None + # type: (str, Union[AppConfigConnectionStringCredential, TokenCredential], **Any) -> None try: if not base_url.lower().startswith("http"): base_url = "https://" + base_url @@ -160,9 +156,8 @@ def _create_appconfig_pipeline( return Pipeline(transport, policies) @distributed_trace - def list_configuration_settings( - self, key_filter=None, label_filter=None, **kwargs - ): # type: (Optional[str], Optional[str], **Any) -> ItemPaged[ConfigurationSetting] + def list_configuration_settings(self, **kwargs): + # type: (**Any) -> ItemPaged[ConfigurationSetting] """List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime @@ -199,6 +194,8 @@ def list_configuration_settings( pass # do something """ select = kwargs.pop("fields", None) + key_filter = kwargs.pop("key_filter", None) + label_filter = kwargs.pop("label_filter", None) if select: select = ["locked" if x == "read_only" else x for x in select] error_map = {401: ClientAuthenticationError} @@ -224,22 +221,17 @@ def list_configuration_settings( def get_configuration_setting( self, key, - label=None, - etag="*", - match_condition=MatchConditions.Unconditionally, **kwargs - ): # type: (str, Optional[str], Optional[str], Optional[MatchConditions], **Any) -> ConfigurationSetting + ): # type: (str, **Any) -> ConfigurationSetting """Get the matched ConfigurationSetting from Azure App Configuration service :param key: key of the ConfigurationSetting :type key: str - :param label: label of the ConfigurationSetting - :type label: str - :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: :class:`~azure.core.MatchConditions` + :keyword str label: label of the ConfigurationSetting + :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag + :keyword match_condition: The match condition to use upon the etag + :paramtype match_condition: :class:`~azure.core.MatchConditions` :keyword datetime accept_datetime: the retrieved ConfigurationSetting that created no later than this datetime :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The matched ConfigurationSetting object @@ -255,6 +247,9 @@ def get_configuration_setting( key="MyKey", label="MyLabel" ) """ + label = kwargs.get("label", None) + etag = kwargs.get("etag", "*") + match_condition = kwargs.get("match_condition", MatchConditions.Unconditionally) error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError} if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError @@ -346,6 +341,7 @@ def set_configuration_setting( :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header + :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index aea69c1c5db5..a7d5821bfc15 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -4,9 +4,10 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Dict, Any, Optional +from typing import Dict, Any, Optional, Union from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions +from azure.core.async_paging import AsyncItemPaged from azure.core.pipeline import AsyncPipeline from azure.core.pipeline.policies import ( UserAgentPolicy, @@ -47,7 +48,7 @@ TYPE_CHECKING = False if TYPE_CHECKING: - from azure.core.async_paging import AsyncItemPaged + from azure.core.credentials_async import AsyncTokenCredential class AzureAppConfigurationClient: @@ -55,7 +56,7 @@ class AzureAppConfigurationClient: :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.AppConfigConnectionStringCredential + :type credential: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials_async.AsyncTokenCredential` :keyword Pipeline pipeline: If omitted, the standard pipeline is used. :keyword HttpTransport transport: If omitted, the standard pipeline is used. :keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used. @@ -66,8 +67,7 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access - def __init__(self, base_url, credential, **kwargs): - # type: (str, Any, **Any) -> None + def __init__(self, base_url: str, credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], **kwargs: Any) -> None: try: if not base_url.lower().startswith("http"): base_url = "https://" + base_url @@ -103,8 +103,7 @@ def __init__(self, base_url, credential, **kwargs): ) @classmethod - def from_connection_string(cls, connection_string, **kwargs): - # type: (str, **Any) -> AzureAppConfigurationClient + 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` @@ -171,8 +170,7 @@ def _create_appconfig_pipeline( ) @distributed_trace - def list_configuration_settings(self, key_filter=None, label_filter=None, **kwargs): - # type: (Optional[str], Optional[str], **Any) -> AsyncItemPaged[ConfigurationSetting] + def list_configuration_settings(self, *, key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged[ConfigurationSetting]: """List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime @@ -233,14 +231,13 @@ def list_configuration_settings(self, key_filter=None, label_filter=None, **kwar @distributed_trace_async async def get_configuration_setting( self, - key, - label=None, - etag="*", - match_condition=MatchConditions.Unconditionally, - **kwargs - ): - # type: (str, Optional[str], Optional[str], Optional[MatchConditions], **Any) -> ConfigurationSetting - + key: str, + *, + label: Optional[str] = None, + etag: Optional[str] = "*", + match_condition: Optional[MatchConditions]=MatchConditions.Unconditionally, + **kwargs: Any + ) -> ConfigurationSetting: """Get the matched ConfigurationSetting from Azure App Configuration service :param key: key of the ConfigurationSetting @@ -296,13 +293,12 @@ async def get_configuration_setting( raise binascii.Error("Connection string secret has incorrect padding") @distributed_trace_async - async def add_configuration_setting(self, configuration_setting, **kwargs): - # type: (ConfigurationSetting, **Any) -> ConfigurationSetting + 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: :class:`ConfigurationSetting` + :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The ConfigurationSetting object returned from the App Configuration service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` @@ -345,10 +341,9 @@ async def add_configuration_setting(self, configuration_setting, **kwargs): @distributed_trace_async async def set_configuration_setting( self, - configuration_setting, - match_condition=MatchConditions.Unconditionally, - **kwargs - ): # type: (ConfigurationSetting, Optional[MatchConditions], **Any) -> ConfigurationSetting + configuration_setting: ConfigurationSetting, + **kwargs: Any + ) -> ConfigurationSetting: """Add or update a ConfigurationSetting. If the configuration setting identified by key and label does not exist, this is a create. @@ -360,6 +355,7 @@ async def set_configuration_setting( :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header + :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ @@ -380,6 +376,9 @@ async def set_configuration_setting( ) returned_config_setting = await async_client.set_configuration_setting(config_setting) """ + etag = kwargs.get("etag", configuration_setting.etag) + match_condition = kwargs.get("match_condition", MatchConditions.Unconditionally) + key_value = configuration_setting._to_generated() custom_headers = CaseInsensitiveDict(kwargs.get("headers")) error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} @@ -399,7 +398,7 @@ async def set_configuration_setting( label=key_value.label, if_match=prep_if_match(configuration_setting.etag, match_condition), if_none_match=prep_if_none_match( - configuration_setting.etag, match_condition + etag, match_condition ), headers=custom_headers, error_map=error_map, @@ -413,8 +412,8 @@ async def set_configuration_setting( @distributed_trace_async async def delete_configuration_setting( - self, key, label=None, **kwargs - ): # type: (str, Optional[str], **Any) -> ConfigurationSetting + self, key: str, label: Optional[str] = None, **kwargs: Any + ) -> ConfigurationSetting: """Delete a ConfigurationSetting if it exists @@ -472,8 +471,8 @@ async def delete_configuration_setting( @distributed_trace def list_revisions( - self, key_filter=None, label_filter=None, **kwargs - ): # type: (Optional[str], Optional[str], **Any) -> AsyncItemPaged[ConfigurationSetting] + self, key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged[ConfigurationSetting]: """ Find the ConfigurationSetting revision history. @@ -534,8 +533,8 @@ def list_revisions( @distributed_trace async def set_read_only( - self, configuration_setting, read_only=True, **kwargs - ): # type: (ConfigurationSetting, Optional[bool], **Any) -> ConfigurationSetting + self, configuration_setting: ConfigurationSetting, read_only: Optional[bool] = True, **kwargs: Any + ) -> ConfigurationSetting: """Set a configuration setting read only From 89184a95e611d9c177149996443fd6155be89a90 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 16:52:26 -0400 Subject: [PATCH 06/60] fixing tests --- .../appconfiguration/_azure_appconfiguration_client.py | 6 +++--- .../tests/test_azure_configuration_client.py | 4 ++-- .../tests/test_azure_configuration_client_aad.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 8a7a9db888cc..9d658f3f4b57 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -247,9 +247,9 @@ def get_configuration_setting( key="MyKey", label="MyLabel" ) """ - label = kwargs.get("label", None) - etag = kwargs.get("etag", "*") - match_condition = kwargs.get("match_condition", MatchConditions.Unconditionally) + label = kwargs.pop("label", None) + etag = kwargs.pop("etag", "*") + match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError} if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index c1c669220be1..500bb6aa62ba 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -213,7 +213,7 @@ def test_get_configuration_setting_no_label(self, client, appconfiguration_conne def test_get_configuration_setting_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): compare_kv = test_config_setting fetched_kv = client.get_configuration_setting( - compare_kv.key, compare_kv.label + compare_kv.key, label=compare_kv.label ) assert ( fetched_kv.key == compare_kv.key @@ -228,7 +228,7 @@ def test_get_non_existing_configuration_setting(self, client, appconfiguration_c compare_kv = test_config_setting with pytest.raises(ResourceNotFoundError): client.get_configuration_setting( - compare_kv.key, compare_kv.label + "a" + compare_kv.key, label=compare_kv.label + "a" ) # method: delete_configuration_setting diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 637caaa69f05..b3d7ef5dfb11 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -173,7 +173,7 @@ def test_get_configuration_setting_label(self, appconfiguration_endpoint_string, client = self.create_aad_client(appconfiguration_endpoint_string) compare_kv = test_config_setting fetched_kv = client.get_configuration_setting( - compare_kv.key, compare_kv.label + compare_kv.key, label=compare_kv.label ) assert ( fetched_kv.key == compare_kv.key @@ -189,7 +189,7 @@ def test_get_non_existing_configuration_setting(self, appconfiguration_endpoint_ compare_kv = test_config_setting with pytest.raises(ResourceNotFoundError): client.get_configuration_setting( - compare_kv.key, compare_kv.label + "a" + compare_kv.key, label=compare_kv.label + "a" ) # method: delete_configuration_setting From 5679d8dc7c53970250cacbc9bfbca8cb1bc65bf3 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 17:08:53 -0400 Subject: [PATCH 07/60] updates to clients --- .../azure/appconfiguration/_azure_appconfiguration_client.py | 3 --- .../appconfiguration/aio/_azure_configuration_client_async.py | 3 --- 2 files changed, 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 9d658f3f4b57..4af5bce2c6be 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -50,9 +50,6 @@ class AzureAppConfigurationClient: :param str base_url: base url of the service :param credential: An object which can provide secrets for the app configuration service :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials.TokenCredential` - :keyword Pipeline pipeline: If omitted, the standard pipeline is used. - :keyword HttpTransport transport: If omitted, the standard pipeline is used. - :keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used. """ diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index a7d5821bfc15..9d4d6bb8c34b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -57,9 +57,6 @@ class AzureAppConfigurationClient: :param str base_url: base url of the service :param credential: An object which can provide secrets for the app configuration service :type credential: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials_async.AsyncTokenCredential` - :keyword Pipeline pipeline: If omitted, the standard pipeline is used. - :keyword HttpTransport transport: If omitted, the standard pipeline is used. - :keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used. This is the async version of :class:`azure.appconfiguration.AzureAppConfigurationClient` From 8f60ae50b611a414a6299f7caeea2cfe08b96137 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 17:12:46 -0400 Subject: [PATCH 08/60] changing base_url -> endpoint --- .../azure-appconfiguration/README.md | 2 +- .../_azure_appconfiguration_client.py | 24 +++++++++---------- .../_generated/_azure_app_configuration.py | 4 ++-- .../aio/_azure_app_configuration.py | 4 ++-- .../aio/_azure_configuration_client_async.py | 24 +++++++++---------- .../test_azure_configuration_client_aad.py | 4 ++-- ...st_azure_configuration_client_aad_async.py | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/README.md b/sdk/appconfiguration/azure-appconfiguration/README.md index bd245cdb0540..76a574988c05 100644 --- a/sdk/appconfiguration/azure-appconfiguration/README.md +++ b/sdk/appconfiguration/azure-appconfiguration/README.md @@ -115,7 +115,7 @@ from azure.appconfiguration import AzureAppConfigurationClient credential = DefaultAzureCredential() -client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential) +client = AzureAppConfigurationClient(endpoint="your_endpoint_url", credential=credential) ``` ## Key concepts diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 6aedb01278f0..fbb81a3631db 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -47,7 +47,7 @@ class AzureAppConfigurationClient: """Represents an client that calls restful API of Azure App Configuration service. - :param str base_url: base url of the service + :param str endpoint: base url of the service :param credential: An object which can provide secrets for the app configuration service :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials.TokenCredential` @@ -55,21 +55,21 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access - def __init__(self, base_url, credential, **kwargs): + def __init__(self, endpoint, credential, **kwargs): # type: (str, Union[AppConfigConnectionStringCredential, TokenCredential], **Any) -> None try: - if not base_url.lower().startswith("http"): - base_url = "https://" + base_url + if not endpoint.lower().startswith("http"): + endpoint = "https://" + endpoint except AttributeError: raise ValueError("Base URL must be a string.") if not credential: raise ValueError("Missing credential") - self._credential_scopes = base_url.strip("/") + "/.default" + self._credential_scopes = endpoint.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, **kwargs + credential, endpoint, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -82,11 +82,11 @@ def __init__(self, base_url, credential, **kwargs): self._sync_token_policy = SyncTokenPolicy() aad_mode = not isinstance(credential, AppConfigConnectionStringCredential) pipeline = self._create_appconfig_pipeline( - credential=credential, aad_mode=aad_mode, base_url=base_url, **kwargs + credential=credential, aad_mode=aad_mode, endpoint=endpoint, **kwargs ) self._impl = AzureAppConfiguration( - credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes + credential, endpoint, pipeline=pipeline, credential_scopes=self._credential_scopes ) @classmethod @@ -108,22 +108,22 @@ def from_connection_string(cls, connection_string, **kwargs): connection_str = "" client = AzureAppConfigurationClient.from_connection_string(connection_str) """ - base_url = "https://" + get_endpoint_from_connection_string(connection_string) + endpoint = "https://" + get_endpoint_from_connection_string(connection_string) return cls( credential=AppConfigConnectionStringCredential(connection_string), - base_url=base_url, + endpoint=endpoint, **kwargs ) def _create_appconfig_pipeline( - self, credential, base_url=None, aad_mode=False, **kwargs + self, credential, endpoint=None, aad_mode=False, **kwargs ): transport = kwargs.get("transport") policies = kwargs.get("policies") if policies is None: # [] is a valid policy list if aad_mode: - scope = base_url.strip("/") + "/.default" + scope = endpoint.strip("/") + "/.default" if hasattr(credential, "get_token"): credential_policy = BearerTokenCredentialPolicy(credential, scope) else: diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py index 6df47ca6ad0e..224167d91a90 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py @@ -42,9 +42,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None - base_url = '{endpoint}' + endpoint = '{endpoint}' self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client = PipelineClient(endpoint=endpoint, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py index eb52b6077a51..dd9098af7c1f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py @@ -39,9 +39,9 @@ def __init__( sync_token: Optional[str] = None, **kwargs: Any ) -> None: - base_url = '{endpoint}' + endpoint = '{endpoint}' self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client = AsyncPipelineClient(endpoint=endpoint, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 3ca619d69101..99fc4ad8ee5a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -48,7 +48,7 @@ class AzureAppConfigurationClient: """Represents an client that calls restful API of Azure App Configuration service. - :param str base_url: base url of the service + :param str endpoint: base url of the service :param credential: An object which can provide secrets for the app configuration service :type credential: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials_async.AsyncTokenCredential` @@ -58,20 +58,20 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access - def __init__(self, base_url: str, credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], **kwargs: Any) -> None: + def __init__(self, endpoint: str, credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], **kwargs: Any) -> None: try: - if not base_url.lower().startswith("http"): - base_url = "https://" + base_url + if not endpoint.lower().startswith("http"): + endpoint = "https://" + endpoint except AttributeError: raise ValueError("Base URL must be a string.") if not credential: raise ValueError("Missing credential") - self._credential_scopes = base_url.strip("/") + "/.default" + self._credential_scopes = endpoint.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, **kwargs + credential, endpoint, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -84,11 +84,11 @@ def __init__(self, base_url: str, credential: Union[AppConfigConnectionStringCre self._sync_token_policy = SyncTokenPolicy() aad_mode = not isinstance(credential, AppConfigConnectionStringCredential) pipeline = self._create_appconfig_pipeline( - credential=credential, aad_mode=aad_mode, base_url=base_url, **kwargs + credential=credential, aad_mode=aad_mode, endpoint=endpoint, **kwargs ) self._impl = AzureAppConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, pipeline=pipeline + credential, endpoint, credential_scopes=self._credential_scopes, pipeline=pipeline ) @classmethod @@ -110,22 +110,22 @@ def from_connection_string(cls, connection_string: str, **kwargs: Any) -> "Azure connection_str = "" async_client = AzureAppConfigurationClient.from_connection_string(connection_str) """ - base_url = "https://" + get_endpoint_from_connection_string(connection_string) + endpoint = "https://" + get_endpoint_from_connection_string(connection_string) return cls( credential=AppConfigConnectionStringCredential(connection_string), - base_url=base_url, + endpoint=endpoint, **kwargs ) def _create_appconfig_pipeline( - self, credential, base_url=None, aad_mode=False, **kwargs + self, credential, endpoint=None, aad_mode=False, **kwargs ): transport = kwargs.get("transport") policies = kwargs.get("policies") if policies is None: # [] is a valid policy list if aad_mode: - scope = base_url.strip("/") + "/.default" + scope = endpoint.strip("/") + "/.default" if hasattr(credential, "get_token"): credential_policy = AsyncBearerTokenCredentialPolicy( credential, scope diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index b3d7ef5dfb11..4d1fb639a3b1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -51,9 +51,9 @@ def _delete_setting(self, client, item): key=item.key, label=item.label ) - def create_aad_client(self, base_url): + def create_aad_client(self, endpoint): cred = self.get_credential(AzureAppConfigurationClient) - return AzureAppConfigurationClient(base_url, cred) + return AzureAppConfigurationClient(endpoint, cred) # method: add_configuration_setting @app_config_decorator diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 8dc98dc2ecfc..7405f60b641c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -53,9 +53,9 @@ def _delete_setting(self, client, item): key=item.key, label=item.label ) - def create_aad_client(self, base_url): + def create_aad_client(self, endpoint): cred = self.get_credential(AzureAppConfigurationClient, is_async=True) - client = AzureAppConfigurationClient(base_url, cred) + client = AzureAppConfigurationClient(endpoint, cred) return AzureAppConfigurationClientProxy(client) # method: add_configuration_setting From 2d3cd140b01111cd35b0daa5bb5c6285c94a6fe4 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 17:15:33 -0400 Subject: [PATCH 09/60] undoing changes to generated --- .../appconfiguration/_generated/_azure_app_configuration.py | 4 ++-- .../_generated/aio/_azure_app_configuration.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py index 224167d91a90..6df47ca6ad0e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py @@ -42,9 +42,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None - endpoint = '{endpoint}' + base_url = '{endpoint}' self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) - self._client = PipelineClient(endpoint=endpoint, config=self._config, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py index dd9098af7c1f..eb52b6077a51 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/aio/_azure_app_configuration.py @@ -39,9 +39,9 @@ def __init__( sync_token: Optional[str] = None, **kwargs: Any ) -> None: - endpoint = '{endpoint}' + base_url = '{endpoint}' self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) - self._client = AsyncPipelineClient(endpoint=endpoint, config=self._config, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) From b9d01c88e6581ac2e84c5f3a0a4e1db98dc38047 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 17:39:35 -0400 Subject: [PATCH 10/60] adding changelog --- sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md | 9 +++++++++ .../azure/appconfiguration/_models.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index d3f8b0b51449..04ed7a3d3b86 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -1,7 +1,16 @@ # Release History ## 1.2.0b3 (Unreleased) +### Features Added +### Breaking Changes +* renamed `base_url` to endpoint in `AzureAppConfigurationClient` +* `key_filter` and `label_filter` are keyword arguments in `list_configuration_settings` +* `label`, `etag`, and `match_condition` are now keyword arguments in `get_configuration_settings` + +### Key Bugs Fixed + +### Fixed ## 1.2.0b2 (2021-06-08) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 45b9525c452e..e430bdc36f6a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -320,7 +320,7 @@ def __init__(self, key, secret_id, label=None, **kwargs): self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) self.value = secret_id - if not isinstance(secret_id, dict) and isinstance(secret_id, six.string_types): + if not isinstance(secret_id, dict): self.value = {"secret_uri": secret_id} @property From 4371f0f1f114df501c345b8dddd791004e4c8d0d Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 18:08:54 -0400 Subject: [PATCH 11/60] updating changelog, enabled is kwarg --- .../azure-appconfiguration/CHANGELOG.md | 1 + .../azure/appconfiguration/_models.py | 7 +++-- .../tests/test_azure_configuration_client.py | 31 ++++++++----------- .../test_azure_configuration_client_aad.py | 10 +++--- ...st_azure_configuration_client_aad_async.py | 10 +++--- .../test_azure_configuration_client_async.py | 16 +++++----- .../tests/test_consistency.py | 14 ++++----- 7 files changed, 44 insertions(+), 45 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index 04ed7a3d3b86..d76824d6b639 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -7,6 +7,7 @@ * renamed `base_url` to endpoint in `AzureAppConfigurationClient` * `key_filter` and `label_filter` are keyword arguments in `list_configuration_settings` * `label`, `etag`, and `match_condition` are now keyword arguments in `get_configuration_settings` +* `enabled` parameter in `FeatureFlagConfigurationSetting` is now a keyword argument ### Key Bugs Fixed diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index e430bdc36f6a..61f3d23fde76 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -159,7 +159,7 @@ class FeatureFlagConfigurationSetting( ) kind = "FeatureFlag" - def __init__(self, feature_id, enabled, filters=[], **kwargs): # pylint: disable=dangerous-default-value + def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangerous-default-value # type: (str, bool, Optional[List[Dict[str, Any]]], **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) if not feature_id.startswith(self.key_prefix): @@ -173,7 +173,10 @@ def __init__(self, feature_id, enabled, filters=[], **kwargs): # pylint: disabl self.etag = kwargs.get("etag", None) self.description = kwargs.get("description", None) self.display_name = kwargs.get("display_name", None) - self.value = kwargs.get("value", {"enabled": enabled, "conditions": {"client_filters": filters}}) + if "enabled" in kwargs.keys(): + self.value = kwargs.get("value", {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": filters}}) + else: + self.value = kwargs.get("value", {"conditions": {"client_filters": filters}}) def _validate(self): # type: () -> None diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 500bb6aa62ba..770c74e02020 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -44,11 +44,6 @@ import functools from uuid import uuid4 -try: - from unittest import mock -except ImportError: - import mock - class AppConfigurationClientTest(AzureTestCase): def __init__(self, method_name): @@ -526,7 +521,7 @@ def test_sync_tokens(self, client): @app_config_decorator def test_config_setting_feature_flag(self, client): - feature_flag = FeatureFlagConfigurationSetting("test_feature", True) + feature_flag = FeatureFlagConfigurationSetting("test_feature", enabled=True) set_flag = client.set_configuration_setting(feature_flag) self._assert_same_keys(feature_flag, set_flag) @@ -581,7 +576,7 @@ def test_config_setting_secret_reference(self, client): def test_feature_filter_targeting(self, client): new = FeatureFlagConfigurationSetting( "newflag", - True, + enabled=True, filters=[ { "name": TARGETING, @@ -641,7 +636,7 @@ def test_feature_filter_targeting(self, client): def test_feature_filter_time_window(self, client): new = FeatureFlagConfigurationSetting( 'time_window', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -666,7 +661,7 @@ def test_feature_filter_time_window(self, client): def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -691,7 +686,7 @@ def test_feature_filter_custom(self, client): def test_feature_filter_multiple(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -739,7 +734,7 @@ def test_feature_filter_multiple(self, client): def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking1', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -755,7 +750,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking2', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -772,7 +767,7 @@ def test_breaking1(self, client): # This will show up as a Custom filter new = FeatureFlagConfigurationSetting( 'breaking3', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -788,7 +783,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking4', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -801,7 +796,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking5', - True, + enabled=True, filters=[ { "name": TARGETING, @@ -818,7 +813,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking6', - True, + enabled=True, filters=[ { "name": TARGETING, @@ -831,7 +826,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking7', - True, + enabled=True, filters=[ { 'abc': 'def' @@ -843,7 +838,7 @@ def test_breaking1(self, client): new = FeatureFlagConfigurationSetting( 'breaking8', - True, + enabled=True, filters=[ { 'abc': 'def' diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 4d1fb639a3b1..940f9a02b6fd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -508,7 +508,7 @@ def test_sync_tokens(self, client): @app_config_decorator def test_config_setting_feature_flag(self, client): - feature_flag = FeatureFlagConfigurationSetting("test_feature", True) + feature_flag = FeatureFlagConfigurationSetting("test_feature", enabled=True) set_flag = client.set_configuration_setting(feature_flag) self._assert_same_keys(feature_flag, set_flag) @@ -564,7 +564,7 @@ def test_config_setting_secret_reference(self, client): def test_feature_filter_targeting(self, client): new = FeatureFlagConfigurationSetting( "newflag", - True, + enabled=True, filters=[ { "name": TARGETING, @@ -624,7 +624,7 @@ def test_feature_filter_targeting(self, client): def test_feature_filter_time_window(self, client): new = FeatureFlagConfigurationSetting( 'time_window', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -649,7 +649,7 @@ def test_feature_filter_time_window(self, client): def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -674,7 +674,7 @@ def test_feature_filter_custom(self, client): def test_feature_filter_multiple(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 7405f60b641c..7f8924717669 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -513,7 +513,7 @@ def _assert_same_keys(self, key1, key2): @app_config_decorator def test_config_setting_feature_flag(self, client): - feature_flag = FeatureFlagConfigurationSetting("test_feature", True) + feature_flag = FeatureFlagConfigurationSetting("test_feature", enabled=True) set_flag = client.set_configuration_setting(feature_flag) self._assert_same_keys(feature_flag, set_flag) @@ -570,7 +570,7 @@ def test_config_setting_secret_reference(self, client): def test_feature_filter_targeting(self, client): new = FeatureFlagConfigurationSetting( "newflag", - True, + enabled=True, filters=[ { "name": TARGETING, @@ -630,7 +630,7 @@ def test_feature_filter_targeting(self, client): def test_feature_filter_time_window(self, client): new = FeatureFlagConfigurationSetting( 'time_window', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -655,7 +655,7 @@ def test_feature_filter_time_window(self, client): def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -680,7 +680,7 @@ def test_feature_filter_custom(self, client): def test_feature_filter_multiple(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index c53f9a698223..01df042b15fa 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -462,7 +462,7 @@ def test_sync_tokens(self, client): def test_sync_tokens(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters = [ { "name": "Microsoft.Percentage", @@ -481,7 +481,7 @@ def test_sync_tokens(self, client): new = FeatureFlagConfigurationSetting( 'time_window', - True, + enabled=True, filters = [ { u"name": TIME_WINDOW, @@ -500,7 +500,7 @@ def test_sync_tokens(self, client): new = FeatureFlagConfigurationSetting( "newflag", - True, + enabled=True, filters=[ { "name": TARGETING, @@ -540,7 +540,7 @@ def _assert_same_keys(self, key1, key2): @app_config_decorator def test_config_setting_feature_flag(self, client): - feature_flag = FeatureFlagConfigurationSetting("test_feature", True) + feature_flag = FeatureFlagConfigurationSetting("test_feature", enabled=True) set_flag = client.set_configuration_setting(feature_flag) self._assert_same_keys(feature_flag, set_flag) @@ -597,7 +597,7 @@ def test_config_setting_secret_reference(self, client): def test_feature_filter_targeting(self, client): new = FeatureFlagConfigurationSetting( "newflag", - True, + enabled=True, filters=[ { "name": TARGETING, @@ -657,7 +657,7 @@ def test_feature_filter_targeting(self, client): def test_feature_filter_time_window(self, client): new = FeatureFlagConfigurationSetting( 'time_window', - True, + enabled=True, filters=[ { "name": TIME_WINDOW, @@ -682,7 +682,7 @@ def test_feature_filter_time_window(self, client): def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -707,7 +707,7 @@ def test_feature_filter_custom(self, client): def test_feature_filter_multiple(self, client): new = FeatureFlagConfigurationSetting( 'custom', - True, + enabled=True, filters=[ { "name": PERCENTAGE, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index e93c156cb078..ac03208c1f33 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -65,7 +65,7 @@ def test_update_json_by_value(self, client): key = self.get_resource_name("key") feature_flag = FeatureFlagConfigurationSetting( key, - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -109,7 +109,7 @@ def test_update_json_by_value(self, client): @app_config_decorator def test_feature_flag_invalid_json(self, client): key = self.get_resource_name("key") - feature_flag = FeatureFlagConfigurationSetting(key, True) + feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) set_flag = client.set_configuration_setting(feature_flag) set_flag.value = [] @@ -120,7 +120,7 @@ def test_feature_flag_invalid_json(self, client): @app_config_decorator def test_feature_flag_invalid_json_string(self, client): key = self.get_resource_name("key") - feature_flag = FeatureFlagConfigurationSetting(key, True) + feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) set_flag = client.set_configuration_setting(feature_flag) set_flag.value = "hello world" @@ -131,7 +131,7 @@ def test_feature_flag_invalid_json_string(self, client): @app_config_decorator def test_feature_flag_invalid_json_access_properties(self, client): key = self.get_resource_name("key") - feature_flag = FeatureFlagConfigurationSetting(key, True) + feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) set_flag = client.set_configuration_setting(feature_flag) set_flag.value = "hello world" @@ -145,7 +145,7 @@ def test_feature_flag_set_value(self, client): key = self.get_resource_name("key") feature_flag = FeatureFlagConfigurationSetting( key, - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -170,7 +170,7 @@ def test_feature_flag_set_enabled(self, client): key = self.get_resource_name("key") feature_flag = FeatureFlagConfigurationSetting( key, - True, + enabled=True, filters=[ { "name": PERCENTAGE, @@ -188,5 +188,5 @@ def test_feature_flag_set_enabled(self, client): @app_config_decorator def test_feature_flag_prefix(self, client): key = self.get_resource_name("key") - feature_flag = FeatureFlagConfigurationSetting(key, True) + feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) assert feature_flag.feature_id.startswith(".appconfig.featureflag/") From 375481e5846ac89ea5a185f986b76095b146d62e Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 21 Jun 2021 18:32:22 -0400 Subject: [PATCH 12/60] lint fixes --- .../azure/appconfiguration/_azure_appconfiguration_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index fbb81a3631db..6ca3d73aceab 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -214,7 +214,7 @@ def list_configuration_settings(self, **kwargs): @distributed_trace def get_configuration_setting(self, key, **kwargs): - # type: (...) -> Union[None, ConfigurationSetting] + # type: (str, **Any) -> Union[None, ConfigurationSetting] """Get the matched ConfigurationSetting from Azure App Configuration service From b791000a710ffa266705742590210895cfb5c77d Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 10:46:42 -0400 Subject: [PATCH 13/60] formatting --- .../azure/appconfiguration/_models.py | 6 +++-- .../aio/_azure_configuration_client_async.py | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 61f3d23fde76..83375cfe4c00 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -4,7 +4,6 @@ # ------------------------------------ import json from typing import Dict, Optional, Any, List, Union -import six from msrest.serialization import Model from ._generated.models import KeyValue @@ -174,7 +173,10 @@ def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangero self.description = kwargs.get("description", None) self.display_name = kwargs.get("display_name", None) if "enabled" in kwargs.keys(): - self.value = kwargs.get("value", {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": filters}}) + self.value = kwargs.get( + "value", + {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": filters}} + ) else: self.value = kwargs.get("value", {"conditions": {"client_filters": filters}}) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 99fc4ad8ee5a..2ab2cb261c5b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -50,7 +50,8 @@ class AzureAppConfigurationClient: :param str endpoint: base url of the service :param credential: An object which can provide secrets for the app configuration service - :type credential: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials_async.AsyncTokenCredential` + :type credential: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or + :class:`~azure.core.credentials_async.AsyncTokenCredential` This is the async version of :class:`azure.appconfiguration.AzureAppConfigurationClient` @@ -58,7 +59,12 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access - def __init__(self, endpoint: str, credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], **kwargs: Any) -> None: + def __init__( + self, + endpoint: str, + credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], + **kwargs: Any + ) -> None: try: if not endpoint.lower().startswith("http"): endpoint = "https://" + endpoint @@ -159,7 +165,13 @@ def _create_appconfig_pipeline( ) @distributed_trace - def list_configuration_settings(self, *, key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged[ConfigurationSetting]: + def list_configuration_settings( + self, + *, + key_filter: Optional[str] = None, + label_filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged[ConfigurationSetting]: """List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime @@ -283,7 +295,11 @@ async def get_configuration_setting( raise binascii.Error("Connection string secret has incorrect padding") @distributed_trace_async - async def add_configuration_setting(self, configuration_setting: ConfigurationSetting, **kwargs: Any) -> ConfigurationSetting: + async def add_configuration_setting( + self, + configuration_setting: ConfigurationSetting, + **kwargs: Any + ) -> ConfigurationSetting: """Add a ConfigurationSetting instance into the Azure App Configuration service. From 84939ed8f65fd4b4408a2c321c5c4d5b4484c942 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 10:55:48 -0400 Subject: [PATCH 14/60] using key instead of feature_id --- .../azure/appconfiguration/_models.py | 7 ++--- .../tests/test_azure_configuration_client.py | 26 +++++++++---------- .../test_azure_configuration_client_aad.py | 10 +++---- ...st_azure_configuration_client_aad_async.py | 10 +++---- .../test_azure_configuration_client_async.py | 10 +++---- .../tests/test_consistency.py | 6 ++--- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 83375cfe4c00..9e230858f50c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -164,6 +164,7 @@ def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangero if not feature_id.startswith(self.key_prefix): feature_id = self.key_prefix + feature_id self.feature_id = feature_id + self.key = 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) @@ -182,7 +183,7 @@ def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangero def _validate(self): # type: () -> None - if not self.feature_id.startswith(self.key_prefix): + if not self.key.startswith(self.key_prefix): raise ValueError("All FeatureFlagConfigurationSettings should be prefixed with {}.".format(self.key_prefix)) if not (self.value is None or isinstance(self.value, dict)): raise ValueError("Expect 'value' to be a dictionary.") @@ -261,9 +262,9 @@ def _to_generated(self): # type: () -> KeyValue return KeyValue( - key=self.feature_id, + key=self.key, label=self.label, - value=json.dumps(self.value), # NOTE: This has to be added for valid json + value=json.dumps(self.value), content_type=self.content_type, last_modified=self.last_modified, tags=self.tags, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 770c74e02020..bc76c7d1d7dd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -545,7 +545,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.feature_id) + client.delete_configuration_setting(changed_flag.key) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -630,7 +630,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.feature_id) + client.delete_configuration_setting(updated_sent_config.key) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -655,7 +655,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_custom(self, client): @@ -680,7 +680,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -728,7 +728,7 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_breaking1(self, client): @@ -746,7 +746,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking2', @@ -762,7 +762,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) # This will show up as a Custom filter new = FeatureFlagConfigurationSetting( @@ -779,7 +779,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking4', @@ -792,7 +792,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking5', @@ -809,7 +809,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking6', @@ -822,7 +822,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking7', @@ -834,7 +834,7 @@ def test_breaking1(self, client): ] ) client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) new = FeatureFlagConfigurationSetting( 'breaking8', @@ -847,7 +847,7 @@ def test_breaking1(self, client): ) new.feature_flag_content_type = "fakeyfakey" client.set_configuration_setting(new) - new1 = client.get_configuration_setting(new.feature_id) + new1 = client.get_configuration_setting(new.key) @app_config_decorator def test_breaking2(self, client): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 940f9a02b6fd..d363b357d987 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -533,7 +533,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.feature_id) + client.delete_configuration_setting(changed_flag.key) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -618,7 +618,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.feature_id) + client.delete_configuration_setting(updated_sent_config.key) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -643,7 +643,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_custom(self, client): @@ -668,7 +668,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -716,4 +716,4 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.feature_id) \ No newline at end of file + client.delete_configuration_setting(new_sent.key) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 7f8924717669..1906282d9c60 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -538,7 +538,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.feature_id) + client.delete_configuration_setting(changed_flag.key) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -624,7 +624,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.feature_id) + client.delete_configuration_setting(updated_sent_config.key) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -649,7 +649,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_custom(self, client): @@ -674,7 +674,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -722,4 +722,4 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.feature_id) \ No newline at end of file + client.delete_configuration_setting(new_sent.key) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 01df042b15fa..5334b1626e65 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -565,7 +565,7 @@ def test_config_setting_feature_flag(self, client): set_flag.value = "bad_value" _ = set_flag.enabled - client.delete_configuration_setting(changed_flag.feature_id) + client.delete_configuration_setting(changed_flag.key) @app_config_decorator def test_config_setting_secret_reference(self, client): @@ -651,7 +651,7 @@ def test_feature_filter_targeting(self, client): self._assert_same_keys(sent_config, updated_sent_config) assert len(sent_config.filters) == 3 - client.delete_configuration_setting(updated_sent_config.feature_id) + client.delete_configuration_setting(updated_sent_config.key) @app_config_decorator def test_feature_filter_time_window(self, client): @@ -676,7 +676,7 @@ def test_feature_filter_time_window(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_custom(self, client): @@ -701,7 +701,7 @@ def test_feature_filter_custom(self, client): new_sent = client.set_configuration_setting(sent) self._assert_same_keys(sent, new_sent) - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) @app_config_decorator def test_feature_filter_multiple(self, client): @@ -749,7 +749,7 @@ def test_feature_filter_multiple(self, client): assert new_sent.filters[1]["parameters"]["Start"] == "Wed, 10 Mar 2021 08:00:00 GMT" assert new_sent.filters[2]["parameters"]["Audience"]["DefaultRolloutPercentage"] == 100 - client.delete_configuration_setting(new_sent.feature_id) + client.delete_configuration_setting(new_sent.key) class TestAppConfig(object): @pytest.mark.live_test_only diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index ac03208c1f33..2dc2bb593821 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -47,7 +47,7 @@ def _assert_same_keys(self, key1, key2): try: assert key1.key == key2.key except AttributeError: - assert key1.feature_id == key2.feature_id + assert key1.key == key2.key assert key1.label == key2.label assert key1.content_type == key2.content_type assert key1.tags == key2.tags @@ -104,7 +104,7 @@ def test_update_json_by_value(self, client): set_flag = client.set_configuration_setting(set_flag) assert isinstance(set_flag, FeatureFlagConfigurationSetting) assert set_flag.enabled == False - assert set_flag.feature_id.endswith(key) + assert set_flag.key.endswith(key) @app_config_decorator def test_feature_flag_invalid_json(self, client): @@ -189,4 +189,4 @@ def test_feature_flag_set_enabled(self, client): def test_feature_flag_prefix(self, client): key = self.get_resource_name("key") feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) - assert feature_flag.feature_id.startswith(".appconfig.featureflag/") + assert feature_flag.key.startswith(".appconfig.featureflag/") From 8a01a166069ba6748982b113962e32bceb055486 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 10:58:43 -0400 Subject: [PATCH 15/60] feature_id strips key prefix --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 9e230858f50c..2636fc057da4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -161,9 +161,9 @@ class FeatureFlagConfigurationSetting( def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangerous-default-value # type: (str, bool, Optional[List[Dict[str, Any]]], **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) + self.feature_id = feature_id.lstrip(self.key_prefix) if not feature_id.startswith(self.key_prefix): feature_id = self.key_prefix + feature_id - self.feature_id = feature_id self.key = feature_id self.label = kwargs.get("label", None) self.content_type = kwargs.get("content_type", self._feature_flag_content_type) From f8d277cd281fd84adb529f89ecead173125670b1 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 11:25:44 -0400 Subject: [PATCH 16/60] working for sync --- .../_azure_appconfiguration_client.py | 48 +- ...est_delete_with_configuration_setting.yaml | 541 ++++++++++++++++++ .../tests/test_azure_configuration_client.py | 8 + .../test_azure_configuration_client_async.py | 8 + 4 files changed, 596 insertions(+), 9 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 0790fa617a50..7786f0dfe5da 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Optional, Any, Mapping, Union +from typing import Optional, Any, Mapping, Union, overload from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.pipeline import Pipeline @@ -394,8 +394,18 @@ def set_configuration_setting( except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") + @overload + def delete_configuration_setting(self, key, **kwargs): + # type: (str, **Any) -> ConfigurationSetting + pass + + @overload + def delete_configuration_setting(self, configuration_setting, **kwargs): + # type: (ConfigurationSetting, **Any) -> ConfigurationSetting + pass + @distributed_trace - def delete_configuration_setting(self, key, label=None, **kwargs): + def delete_configuration_setting(self, *args, **kwargs): # type: (str, Optional[str], **Any) -> ConfigurationSetting """Delete a ConfigurationSetting if it exists @@ -422,7 +432,18 @@ def delete_configuration_setting(self, key, label=None, **kwargs): key="MyKey", label="MyLabel" ) """ + key = kwargs.pop("key", None) + label = kwargs.pop("label", None) etag = kwargs.pop("etag", None) + if len(args) > 0: + if isinstance(args[0], ConfigurationSetting): + key = args[0].key + label = args[0].label + etag = args[0].etag if not None else etag + else: + key = args[0] + if len(args) == 2: + label = args[1] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} @@ -436,13 +457,22 @@ def delete_configuration_setting(self, key, label=None, **kwargs): error_map[412] = ResourceExistsError try: - key_value_deleted = self._impl.delete_key_value( - key=key, - label=label, - if_match=prep_if_match(etag, match_condition), - headers=custom_headers, - error_map=error_map, - ) + if label: + key_value_deleted = self._impl.delete_key_value( + key=key, + label=label, + if_match=prep_if_match(etag, match_condition), + headers=custom_headers, + error_map=error_map, + ) + else: + key_value_deleted = self._impl.delete_key_value( + key=key, + if_match=prep_if_match(etag, match_condition), + headers=custom_headers, + error_map=error_map, + ) + return ConfigurationSetting._from_generated(key_value_deleted) # type: ignore except HttpResponseError as error: e = error_map[error.status_code] diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml new file mode 100644 index 000000000000..d84958bcca72 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml @@ -0,0 +1,541 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:52.491986 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:57 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE1;sn=9440315 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "label": + "test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309", "content_type": "test content + type", "value": "test value", "tags": {"tag1": "tag1", "tag2": "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '231' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE1 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= + x-ms-date: + - Jun, 22 2021 15:24:53.048401 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:57 GMT + etag: + - '"H1Y44TeCkZRTjhbYqDLXUKqaC0Y"' + last-modified: + - Tue, 22 Jun 2021 15:24:54 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE2;sn=9440316 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE2 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:53.235228 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:57 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE2;sn=9440316 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE2 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:53.374785 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:57 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "content_type": + "test content type", "value": "test value", "tags": {"tag1": "tag1", "tag2": + "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '170' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE2 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= + x-ms-date: + - Jun, 22 2021 15:24:53.540208 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"vEJwpDIAkgaqS6JxAcrOGdRwWV8","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:57 GMT + etag: + - '"vEJwpDIAkgaqS6JxAcrOGdRwWV8"' + last-modified: + - Tue, 22 Jun 2021 15:24:54 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE3;sn=9440317 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE3 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:53.705365 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"vEJwpDIAkgaqS6JxAcrOGdRwWV8","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:58 GMT + etag: + - '"vEJwpDIAkgaqS6JxAcrOGdRwWV8"' + last-modified: + - Tue, 22 Jun 2021 15:24:54 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE4;sn=9440318 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE4 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:53.863455 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-length: + - '0' + date: + - Tue, 22 Jun 2021 15:24:58 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 404 + message: Not Found +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE4 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:54.073198 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:58 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE4 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:54.235165 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:58 GMT + etag: + - '"H1Y44TeCkZRTjhbYqDLXUKqaC0Y"' + last-modified: + - Tue, 22 Jun 2021 15:24:54 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwMzE5;sn=9440319 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwMzE5 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:24:54.397330 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:24:58 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 8ffa613bcc4a..645784038b2d 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -242,6 +242,14 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri to_delete_kv.key, label=to_delete_kv.label ) + @app_config_decorator + def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): + to_delete_kv = test_config_setting_no_label + client.delete_configuration_setting(to_delete_kv.key) + with pytest.raises(ResourceNotFoundError): + client.get_configuration_setting(to_delete_kv.key) + client.delete_configuration_setting(to_delete_kv) + @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): to_delete_kv = test_config_setting diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 5042ba86a5e0..2b4171d091f4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -189,6 +189,14 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri with pytest.raises(ResourceNotFoundError): client.get_configuration_setting(to_delete_kv.key) + @app_config_decorator + def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): + to_delete_kv = test_config_setting_no_label + client.delete_configuration_setting(to_delete_kv.key) + with pytest.raises(ResourceNotFoundError): + client.get_configuration_setting(to_delete_kv.key) + client.delete_configuration_setting(to_delete_kv) + @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): to_delete_kv = test_config_setting From c58a41fa5d24f8595cabfd30fcbe41b1444a546f Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 11:27:17 -0400 Subject: [PATCH 17/60] removing if conditional on delete --- .../_azure_appconfiguration_client.py | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 7786f0dfe5da..7cf85555e1d1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -457,22 +457,13 @@ def delete_configuration_setting(self, *args, **kwargs): error_map[412] = ResourceExistsError try: - if label: - key_value_deleted = self._impl.delete_key_value( - key=key, - label=label, - if_match=prep_if_match(etag, match_condition), - headers=custom_headers, - error_map=error_map, - ) - else: - key_value_deleted = self._impl.delete_key_value( - key=key, - if_match=prep_if_match(etag, match_condition), - headers=custom_headers, - error_map=error_map, - ) - + key_value_deleted = self._impl.delete_key_value( + key=key, + label=label, + if_match=prep_if_match(etag, match_condition), + headers=custom_headers, + error_map=error_map, + ) return ConfigurationSetting._from_generated(key_value_deleted) # type: ignore except HttpResponseError as error: e = error_map[error.status_code] From bc2263daec73a358a7ffeb597f984a672434f8eb Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 11:29:07 -0400 Subject: [PATCH 18/60] doc and typehint --- .../_azure_appconfiguration_client.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 7cf85555e1d1..26e781f27ab4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -406,14 +406,13 @@ def delete_configuration_setting(self, configuration_setting, **kwargs): @distributed_trace def delete_configuration_setting(self, *args, **kwargs): - # type: (str, Optional[str], **Any) -> ConfigurationSetting - + # type: (Union[str, ConfigurationSetting], **Any) -> 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 - :type label: str + :param str key: key used to identify the ConfigurationSetting + :param configuration-setting: ConfigurationSetting to be deleted + :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` + :keyword str label: label used to identify the ConfigurationSetting :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` From 8fcede651774c8bb681c9c5d6ed1b4212c5cbd2c Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 11:38:08 -0400 Subject: [PATCH 19/60] adding delete overload to async --- .../_azure_appconfiguration_client.py | 2 - .../aio/_azure_configuration_client_async.py | 38 +- ...est_delete_with_configuration_setting.yaml | 541 ++++++++++++++++++ .../tests/test_azure_configuration_client.py | 4 +- 4 files changed, 572 insertions(+), 13 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 26e781f27ab4..782408ed5ed8 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -441,8 +441,6 @@ def delete_configuration_setting(self, *args, **kwargs): etag = args[0].etag if not None else etag else: key = args[0] - if len(args) == 2: - label = args[1] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index a90de362a385..8c73699e4db9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Dict, Any, Optional, Mapping, Union +from typing import Dict, Any, Optional, Mapping, Union, overload from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.pipeline import AsyncPipeline @@ -408,17 +408,29 @@ async def set_configuration_setting( except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") + @overload + async def delete_configuration_setting(self, key: str, **kwargs: Any) -> ConfigurationSetting: + ... + + @overload + async def delete_configuration_setting(self, + configuration_setting: ConfigurationSetting, + **kwargs: Any + ) -> ConfigurationSetting: + ... + @distributed_trace_async async def delete_configuration_setting( - self, key, label=None, **kwargs - ): # type: (str, Optional[str], **Any) -> ConfigurationSetting - + self, + *args: Union[str, ConfigurationSetting], + **kwargs: Any + ) -> 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 - :type label: str + :param str key: key used to identify the ConfigurationSetting + :param configuration-setting: ConfigurationSetting to be deleted + :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` + :keyword str label: label used to identify the ConfigurationSetting :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` @@ -438,8 +450,16 @@ async def delete_configuration_setting( key="MyKey", label="MyLabel" ) """ - + key = kwargs.pop("key", None) + label = kwargs.pop("label", None) etag = kwargs.pop("etag", None) + if len(args) > 0: + if isinstance(args[0], ConfigurationSetting): + key = args[0].key + label = args[0].label + etag = args[0].etag if not None else etag + else: + key = args[0] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml new file mode 100644 index 000000000000..7733a54e094e --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml @@ -0,0 +1,541 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:47.469213 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:47 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjQ4;sn=9440648 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "label": + "test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309", "content_type": "test content + type", "value": "test value", "tags": {"tag1": "tag1", "tag2": "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '231' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjQ4 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= + x-ms-date: + - Jun, 22 2021 15:34:48.030742 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:47 GMT + etag: + - '"sOqKLFjBk2FkirerVAnfGvijyot"' + last-modified: + - Tue, 22 Jun 2021 15:34:49 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjQ5;sn=9440649 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjQ5 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:48.229792 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:47 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjQ5;sn=9440649 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjQ5 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:48.389907 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:47 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "content_type": + "test content type", "value": "test value", "tags": {"tag1": "tag1", "tag2": + "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '170' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjQ5 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= + x-ms-date: + - Jun, 22 2021 15:34:48.549719 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"x8RLWyf6AQrcwMx40sQo4atQoi2","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:47 GMT + etag: + - '"x8RLWyf6AQrcwMx40sQo4atQoi2"' + last-modified: + - Tue, 22 Jun 2021 15:34:49 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjUw;sn=9440650 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjUw + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:48.719779 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"x8RLWyf6AQrcwMx40sQo4atQoi2","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:48 GMT + etag: + - '"x8RLWyf6AQrcwMx40sQo4atQoi2"' + last-modified: + - Tue, 22 Jun 2021 15:34:49 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjUx;sn=9440651 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjUx + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:48.890302 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-length: + - '0' + date: + - Tue, 22 Jun 2021 15:34:48 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 404 + message: Not Found +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjUx + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:49.069792 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:48 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjUx + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:49.219617 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:48 GMT + etag: + - '"sOqKLFjBk2FkirerVAnfGvijyot"' + last-modified: + - Tue, 22 Jun 2021 15:34:49 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NDQwNjUy;sn=9440652 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NDQwNjUy + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 22 2021 15:34:49.379482 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Tue, 22 Jun 2021 15:34:48 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 645784038b2d..3284d0c5d094 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -123,7 +123,7 @@ def test_add_configuration_setting(self, client, appconfiguration_connection_str created_kv.value = None created_kv.value = "" client.delete_configuration_setting( - created_kv.key, created_kv.label + created_kv.key, label=created_kv.label ) @app_config_decorator @@ -193,7 +193,7 @@ def test_set_configuration_setting_no_etag(self, client, appconfiguration_connec and to_set_kv.etag != set_kv.etag ) client.delete_configuration_setting( - to_set_kv.key, to_set_kv.label + to_set_kv.key, label=to_set_kv.label ) # method: get_configuration_setting From b40fd10fc3b40f60a14bc3a259d1a7b067ef74bd Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 11:43:10 -0400 Subject: [PATCH 20/60] fixing tests --- ...est_delete_with_configuration_setting.yaml | 149 ++++++------------ ...est_delete_with_configuration_setting.yaml | 149 ++++++------------ .../tests/test_azure_configuration_client.py | 3 +- .../test_azure_configuration_client_async.py | 3 +- 4 files changed, 102 insertions(+), 202 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml index d84958bcca72..7ba384f50716 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml +++ b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml @@ -13,7 +13,7 @@ interactions: x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:52.491986 GMT + - Jun, 22 2021 15:41:42.462825 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: @@ -36,13 +36,13 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:57 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE1;sn=9440315 + - zAJw6V16=MDoxNyM5NDQwODYz;sn=9440863 transfer-encoding: - chunked status: @@ -66,19 +66,19 @@ interactions: If-None-Match: - '*' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE1 + - zAJw6V16=MDoxNyM5NDQwODYz User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= x-ms-date: - - Jun, 22 2021 15:24:53.048401 GMT + - Jun, 22 2021 15:41:43.034011 GMT method: PUT uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: body: - string: '{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + string: '{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -96,17 +96,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:57 GMT + - Tue, 22 Jun 2021 15:41:44 GMT etag: - - '"H1Y44TeCkZRTjhbYqDLXUKqaC0Y"' + - '"DeJ0uxOCy6WQFQmWEEV3pPzZmog"' last-modified: - - Tue, 22 Jun 2021 15:24:54 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE2;sn=9440316 + - zAJw6V16=MDoxNyM5NDQwODY0;sn=9440864 transfer-encoding: - chunked status: @@ -122,19 +122,19 @@ interactions: Connection: - keep-alive Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE2 + - zAJw6V16=MDoxNyM5NDQwODY0 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:53.235228 GMT + - Jun, 22 2021 15:41:43.182697 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 response: body: - string: '{"items":[{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}]}' + string: '{"items":[{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}]}' headers: access-control-allow-credentials: - 'true' @@ -152,13 +152,13 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:57 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE2;sn=9440316 + - zAJw6V16=MDoxNyM5NDQwODY0;sn=9440864 transfer-encoding: - chunked status: @@ -176,13 +176,13 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE2 + - zAJw6V16=MDoxNyM5NDQwODY0 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:53.374785 GMT + - Jun, 22 2021 15:41:43.312653 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -205,7 +205,7 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:57 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: @@ -231,19 +231,19 @@ interactions: If-None-Match: - '*' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE2 + - zAJw6V16=MDoxNyM5NDQwODY0 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= x-ms-date: - - Jun, 22 2021 15:24:53.540208 GMT + - Jun, 22 2021 15:41:43.444692 GMT method: PUT uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: body: - string: '{"etag":"vEJwpDIAkgaqS6JxAcrOGdRwWV8","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + string: '{"etag":"0cOKAAGr1cSbx4zvam8Stj5hyyA","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -261,17 +261,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:57 GMT + - Tue, 22 Jun 2021 15:41:44 GMT etag: - - '"vEJwpDIAkgaqS6JxAcrOGdRwWV8"' + - '"0cOKAAGr1cSbx4zvam8Stj5hyyA"' last-modified: - - Tue, 22 Jun 2021 15:24:54 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE3;sn=9440317 + - zAJw6V16=MDoxNyM5NDQwODY1;sn=9440865 transfer-encoding: - chunked status: @@ -289,19 +289,19 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE3 + - zAJw6V16=MDoxNyM5NDQwODY1 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:53.705365 GMT + - Jun, 22 2021 15:41:43.579818 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: body: - string: '{"etag":"vEJwpDIAkgaqS6JxAcrOGdRwWV8","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + string: '{"etag":"0cOKAAGr1cSbx4zvam8Stj5hyyA","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -319,17 +319,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:58 GMT + - Tue, 22 Jun 2021 15:41:44 GMT etag: - - '"vEJwpDIAkgaqS6JxAcrOGdRwWV8"' + - '"0cOKAAGr1cSbx4zvam8Stj5hyyA"' last-modified: - - Tue, 22 Jun 2021 15:24:54 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE4;sn=9440318 + - zAJw6V16=MDoxNyM5NDQwODY2;sn=9440866 transfer-encoding: - chunked status: @@ -345,13 +345,13 @@ interactions: Connection: - keep-alive Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE4 + - zAJw6V16=MDoxNyM5NDQwODY2 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:53.863455 GMT + - Jun, 22 2021 15:41:43.722785 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -374,7 +374,7 @@ interactions: content-length: - '0' date: - - Tue, 22 Jun 2021 15:24:58 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: @@ -394,68 +394,19 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE4 + - zAJw6V16=MDoxNyM5NDQwODY2 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:54.073198 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:24:58 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE4 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:24:54.235165 GMT + - Jun, 22 2021 15:41:43.855794 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: body: - string: '{"etag":"H1Y44TeCkZRTjhbYqDLXUKqaC0Y","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:24:54+00:00"}' + string: '{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -473,17 +424,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:58 GMT + - Tue, 22 Jun 2021 15:41:45 GMT etag: - - '"H1Y44TeCkZRTjhbYqDLXUKqaC0Y"' + - '"DeJ0uxOCy6WQFQmWEEV3pPzZmog"' last-modified: - - Tue, 22 Jun 2021 15:24:54 GMT + - Tue, 22 Jun 2021 15:41:44 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwMzE5;sn=9440319 + - zAJw6V16=MDoxNyM5NDQwODY3;sn=9440867 transfer-encoding: - chunked status: @@ -501,13 +452,13 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwMzE5 + - zAJw6V16=MDoxNyM5NDQwODY3 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:24:54.397330 GMT + - Jun, 22 2021 15:41:43.994362 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -530,7 +481,7 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:24:58 GMT + - Tue, 22 Jun 2021 15:41:45 GMT server: - openresty/1.17.8.2 strict-transport-security: diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml index 7733a54e094e..98e7dd72ec9c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml +++ b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml @@ -13,7 +13,7 @@ interactions: x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:47.469213 GMT + - Jun, 22 2021 15:41:44.200852 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: @@ -36,13 +36,13 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:47 GMT + - Tue, 22 Jun 2021 15:41:45 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjQ4;sn=9440648 + - zAJw6V16=MDoxNyM5NDQwODY3;sn=9440867 transfer-encoding: - chunked status: @@ -66,19 +66,19 @@ interactions: If-None-Match: - '*' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjQ4 + - zAJw6V16=MDoxNyM5NDQwODY3 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= x-ms-date: - - Jun, 22 2021 15:34:48.030742 GMT + - Jun, 22 2021 15:41:44.728991 GMT method: PUT uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: body: - string: '{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + string: '{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -96,17 +96,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:47 GMT + - Tue, 22 Jun 2021 15:41:46 GMT etag: - - '"sOqKLFjBk2FkirerVAnfGvijyot"' + - '"NoWRLVki4rC6Y4WJnSuFLdxrHWx"' last-modified: - - Tue, 22 Jun 2021 15:34:49 GMT + - Tue, 22 Jun 2021 15:41:45 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjQ5;sn=9440649 + - zAJw6V16=MDoxNyM5NDQwODY4;sn=9440868 transfer-encoding: - chunked status: @@ -122,19 +122,19 @@ interactions: Connection: - keep-alive Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjQ5 + - zAJw6V16=MDoxNyM5NDQwODY4 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:48.229792 GMT + - Jun, 22 2021 15:41:44.881090 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 response: body: - string: '{"items":[{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}]}' + string: '{"items":[{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}]}' headers: access-control-allow-credentials: - 'true' @@ -152,13 +152,13 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:47 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjQ5;sn=9440649 + - zAJw6V16=MDoxNyM5NDQwODY4;sn=9440868 transfer-encoding: - chunked status: @@ -176,13 +176,13 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjQ5 + - zAJw6V16=MDoxNyM5NDQwODY4 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:48.389907 GMT + - Jun, 22 2021 15:41:45.012249 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -205,7 +205,7 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:47 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: @@ -231,19 +231,19 @@ interactions: If-None-Match: - '*' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjQ5 + - zAJw6V16=MDoxNyM5NDQwODY4 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= x-ms-date: - - Jun, 22 2021 15:34:48.549719 GMT + - Jun, 22 2021 15:41:45.140103 GMT method: PUT uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: body: - string: '{"etag":"x8RLWyf6AQrcwMx40sQo4atQoi2","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + string: '{"etag":"Rivwo9kzUniW0UnKsK1xRMWYe0l","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:46+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -261,17 +261,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:47 GMT + - Tue, 22 Jun 2021 15:41:46 GMT etag: - - '"x8RLWyf6AQrcwMx40sQo4atQoi2"' + - '"Rivwo9kzUniW0UnKsK1xRMWYe0l"' last-modified: - - Tue, 22 Jun 2021 15:34:49 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjUw;sn=9440650 + - zAJw6V16=MDoxNyM5NDQwODY5;sn=9440869 transfer-encoding: - chunked status: @@ -289,19 +289,19 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjUw + - zAJw6V16=MDoxNyM5NDQwODY5 User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:48.719779 GMT + - Jun, 22 2021 15:41:45.282068 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: body: - string: '{"etag":"x8RLWyf6AQrcwMx40sQo4atQoi2","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + string: '{"etag":"Rivwo9kzUniW0UnKsK1xRMWYe0l","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:46+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -319,17 +319,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:48 GMT + - Tue, 22 Jun 2021 15:41:46 GMT etag: - - '"x8RLWyf6AQrcwMx40sQo4atQoi2"' + - '"Rivwo9kzUniW0UnKsK1xRMWYe0l"' last-modified: - - Tue, 22 Jun 2021 15:34:49 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjUx;sn=9440651 + - zAJw6V16=MDoxNyM5NDQwODcw;sn=9440870 transfer-encoding: - chunked status: @@ -345,13 +345,13 @@ interactions: Connection: - keep-alive Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjUx + - zAJw6V16=MDoxNyM5NDQwODcw User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:48.890302 GMT + - Jun, 22 2021 15:41:45.415107 GMT method: GET uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -374,7 +374,7 @@ interactions: content-length: - '0' date: - - Tue, 22 Jun 2021 15:34:48 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: @@ -394,68 +394,19 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjUx + - zAJw6V16=MDoxNyM5NDQwODcw User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:49.069792 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:34:48 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjUx - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:34:49.219617 GMT + - Jun, 22 2021 15:41:45.544070 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 response: body: - string: '{"etag":"sOqKLFjBk2FkirerVAnfGvijyot","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:34:49+00:00"}' + string: '{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}' headers: access-control-allow-credentials: - 'true' @@ -473,17 +424,17 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:48 GMT + - Tue, 22 Jun 2021 15:41:46 GMT etag: - - '"sOqKLFjBk2FkirerVAnfGvijyot"' + - '"NoWRLVki4rC6Y4WJnSuFLdxrHWx"' last-modified: - - Tue, 22 Jun 2021 15:34:49 GMT + - Tue, 22 Jun 2021 15:41:45 GMT server: - openresty/1.17.8.2 strict-transport-security: - max-age=15724800; includeSubDomains sync-token: - - zAJw6V16=MDoxNyM5NDQwNjUy;sn=9440652 + - zAJw6V16=MDoxNyM5NDQwODcx;sn=9440871 transfer-encoding: - chunked status: @@ -501,13 +452,13 @@ interactions: Content-Length: - '0' Sync-Token: - - zAJw6V16=MDoxNyM5NDQwNjUy + - zAJw6V16=MDoxNyM5NDQwODcx User-Agent: - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-content-sha256: - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= x-ms-date: - - Jun, 22 2021 15:34:49.379482 GMT + - Jun, 22 2021 15:41:45.692068 GMT method: DELETE uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 response: @@ -530,7 +481,7 @@ interactions: content-type: - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 date: - - Tue, 22 Jun 2021 15:34:48 GMT + - Tue, 22 Jun 2021 15:41:46 GMT server: - openresty/1.17.8.2 strict-transport-security: diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 3284d0c5d094..6bd743977894 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -245,10 +245,9 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri @app_config_decorator def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): to_delete_kv = test_config_setting_no_label - client.delete_configuration_setting(to_delete_kv.key) + client.delete_configuration_setting(to_delete_kv) with pytest.raises(ResourceNotFoundError): client.get_configuration_setting(to_delete_kv.key) - client.delete_configuration_setting(to_delete_kv) @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 2b4171d091f4..96144c6a2278 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -192,10 +192,9 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri @app_config_decorator def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): to_delete_kv = test_config_setting_no_label - client.delete_configuration_setting(to_delete_kv.key) + client.delete_configuration_setting(to_delete_kv) with pytest.raises(ResourceNotFoundError): client.get_configuration_setting(to_delete_kv.key) - client.delete_configuration_setting(to_delete_kv) @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): From 37d0ecece43baf00ee1d8c663f28342b85e64dc0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 12:58:30 -0400 Subject: [PATCH 21/60] adding back label to not be breaking --- .../appconfiguration/_azure_appconfiguration_client.py | 6 ++++-- .../tests/test_azure_configuration_client.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 782408ed5ed8..23b5df860445 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -395,8 +395,8 @@ def set_configuration_setting( raise binascii.Error("Connection string secret has incorrect padding") @overload - def delete_configuration_setting(self, key, **kwargs): - # type: (str, **Any) -> ConfigurationSetting + def delete_configuration_setting(self, key, label=None, **kwargs): + # type: (str, Optional[str], **Any) -> ConfigurationSetting pass @overload @@ -441,6 +441,8 @@ def delete_configuration_setting(self, *args, **kwargs): etag = args[0].etag if not None else etag else: key = args[0] + if len(args) == 2: + label = args[1] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 6bd743977894..73f3f3534073 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -123,7 +123,7 @@ def test_add_configuration_setting(self, client, appconfiguration_connection_str created_kv.value = None created_kv.value = "" client.delete_configuration_setting( - created_kv.key, label=created_kv.label + created_kv.key, created_kv.label ) @app_config_decorator @@ -193,7 +193,7 @@ def test_set_configuration_setting_no_etag(self, client, appconfiguration_connec and to_set_kv.etag != set_kv.etag ) client.delete_configuration_setting( - to_set_kv.key, label=to_set_kv.label + to_set_kv.key, to_set_kv.label ) # method: get_configuration_setting From de563be15f0c3fa776c5cbb7fd05ae7fe9997316 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:02:11 -0400 Subject: [PATCH 22/60] non breaking for delete --- .../aio/_azure_configuration_client_async.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 8c73699e4db9..1d248a39dfad 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -409,7 +409,12 @@ async def set_configuration_setting( raise binascii.Error("Connection string secret has incorrect padding") @overload - async def delete_configuration_setting(self, key: str, **kwargs: Any) -> ConfigurationSetting: + async def delete_configuration_setting( + self, + key: str, + label: Optional[str] = None, + **kwargs: Any + ) -> ConfigurationSetting: ... @overload From c8a4aa906fd82ec44914307f2d39fade4a180ea9 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:21:38 -0400 Subject: [PATCH 23/60] undoing breaking change --- .../_azure_appconfiguration_client.py | 22 +++++++++++++------ .../aio/_azure_configuration_client_async.py | 1 - 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 6ca3d73aceab..9141de915afd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -213,17 +213,25 @@ def list_configuration_settings(self, **kwargs): raise binascii.Error("Connection string secret has incorrect padding") @distributed_trace - def get_configuration_setting(self, key, **kwargs): - # type: (str, **Any) -> Union[None, ConfigurationSetting] - + def get_configuration_setting( + self, + key, # type: str + label=None, # type: Optional[str] + etag="*", # type: Optional[str] + match_condition=MatchConditions.Unconditionally, # type: Optional[MatchConditions] + **kwargs # type: Any + ): + # type: (...) -> Union[None, ConfigurationSetting] """Get the matched ConfigurationSetting from Azure App Configuration service :param key: key of the ConfigurationSetting :type key: str - :keyword str label: label of the ConfigurationSetting - :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag - :keyword match_condition: The match condition to use upon the etag - :paramtype match_condition: :class:`~azure.core.MatchConditions` + :param label: label of the ConfigurationSetting + :type label: str + :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: :class:`~azure.core.MatchConditions` :keyword datetime accept_datetime: the retrieved ConfigurationSetting that created no later than this datetime :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The matched ConfigurationSetting object diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 2ab2cb261c5b..00c21ea1959c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -233,7 +233,6 @@ def list_configuration_settings( async def get_configuration_setting( self, key: str, - *, label: Optional[str] = None, etag: Optional[str] = "*", match_condition: Optional[MatchConditions] = MatchConditions.Unconditionally, From 163decc379e621c68309bc156ea9ca9958149dd1 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:33:24 -0400 Subject: [PATCH 24/60] undoing rename of endpoint --- .../azure-appconfiguration/CHANGELOG.md | 4 ---- .../azure-appconfiguration/README.md | 2 +- .../_azure_appconfiguration_client.py | 24 +++++++++---------- .../azure/appconfiguration/_utils.py | 12 +++++----- .../aio/_azure_configuration_client_async.py | 24 +++++++++---------- .../test_azure_configuration_client_aad.py | 4 ++-- ...st_azure_configuration_client_aad_async.py | 4 ++-- 7 files changed, 35 insertions(+), 39 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index d76824d6b639..d846fe241f43 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -4,10 +4,6 @@ ### Features Added ### Breaking Changes -* renamed `base_url` to endpoint in `AzureAppConfigurationClient` -* `key_filter` and `label_filter` are keyword arguments in `list_configuration_settings` -* `label`, `etag`, and `match_condition` are now keyword arguments in `get_configuration_settings` -* `enabled` parameter in `FeatureFlagConfigurationSetting` is now a keyword argument ### Key Bugs Fixed diff --git a/sdk/appconfiguration/azure-appconfiguration/README.md b/sdk/appconfiguration/azure-appconfiguration/README.md index 76a574988c05..bd245cdb0540 100644 --- a/sdk/appconfiguration/azure-appconfiguration/README.md +++ b/sdk/appconfiguration/azure-appconfiguration/README.md @@ -115,7 +115,7 @@ from azure.appconfiguration import AzureAppConfigurationClient credential = DefaultAzureCredential() -client = AzureAppConfigurationClient(endpoint="your_endpoint_url", credential=credential) +client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential) ``` ## Key concepts diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 9141de915afd..a2f4f71be6a3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -47,7 +47,7 @@ class AzureAppConfigurationClient: """Represents an client that calls restful API of Azure App Configuration service. - :param str endpoint: base url of the 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: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials.TokenCredential` @@ -55,21 +55,21 @@ class AzureAppConfigurationClient: # pylint:disable=protected-access - def __init__(self, endpoint, credential, **kwargs): + def __init__(self, base_url, credential, **kwargs): # type: (str, Union[AppConfigConnectionStringCredential, TokenCredential], **Any) -> None try: - if not endpoint.lower().startswith("http"): - endpoint = "https://" + endpoint + if not base_url.lower().startswith("http"): + base_url = "https://" + base_url except AttributeError: raise ValueError("Base URL must be a string.") if not credential: raise ValueError("Missing credential") - self._credential_scopes = endpoint.strip("/") + "/.default" + self._credential_scopes = base_url.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, endpoint, credential_scopes=self._credential_scopes, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -82,11 +82,11 @@ def __init__(self, endpoint, credential, **kwargs): self._sync_token_policy = SyncTokenPolicy() aad_mode = not isinstance(credential, AppConfigConnectionStringCredential) pipeline = self._create_appconfig_pipeline( - credential=credential, aad_mode=aad_mode, endpoint=endpoint, **kwargs + credential=credential, aad_mode=aad_mode, base_url=base_url, **kwargs ) self._impl = AzureAppConfiguration( - credential, endpoint, pipeline=pipeline, credential_scopes=self._credential_scopes + credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes ) @classmethod @@ -108,22 +108,22 @@ def from_connection_string(cls, connection_string, **kwargs): connection_str = "" client = AzureAppConfigurationClient.from_connection_string(connection_str) """ - endpoint = "https://" + get_endpoint_from_connection_string(connection_string) + base_url = "https://" + get_endpoint_from_connection_string(connection_string) return cls( credential=AppConfigConnectionStringCredential(connection_string), - endpoint=endpoint, + base_url=base_url, **kwargs ) def _create_appconfig_pipeline( - self, credential, endpoint=None, aad_mode=False, **kwargs + self, credential, base_url=None, aad_mode=False, **kwargs ): transport = kwargs.get("transport") policies = kwargs.get("policies") if policies is None: # [] is a valid policy list if aad_mode: - scope = endpoint.strip("/") + "/.default" + scope = base_url.strip("/") + "/.default" if hasattr(credential, "get_token"): credential_policy = BearerTokenCredentialPolicy(credential, scope) else: diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py index 3ff02d4a1d47..8b71334865d3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py @@ -42,8 +42,8 @@ def prep_if_none_match(etag, match_condition): def get_endpoint_from_connection_string(connection_string): # type: (str) -> str - endpoint, _, _ = parse_connection_string(connection_string) - return endpoint + base_url, _, _ = parse_connection_string(connection_string) + return base_url def parse_connection_string(connection_string): @@ -53,13 +53,13 @@ def parse_connection_string(connection_string): if len(segments) != 3: raise ValueError("Invalid connection string.") - endpoint = "" + base_url = "" id_ = "" secret = "" for segment in segments: segment = segment.strip() if segment.startswith("Endpoint"): - endpoint = str(segment[17:]) + base_url = str(segment[17:]) elif segment.startswith("Id"): id_ = str(segment[3:]) elif segment.startswith("Secret"): @@ -67,10 +67,10 @@ def parse_connection_string(connection_string): else: raise ValueError("Invalid connection string.") - if not endpoint or not id_ or not secret: + if not base_url or not id_ or not secret: raise ValueError("Invalid connection string.") - return endpoint, id_, secret + return base_url, id_, secret def get_current_utc_time(): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 00c21ea1959c..021b72793eb8 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -48,7 +48,7 @@ class AzureAppConfigurationClient: """Represents an client that calls restful API of Azure App Configuration service. - :param str endpoint: base url of the 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: :class:`azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials_async.AsyncTokenCredential` @@ -61,23 +61,23 @@ class AzureAppConfigurationClient: def __init__( self, - endpoint: str, + base_url: str, credential: Union[AppConfigConnectionStringCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: try: - if not endpoint.lower().startswith("http"): - endpoint = "https://" + endpoint + if not base_url.lower().startswith("http"): + base_url = "https://" + base_url except AttributeError: raise ValueError("Base URL must be a string.") if not credential: raise ValueError("Missing credential") - self._credential_scopes = endpoint.strip("/") + "/.default" + self._credential_scopes = base_url.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, endpoint, credential_scopes=self._credential_scopes, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -90,11 +90,11 @@ def __init__( self._sync_token_policy = SyncTokenPolicy() aad_mode = not isinstance(credential, AppConfigConnectionStringCredential) pipeline = self._create_appconfig_pipeline( - credential=credential, aad_mode=aad_mode, endpoint=endpoint, **kwargs + credential=credential, aad_mode=aad_mode, base_url=base_url, **kwargs ) self._impl = AzureAppConfiguration( - credential, endpoint, credential_scopes=self._credential_scopes, pipeline=pipeline + credential, base_url, credential_scopes=self._credential_scopes, pipeline=pipeline ) @classmethod @@ -116,22 +116,22 @@ def from_connection_string(cls, connection_string: str, **kwargs: Any) -> "Azure connection_str = "" async_client = AzureAppConfigurationClient.from_connection_string(connection_str) """ - endpoint = "https://" + get_endpoint_from_connection_string(connection_string) + base_url = "https://" + get_endpoint_from_connection_string(connection_string) return cls( credential=AppConfigConnectionStringCredential(connection_string), - endpoint=endpoint, + base_url=base_url, **kwargs ) def _create_appconfig_pipeline( - self, credential, endpoint=None, aad_mode=False, **kwargs + self, credential, base_url=None, aad_mode=False, **kwargs ): transport = kwargs.get("transport") policies = kwargs.get("policies") if policies is None: # [] is a valid policy list if aad_mode: - scope = endpoint.strip("/") + "/.default" + scope = base_url.strip("/") + "/.default" if hasattr(credential, "get_token"): credential_policy = AsyncBearerTokenCredentialPolicy( credential, scope diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index d363b357d987..27f123aa05d3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -51,9 +51,9 @@ def _delete_setting(self, client, item): key=item.key, label=item.label ) - def create_aad_client(self, endpoint): + def create_aad_client(self, base_url): cred = self.get_credential(AzureAppConfigurationClient) - return AzureAppConfigurationClient(endpoint, cred) + return AzureAppConfigurationClient(base_url, cred) # method: add_configuration_setting @app_config_decorator diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 1906282d9c60..86d73fed66b0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -53,9 +53,9 @@ def _delete_setting(self, client, item): key=item.key, label=item.label ) - def create_aad_client(self, endpoint): + def create_aad_client(self, base_url): cred = self.get_credential(AzureAppConfigurationClient, is_async=True) - client = AzureAppConfigurationClient(endpoint, cred) + client = AzureAppConfigurationClient(base_url, cred) return AzureAppConfigurationClientProxy(client) # method: add_configuration_setting From f5154d0c17eea7af725bea1a548461478f58b5f8 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:35:59 -0400 Subject: [PATCH 25/60] undoing more breaking changes --- .../_azure_appconfiguration_client.py | 8 ++++---- .../azure/appconfiguration/_utils.py | 12 ++++++------ .../aio/_azure_configuration_client_async.py | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index a2f4f71be6a3..5f9ec2423df5 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -151,8 +151,10 @@ def _create_appconfig_pipeline( return Pipeline(transport, policies) @distributed_trace - def list_configuration_settings(self, **kwargs): - # type: (**Any) -> ItemPaged[ConfigurationSetting] + def list_configuration_settings( + self, key_filter=None, label_filter=None, **kwargs + ): + # type: (Optional[str], Optional[str], **Any) -> ItemPaged[ConfigurationSetting] """List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime @@ -189,8 +191,6 @@ def list_configuration_settings(self, **kwargs): pass # do something """ select = kwargs.pop("fields", None) - key_filter = kwargs.pop("key_filter", None) - label_filter = kwargs.pop("label_filter", None) if select: select = ["locked" if x == "read_only" else x for x in select] error_map = {401: ClientAuthenticationError} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py index 8b71334865d3..3ff02d4a1d47 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_utils.py @@ -42,8 +42,8 @@ def prep_if_none_match(etag, match_condition): def get_endpoint_from_connection_string(connection_string): # type: (str) -> str - base_url, _, _ = parse_connection_string(connection_string) - return base_url + endpoint, _, _ = parse_connection_string(connection_string) + return endpoint def parse_connection_string(connection_string): @@ -53,13 +53,13 @@ def parse_connection_string(connection_string): if len(segments) != 3: raise ValueError("Invalid connection string.") - base_url = "" + endpoint = "" id_ = "" secret = "" for segment in segments: segment = segment.strip() if segment.startswith("Endpoint"): - base_url = str(segment[17:]) + endpoint = str(segment[17:]) elif segment.startswith("Id"): id_ = str(segment[3:]) elif segment.startswith("Secret"): @@ -67,10 +67,10 @@ def parse_connection_string(connection_string): else: raise ValueError("Invalid connection string.") - if not base_url or not id_ or not secret: + if not endpoint or not id_ or not secret: raise ValueError("Invalid connection string.") - return base_url, id_, secret + return endpoint, id_, secret def get_current_utc_time(): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 021b72793eb8..0abd617c1000 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -167,7 +167,6 @@ def _create_appconfig_pipeline( @distributed_trace def list_configuration_settings( self, - *, key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any From d65d39f44eadf5d2aa84fec0b3b0acdcdb493015 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:43:00 -0400 Subject: [PATCH 26/60] fixing up a couple more --- .../azure/appconfiguration/_azure_appconfiguration_client.py | 3 --- .../azure-appconfiguration/tests/test_consistency.py | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 5f9ec2423df5..39752f11aa1a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -247,9 +247,6 @@ def get_configuration_setting( key="MyKey", label="MyLabel" ) """ - label = kwargs.pop("label", None) - etag = kwargs.pop("etag", "*") - match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError} if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index 2dc2bb593821..6da079ae7d85 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -44,10 +44,7 @@ class AppConfigurationClientTest(AzureTestCase): def _assert_same_keys(self, key1, key2): assert type(key1) == type(key2) - try: - assert key1.key == key2.key - except AttributeError: - assert key1.key == key2.key + assert key1.key == key2.key assert key1.label == key2.label assert key1.content_type == key2.content_type assert key1.tags == key2.tags From 9d9b9327e19ed6bf8d9a9dd4ab630eef61fd45d2 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 13:49:15 -0400 Subject: [PATCH 27/60] one more removal --- .../appconfiguration/_azure_appconfiguration_client.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 39752f11aa1a..8befb8d5aea6 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -153,8 +153,7 @@ def _create_appconfig_pipeline( @distributed_trace def list_configuration_settings( self, key_filter=None, label_filter=None, **kwargs - ): - # type: (Optional[str], Optional[str], **Any) -> ItemPaged[ConfigurationSetting] + ): # type: (Optional[str], Optional[str], **Any) -> ItemPaged[ConfigurationSetting] """List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime @@ -220,8 +219,7 @@ def get_configuration_setting( etag="*", # type: Optional[str] match_condition=MatchConditions.Unconditionally, # type: Optional[MatchConditions] **kwargs # type: Any - ): - # type: (...) -> Union[None, ConfigurationSetting] + ): # type: (...) -> Union[None, ConfigurationSetting] """Get the matched ConfigurationSetting from Azure App Configuration service :param key: key of the ConfigurationSetting From b2c245025d865bd4b8276fcd2debe981c45963aa Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 14:19:34 -0400 Subject: [PATCH 28/60] changelog --- sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index d3f8b0b51449..828cd306465e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -1,7 +1,13 @@ # Release History ## 1.2.0b3 (Unreleased) +### Features Added +* `delete_configuration_setting` now takes either the string `key` or a `ConfigurationSetting` object. +### Breaking Changes +### Key Bugs Fixed + +### Fixed ## 1.2.0b2 (2021-06-08) From f130b683eb22a0d402a91d70e1b552bf2730e59a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 14:45:27 -0400 Subject: [PATCH 29/60] fixing breaking change --- .../appconfiguration/aio/_azure_configuration_client_async.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 0abd617c1000..393662cfd519 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -346,6 +346,7 @@ async def add_configuration_setting( async def set_configuration_setting( self, configuration_setting: ConfigurationSetting, + match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs: Any ) -> ConfigurationSetting: From e53bda805b12398bc8782d396e732c6459be012c Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 15:28:14 -0400 Subject: [PATCH 30/60] secret reference issue, breaking change fixed --- .../azure/appconfiguration/_models.py | 19 +++++++++++++------ .../aio/_azure_configuration_client_async.py | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 2636fc057da4..86b3aea1a842 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -158,8 +158,8 @@ class FeatureFlagConfigurationSetting( ) kind = "FeatureFlag" - def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangerous-default-value - # type: (str, bool, Optional[List[Dict[str, Any]]], **Any) -> None + def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value + # type: (str, **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id.lstrip(self.key_prefix) if not feature_id.startswith(self.key_prefix): @@ -176,10 +176,10 @@ def __init__(self, feature_id, filters=[], **kwargs): # pylint: disable=dangero if "enabled" in kwargs.keys(): self.value = kwargs.get( "value", - {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": filters}} + {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters", [])}} ) else: - self.value = kwargs.get("value", {"conditions": {"client_filters": filters}}) + self.value = kwargs.get("value", {"conditions": {"client_filters": kwargs.pop("filters", [])}}) def _validate(self): # type: () -> None @@ -326,8 +326,15 @@ def __init__(self, key, secret_id, label=None, **kwargs): self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) self.value = secret_id - if not isinstance(secret_id, dict): - self.value = {"secret_uri": secret_id} + import six + if not self.value: + self.value = {} + if isinstance(self.value, dict) and "secret_uri" not in self.value.keys(): + self.value["secret_uri"] = secret_id + elif isinstance(self.value, six.string_types): + self.value = {"secret_uri": self.value} + # elif not self.value: + # self.value = {"secret_uri": secret_id} @property def secret_id(self): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 393662cfd519..b929b748787b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -382,7 +382,6 @@ async def set_configuration_setting( returned_config_setting = await async_client.set_configuration_setting(config_setting) """ etag = kwargs.get("etag", configuration_setting.etag) - match_condition = kwargs.get("match_condition", MatchConditions.Unconditionally) key_value = configuration_setting._to_generated() custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] From 6378d76777799076d0688e3fa84190c19abd0d0a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 16:36:38 -0400 Subject: [PATCH 31/60] pylint and mypy fixes --- .../appconfiguration/_azure_appconfiguration_client.py | 9 +++++---- .../azure/appconfiguration/_models.py | 2 +- .../aio/_azure_configuration_client_async.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 8befb8d5aea6..018b3f28eefa 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Optional, Any, Union, TYPE_CHECKING +from typing import Optional, Any, Union, Mapping, TYPE_CHECKING from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.pipeline import Pipeline @@ -49,7 +49,8 @@ class AzureAppConfigurationClient: :param str base_url: base url of the service :param credential: An object which can provide secrets for the app configuration service - :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` or :class:`~azure.core.credentials.TokenCredential` + :type credential: :class:`~azure.appconfiguration.AppConfigConnectionStringCredential` + or :class:`~azure.core.credentials.TokenCredential` """ @@ -69,7 +70,7 @@ def __init__(self, base_url, credential, **kwargs): self._credential_scopes = base_url.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs # type: ignore ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -86,7 +87,7 @@ def __init__(self, base_url, credential, **kwargs): ) self._impl = AzureAppConfiguration( - credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes + credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes # type: ignore ) @classmethod diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 86b3aea1a842..8c500571d377 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -371,7 +371,7 @@ def _from_generated(cls, key_value): key=key_value.key, # type: ignore secret_uri=key_value.value[u"secret_uri"], # type: ignore label=key_value.label, - secret_id=key_value.value, + secret_id=key_value.value, # type: ignore last_modified=key_value.last_modified, tags=key_value.tags, read_only=key_value.locked, diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index b929b748787b..ba5343c4e117 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -77,7 +77,7 @@ def __init__( self._credential_scopes = base_url.strip("/") + "/.default" self._config = AzureAppConfigurationConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, **kwargs + credential, base_url, credential_scopes=self._credential_scopes, **kwargs # type: ignore ) self._config.user_agent_policy = UserAgentPolicy( base_user_agent=USER_AGENT, **kwargs @@ -94,7 +94,7 @@ def __init__( ) self._impl = AzureAppConfiguration( - credential, base_url, credential_scopes=self._credential_scopes, pipeline=pipeline + credential, base_url, credential_scopes=self._credential_scopes, pipeline=pipeline # type: ignore ) @classmethod From cfb9642e5c1a2a092b45ecdd2f01a562905dcf9a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 16:51:23 -0400 Subject: [PATCH 32/60] more of xiangs feedback --- .../azure/appconfiguration/_models.py | 16 ++++++---------- .../tests/test_azure_configuration_client.py | 4 ++-- .../tests/test_azure_configuration_client_aad.py | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 8c500571d377..bd497dc50068 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ import json +import six from typing import Dict, Optional, Any, List, Union from msrest.serialization import Model from ._generated.models import KeyValue @@ -122,10 +123,10 @@ class FeatureFlagConfigurationSetting( :vartype feature_id: str :ivar value: The value of the configuration setting :vartype value: str - :ivar enabled: - :vartype enabled: bool - :param filters: - :type filters: list[dict[str, Any]] + :keyword enabled: + :paramtype enabled: bool + :keyword filters: + :paramtype filters: list[dict[str, Any]] :param label: :type label: str :param display_name: @@ -162,9 +163,7 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v # type: (str, **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id.lstrip(self.key_prefix) - if not feature_id.startswith(self.key_prefix): - feature_id = self.key_prefix + feature_id - self.key = feature_id + self.key = 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) @@ -326,15 +325,12 @@ def __init__(self, key, secret_id, label=None, **kwargs): self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) self.value = secret_id - import six if not self.value: self.value = {} if isinstance(self.value, dict) and "secret_uri" not in self.value.keys(): self.value["secret_uri"] = secret_id elif isinstance(self.value, six.string_types): self.value = {"secret_uri": self.value} - # elif not self.value: - # self.value = {"secret_uri": secret_id} @property def secret_id(self): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index bc76c7d1d7dd..afedbe1a76c6 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -208,7 +208,7 @@ def test_get_configuration_setting_no_label(self, client, appconfiguration_conne def test_get_configuration_setting_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): compare_kv = test_config_setting fetched_kv = client.get_configuration_setting( - compare_kv.key, label=compare_kv.label + compare_kv.key, compare_kv.label ) assert ( fetched_kv.key == compare_kv.key @@ -223,7 +223,7 @@ def test_get_non_existing_configuration_setting(self, client, appconfiguration_c compare_kv = test_config_setting with pytest.raises(ResourceNotFoundError): client.get_configuration_setting( - compare_kv.key, label=compare_kv.label + "a" + compare_kv.key, compare_kv.label + "a" ) # method: delete_configuration_setting diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 27f123aa05d3..af6e86755d09 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -173,7 +173,7 @@ def test_get_configuration_setting_label(self, appconfiguration_endpoint_string, client = self.create_aad_client(appconfiguration_endpoint_string) compare_kv = test_config_setting fetched_kv = client.get_configuration_setting( - compare_kv.key, label=compare_kv.label + compare_kv.key, compare_kv.label ) assert ( fetched_kv.key == compare_kv.key @@ -189,7 +189,7 @@ def test_get_non_existing_configuration_setting(self, appconfiguration_endpoint_ compare_kv = test_config_setting with pytest.raises(ResourceNotFoundError): client.get_configuration_setting( - compare_kv.key, label=compare_kv.label + "a" + compare_kv.key, compare_kv.label + "a" ) # method: delete_configuration_setting From 4ac7be201e8b919c477a7da329532b196c9ce7d0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 16:52:53 -0400 Subject: [PATCH 33/60] fixing key and feature_id --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index bd497dc50068..fcc2c7cbc2d0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -162,8 +162,8 @@ class FeatureFlagConfigurationSetting( def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value # type: (str, **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) - self.feature_id = feature_id.lstrip(self.key_prefix) - self.key = self.key_prefix + self.feature_id + self.feature_id = feature_id + self.key = self.key_prefix + self.feature_id.lstrip(self.key_prefix) 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) From bdc7d76f12a09e45270dbe8bb5530e580780b920 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 22 Jun 2021 18:11:54 -0400 Subject: [PATCH 34/60] working with xiang --- .../azure/appconfiguration/_models.py | 82 +++++++++++-------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index fcc2c7cbc2d0..81c0f0035d27 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -163,7 +163,7 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v # type: (str, **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id - self.key = self.key_prefix + self.feature_id.lstrip(self.key_prefix) + self.key = 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) @@ -172,13 +172,13 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.etag = kwargs.get("etag", None) self.description = kwargs.get("description", None) self.display_name = kwargs.get("display_name", None) - if "enabled" in kwargs.keys(): - self.value = kwargs.get( - "value", - {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters", [])}} - ) - else: - self.value = kwargs.get("value", {"conditions": {"client_filters": kwargs.pop("filters", [])}}) + # if "enabled" in kwargs.keys(): + # self.value = kwargs.get( + # "value", + # {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters", [])}} + # ) + # else: + # self.value = kwargs.get("value", {"conditions": {"client_filters": kwargs.pop("filters", [])}}) def _validate(self): # type: () -> None @@ -206,6 +206,12 @@ def enabled(self, new_value): @property def filters(self): # type: () -> Union[None, List[Any]] + try: + temp = json.dumps(self.value) + return temp.get("feature_filters", None) + except json.DecodeError: + raise ValueError + self._validate() if self.value is None: return None @@ -218,15 +224,17 @@ def filters(self): @filters.setter def filters(self, new_filters): # type: (List[Dict[str, Any]]) -> None - self._validate() - if self.value is None: - self.value = {} - try: - self.value["conditions"]["client_filters"] = new_filters - except KeyError: - self.value["conditions"] = { - "client_filters": new_filters - } + temp = json.dumps(self.value) + temp["feature_filters"] = new_filters + # self._validate() + # if self.value is None: + # self.value = {} + # try: + # self.value["conditions"]["client_filters"] = new_filters + # except KeyError: + # self.value["conditions"] = { + # "client_filters": new_filters + # } @classmethod def _from_generated(cls, key_value): @@ -234,24 +242,24 @@ def _from_generated(cls, key_value): try: if key_value is None: return key_value - if key_value.value: - try: - key_value.value = json.loads(key_value.value) - except json.decoder.JSONDecodeError: - pass + # if key_value.value: + # try: + # key_value.value = json.loads(key_value.value) + # except json.decoder.JSONDecodeError: + # pass - filters = key_value.value["conditions"]["client_filters"] # type: ignore + # filters = key_value.value["conditions"]["client_filters"] # type: ignore return cls( - feature_id=key_value.key, # type: ignore - enabled=key_value.value["enabled"], # type: ignore + feature_id=key_value.key.lstrip(self._key_prefix), # type: ignore + # enabled=key_value.value["enabled"], # type: ignore 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, - filters=filters, # type: ignore + # filters=filters, # type: ignore value=key_value.value, ) except (KeyError, AttributeError): @@ -324,13 +332,14 @@ def __init__(self, key, secret_id, label=None, **kwargs): self.last_modified = kwargs.get("last_modified", None) self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) - self.value = secret_id if not self.value: - self.value = {} - if isinstance(self.value, dict) and "secret_uri" not in self.value.keys(): - self.value["secret_uri"] = secret_id - elif isinstance(self.value, six.string_types): - self.value = {"secret_uri": self.value} + self.value = json.dumps({"secret_uri": secret_id}) + # if not self.value: + # self.value = {} + # if isinstance(self.value, dict) and "secret_uri" not in self.value.keys(): + # self.value["secret_uri"] = secret_id + # elif isinstance(self.value, six.string_types): + # self.value = {"secret_uri": self.value} @property def secret_id(self): @@ -339,13 +348,13 @@ def secret_id(self): return self.value['secret_uri'] @secret_id.setter - def secret_id(self, value): + def secret_id(self, secret_id): if self.value is None or isinstance(self.value, dict): if self.value is None: self.value = {} - self.value["secret_uri"] = value + self.value["secret_uri"] = secret_id else: - raise ValueError("Expect 'value' to be a dictionary.") + raise ValueError("Expect 'self.value' to be a dictionary.") def _validate(self): # type: () -> None @@ -365,7 +374,8 @@ def _from_generated(cls, key_value): return cls( key=key_value.key, # type: ignore - secret_uri=key_value.value[u"secret_uri"], # type: ignore + # secret_uri=key_value.value[u"secret_uri"], # type: ignore + value=key_value.value, label=key_value.label, secret_id=key_value.value, # type: ignore last_modified=key_value.last_modified, From fe14053dcd5b15b740a247557325bcb24e07a142 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 10:08:36 -0400 Subject: [PATCH 35/60] fixed secref --- .../azure/appconfiguration/_models.py | 40 +++++++++---------- .../tests/test_azure_configuration_client.py | 9 ++--- .../test_azure_configuration_client_aad.py | 9 ++--- ...st_azure_configuration_client_aad_async.py | 9 ++--- .../test_azure_configuration_client_async.py | 9 +++-- 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 81c0f0035d27..4708e34141c8 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ import json +from json.decoder import JSONDecodeError import six from typing import Dict, Optional, Any, List, Union from msrest.serialization import Model @@ -343,38 +344,35 @@ def __init__(self, key, secret_id, label=None, **kwargs): @property def secret_id(self): - # type: () -> str - self._validate() - return self.value['secret_uri'] + # type: () -> Optional[str] + try: + temp = json.loads(self.value) + return temp.get("secret_uri", None) + except json.decoder.JSONDecodeError: + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") @secret_id.setter def secret_id(self, secret_id): - if self.value is None or isinstance(self.value, dict): - if self.value is None: - self.value = {} - self.value["secret_uri"] = secret_id - else: - raise ValueError("Expect 'self.value' to be a dictionary.") - - def _validate(self): - # type: () -> None - if not (self.value is None or isinstance(self.value, dict)): - raise ValueError("Expect 'value' to be a dictionary or None.") + try: + temp = json.loads(self.value) + temp["secret_uri"] = secret_id + self.value = json.dumps(temp) + except json.decoder.JSONDecodeError: + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): # type: (KeyValue) -> SecretReferenceConfigurationSetting if key_value is None: return key_value - if key_value.value: - try: - key_value.value = json.loads(key_value.value) - except json.decoder.JSONDecodeError: - pass + # if key_value.value: + # try: + # key_value.value = json.loads(key_value.value) + # except json.decoder.JSONDecodeError: + # pass return cls( key=key_value.key, # type: ignore - # secret_uri=key_value.value[u"secret_uri"], # type: ignore value=key_value.value, label=key_value.label, secret_id=key_value.value, # type: ignore @@ -389,7 +387,7 @@ def _to_generated(self): return KeyValue( key=self.key, label=self.label, - value=json.dumps(self.value), + value=self.value, content_type=self.content_type, last_modified=self.last_modified, tags=self.tags, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index afedbe1a76c6..f9031fe97eee 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -38,10 +38,8 @@ import pytest import copy import datetime -import os -import logging +import json import re -import functools from uuid import uuid4 @@ -561,9 +559,10 @@ def test_config_setting_secret_reference(self, client): new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" updated_flag.secret_id = new_uri - assert updated_flag.value['secret_uri'] == new_uri + temp = json.loads(updated_flag.value) + assert temp['secret_uri'] == new_uri - updated_flag.value = {'secret_uri': new_uri2} + updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index af6e86755d09..c511eb2055f1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -33,10 +33,8 @@ import pytest import copy import datetime -import os -import logging +import json import re -import functools from wrapper import app_config_decorator @@ -549,9 +547,10 @@ def test_config_setting_secret_reference(self, client): new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" updated_flag.secret_id = new_uri - assert updated_flag.value['secret_uri'] == new_uri + temp = json.loads(updated_flag.value) + assert temp['secret_uri'] == new_uri - updated_flag.value = {'secret_uri': new_uri2} + updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 86d73fed66b0..d8317d423b91 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -33,9 +33,7 @@ import pytest import copy import datetime -import os -import logging -import asyncio +import json import re import copy @@ -555,9 +553,10 @@ def test_config_setting_secret_reference(self, client): new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" updated_flag.secret_id = new_uri - assert updated_flag.value['secret_uri'] == new_uri + temp = json.loads(updated_flag.value) + assert temp['secret_uri'] == new_uri - updated_flag.value = {'secret_uri': new_uri2} + updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 5334b1626e65..8f2f50cf034a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -34,11 +34,11 @@ import copy import datetime import os -import logging +import json import re -import functools import copy from uuid import uuid4 +import json from async_proxy import AzureAppConfigurationClientProxy from async_wrapper import app_config_decorator @@ -582,9 +582,10 @@ def test_config_setting_secret_reference(self, client): new_uri = "https://aka.ms/azsdk" new_uri2 = "https://aka.ms/azsdk/python" updated_flag.secret_id = new_uri - assert updated_flag.value['secret_uri'] == new_uri + temp = json.loads(updated_flag.value) + assert temp['secret_uri'] == new_uri - updated_flag.value = {'secret_uri': new_uri2} + updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 with pytest.raises(ValueError): From c73406b3ba5aa929f0bdf2c598f0aec9894d3460 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 10:32:02 -0400 Subject: [PATCH 36/60] fixed feature flag --- .../azure/appconfiguration/_models.py | 136 +++++++----------- .../tests/test_azure_configuration_client.py | 11 +- .../test_azure_configuration_client_aad.py | 12 +- ...st_azure_configuration_client_aad_async.py | 12 +- .../test_azure_configuration_client_async.py | 12 +- 5 files changed, 77 insertions(+), 106 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 4708e34141c8..b733d4740560 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -173,98 +173,79 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.etag = kwargs.get("etag", None) self.description = kwargs.get("description", None) self.display_name = kwargs.get("display_name", None) - # if "enabled" in kwargs.keys(): - # self.value = kwargs.get( - # "value", - # {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters", [])}} - # ) - # else: - # self.value = kwargs.get("value", {"conditions": {"client_filters": kwargs.pop("filters", [])}}) - - def _validate(self): - # type: () -> None - if not self.key.startswith(self.key_prefix): - raise ValueError("All FeatureFlagConfigurationSettings should be prefixed with {}.".format(self.key_prefix)) - if not (self.value is None or isinstance(self.value, dict)): - raise ValueError("Expect 'value' to be a dictionary.") + if not self.value: + if "enabled" in kwargs.keys() and "filters" in kwargs.keys(): + self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}}) + elif "enabled" in kwargs.keys(): + self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) + elif "filters" in kwargs.keys(): + self.value = json.dumps({"conditions": {"client_filters": []}}) @property def enabled(self): # type: () -> Union[None, bool] - self._validate() - if self.value is None or "enabled" not in self.value: - return None - return self.value["enabled"] + try: + temp = json.loads(self.value) + return temp.get("enabled", None) + except json.decoder.JSONDecodeError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") @enabled.setter def enabled(self, new_value): # type: (bool) -> None - self._validate() - if self.value is None: - self.value = {} - self.value["enabled"] = new_value + try: + temp = json.loads(self.value) + temp["enabled"] = new_value + self.value = json.dumps(temp) + except json.decoder.JSONDecodeError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") @property def filters(self): # type: () -> Union[None, List[Any]] try: - temp = json.dumps(self.value) - return temp.get("feature_filters", None) - except json.DecodeError: - raise ValueError - - self._validate() - if self.value is None: - return None - try: - return self.value["conditions"]["client_filters"] - except KeyError: - pass - return None + temp = json.loads(self.value) + conditions = temp.get("conditions", None) + if not conditions: + return None + try: + return conditions.get("client_filters", None) + except AttributeError: + return ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'client_filters' is expected to be a dictionary") + except json.decoder.JSONDecodeError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + @filters.setter def filters(self, new_filters): # type: (List[Dict[str, Any]]) -> None - temp = json.dumps(self.value) - temp["feature_filters"] = new_filters - # self._validate() - # if self.value is None: - # self.value = {} - # try: - # self.value["conditions"]["client_filters"] = new_filters - # except KeyError: - # self.value["conditions"] = { - # "client_filters": new_filters - # } + try: + temp = json.loads(self.value) + if "conditions" not in temp: + temp["conditions"] = {} + try: + temp["conditions"]["client_filters"] = new_filters + self.value = json.dumps(temp) + except AttributeError: + return ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'client_filters' is expected to be a dictionary") + except json.decoder.JSONDecodeError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): # type: (KeyValue) -> Union[FeatureFlagConfigurationSetting, ConfigurationSetting] - try: - if key_value is None: - return key_value - # if key_value.value: - # try: - # key_value.value = json.loads(key_value.value) - # except json.decoder.JSONDecodeError: - # pass - - # filters = key_value.value["conditions"]["client_filters"] # type: ignore - - return cls( - feature_id=key_value.key.lstrip(self._key_prefix), # type: ignore - # enabled=key_value.value["enabled"], # type: ignore - 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, - # filters=filters, # type: ignore - value=key_value.value, - ) - except (KeyError, AttributeError): - return ConfigurationSetting._from_generated(key_value) + if key_value is None: + return key_value + return cls( + feature_id=key_value.key.lstrip(".appconfig.featureflag").lstrip("/"), # type: ignore + 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, + value=key_value.value, + ) def _to_generated(self): # type: () -> KeyValue @@ -272,7 +253,7 @@ def _to_generated(self): return KeyValue( key=self.key, label=self.label, - value=json.dumps(self.value), + value=self.value, content_type=self.content_type, last_modified=self.last_modified, tags=self.tags, @@ -335,12 +316,6 @@ def __init__(self, key, secret_id, label=None, **kwargs): self.tags = kwargs.get("tags", {}) if not self.value: self.value = json.dumps({"secret_uri": secret_id}) - # if not self.value: - # self.value = {} - # if isinstance(self.value, dict) and "secret_uri" not in self.value.keys(): - # self.value["secret_uri"] = secret_id - # elif isinstance(self.value, six.string_types): - # self.value = {"secret_uri": self.value} @property def secret_id(self): @@ -365,11 +340,6 @@ def _from_generated(cls, key_value): # type: (KeyValue) -> SecretReferenceConfigurationSetting if key_value is None: return key_value - # if key_value.value: - # try: - # key_value.value = json.loads(key_value.value) - # except json.decoder.JSONDecodeError: - # pass return cls( key=key_value.key, # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index f9031fe97eee..1177854362d7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -528,16 +528,17 @@ def test_config_setting_feature_flag(self, client): changed_flag = client.set_configuration_setting(set_flag) changed_flag.enabled = False - assert changed_flag.value['enabled'] == False + temp = json.loads(changed_flag.value) + assert temp['enabled'] == False - c = copy.deepcopy(changed_flag.value) + c = json.loads(copy.deepcopy(changed_flag.value)) c['enabled'] = True - changed_flag.value = c + changed_flag.value = json.dumps(c) assert changed_flag.enabled == True - changed_flag.value = {} + changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == {} + assert changed_flag.value == json.dumps({}) with pytest.raises(ValueError): set_flag.value = "bad_value" diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index c511eb2055f1..ea15eb0b6ade 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -513,19 +513,19 @@ def test_config_setting_feature_flag(self, client): set_flag.enabled = not set_flag.enabled changed_flag = client.set_configuration_setting(set_flag) - self._assert_same_keys(set_flag, changed_flag) changed_flag.enabled = False - assert changed_flag.value['enabled'] == False + temp = json.loads(changed_flag.value) + assert temp['enabled'] == False - c = copy.deepcopy(changed_flag.value) + c = json.loads(copy.deepcopy(changed_flag.value)) c['enabled'] = True - changed_flag.value = c + changed_flag.value = json.dumps(c) assert changed_flag.enabled == True - changed_flag.value = {} + changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == {} + assert changed_flag.value == json.dumps({}) with pytest.raises(ValueError): set_flag.value = "bad_value" diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index d8317d423b91..3fb3b74ada7d 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -518,19 +518,19 @@ def test_config_setting_feature_flag(self, client): set_flag.enabled = not set_flag.enabled changed_flag = client.set_configuration_setting(set_flag) - self._assert_same_keys(set_flag, changed_flag) changed_flag.enabled = False - assert changed_flag.value['enabled'] == False + temp = json.loads(changed_flag.value) + assert temp['enabled'] == False - c = copy.deepcopy(changed_flag.value) + c = json.loads(copy.deepcopy(changed_flag.value)) c['enabled'] = True - changed_flag.value = c + changed_flag.value = json.dumps(c) assert changed_flag.enabled == True - changed_flag.value = {} + changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == {} + assert changed_flag.value == json.dumps({}) with pytest.raises(ValueError): set_flag.value = "bad_value" diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 8f2f50cf034a..fc591a850e8f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -547,19 +547,19 @@ def test_config_setting_feature_flag(self, client): set_flag.enabled = not set_flag.enabled changed_flag = client.set_configuration_setting(set_flag) - self._assert_same_keys(set_flag, changed_flag) changed_flag.enabled = False - assert changed_flag.value['enabled'] == False + temp = json.loads(changed_flag.value) + assert temp['enabled'] == False - c = copy.deepcopy(changed_flag.value) + c = json.loads(copy.deepcopy(changed_flag.value)) c['enabled'] = True - changed_flag.value = c + changed_flag.value = json.dumps(c) assert changed_flag.enabled == True - changed_flag.value = {} + changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == {} + assert changed_flag.value == json.dumps({}) with pytest.raises(ValueError): set_flag.value = "bad_value" From 4c87a304a1bd842606a242f6fb3d9c8a4b54a14e Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 10:50:34 -0400 Subject: [PATCH 37/60] fixed feature filter tests --- .../azure/appconfiguration/_models.py | 2 +- .../tests/test_consistency.py | 35 ++++--------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index b733d4740560..217f5b9502cd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -209,7 +209,7 @@ def filters(self): if not conditions: return None try: - return conditions.get("client_filters", None) + return conditions.get("client_filters", []) except AttributeError: return ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'client_filters' is expected to be a dictionary") except json.decoder.JSONDecodeError: diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index 6da079ae7d85..ffd49f02e97a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -3,39 +3,15 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.core import MatchConditions -from azure.core.exceptions import HttpResponseError -from devtools_testutils import AzureTestCase, PowerShellPreparer -from azure.core.exceptions import ( - ResourceModifiedError, - ResourceNotFoundError, - ResourceExistsError, - AzureError, -) +from devtools_testutils import AzureTestCase from azure.appconfiguration import ( - ResourceReadOnlyError, - AzureAppConfigurationClient, - ConfigurationSetting, FeatureFlagConfigurationSetting, SecretReferenceConfigurationSetting, PERCENTAGE, - TARGETING, - TIME_WINDOW, -) -from azure.identity import DefaultAzureCredential - -from consts import ( - KEY, - LABEL, - TEST_VALUE, - TEST_CONTENT_TYPE, - LABEL_RESERVED_CHARS, - PAGE_SIZE, - KEY_UUID, ) from wrapper import app_config_decorator -from uuid import uuid4 +import json import pytest @@ -112,7 +88,7 @@ def test_feature_flag_invalid_json(self, client): set_flag.value = [] received = client.set_configuration_setting(set_flag) - assert not isinstance(received, FeatureFlagConfigurationSetting) + assert isinstance(received, FeatureFlagConfigurationSetting) @app_config_decorator def test_feature_flag_invalid_json_string(self, client): @@ -123,7 +99,7 @@ def test_feature_flag_invalid_json_string(self, client): set_flag.value = "hello world" received = client.set_configuration_setting(set_flag) - assert not isinstance(received, FeatureFlagConfigurationSetting) + assert isinstance(received, FeatureFlagConfigurationSetting) @app_config_decorator def test_feature_flag_invalid_json_access_properties(self, client): @@ -180,7 +156,8 @@ def test_feature_flag_set_enabled(self, client): ) feature_flag.enabled = False - assert feature_flag.value["enabled"] == False + temp = json.loads(feature_flag.value) + assert temp["enabled"] == False @app_config_decorator def test_feature_flag_prefix(self, client): From 1ba6c4cd5c751d98fdc0aac30c4da35ced3c1643 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 11:23:15 -0400 Subject: [PATCH 38/60] mypy and pylint fixes --- .../azure/appconfiguration/_models.py | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 217f5b9502cd..95ff1a96f635 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -3,8 +3,6 @@ # Licensed under the MIT License. # ------------------------------------ import json -from json.decoder import JSONDecodeError -import six from typing import Dict, Optional, Any, List, Union from msrest.serialization import Model from ._generated.models import KeyValue @@ -188,7 +186,8 @@ def enabled(self): temp = json.loads(self.value) return temp.get("enabled", None) except json.decoder.JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @enabled.setter def enabled(self, new_value): @@ -198,7 +197,8 @@ def enabled(self, new_value): temp["enabled"] = new_value self.value = json.dumps(temp) except json.decoder.JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @property def filters(self): @@ -211,9 +211,11 @@ def filters(self): try: return conditions.get("client_filters", []) except AttributeError: - return ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'client_filters' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ + " 'client_filters' is expected to be a dictionary") except json.decoder.JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @filters.setter @@ -227,9 +229,11 @@ def filters(self, new_filters): temp["conditions"]["client_filters"] = new_filters self.value = json.dumps(temp) except AttributeError: - return ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'client_filters' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ + " 'client_filters' is expected to be a dictionary") except json.decoder.JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): @@ -324,7 +328,8 @@ def secret_id(self): temp = json.loads(self.value) return temp.get("secret_uri", None) except json.decoder.JSONDecodeError: - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @secret_id.setter def secret_id(self, secret_id): @@ -333,7 +338,8 @@ def secret_id(self, secret_id): temp["secret_uri"] = secret_id self.value = json.dumps(temp) except json.decoder.JSONDecodeError: - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. 'value' is expected to be a dictionary") + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): From 813baad83b7e19b19b451b6bd5c080e5ca3425b3 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 11:38:21 -0400 Subject: [PATCH 39/60] updating tests --- .../tests/test_azure_configuration_client.py | 32 +++++++++++++++++-- .../test_azure_configuration_client_aad.py | 32 +++++++++++++++++-- ...st_azure_configuration_client_aad_async.py | 32 +++++++++++++++++-- .../test_azure_configuration_client_async.py | 32 +++++++++++++++++-- 4 files changed, 120 insertions(+), 8 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 1177854362d7..b7bb57f791c0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -601,7 +601,8 @@ def test_feature_filter_targeting(self, client): updated_sent_config = client.set_configuration_setting(sent_config) self._assert_same_keys(sent_config, updated_sent_config) - updated_sent_config.filters.append( + filters = updated_sent_config.filters + filters.append( { "name": TARGETING, "parameters": { @@ -613,7 +614,8 @@ def test_feature_filter_targeting(self, client): } } ) - updated_sent_config.filters.append( + + filters.append( { "name": TARGETING, "parameters": { @@ -625,6 +627,7 @@ def test_feature_filter_targeting(self, client): } } ) + updated_sent_config.filters = filters sent_config = client.set_configuration_setting(updated_sent_config) self._assert_same_keys(sent_config, updated_sent_config) @@ -657,6 +660,31 @@ def test_feature_filter_time_window(self, client): client.delete_configuration_setting(new_sent.key) + @app_config_decorator + def test_feature_filter_time_window(self, client): + new = FeatureFlagConfigurationSetting( + 'time_window', + enabled=True, + filters=[ + { + "name": TIME_WINDOW, + "parameters": { + "Start": "Wed, 10 Mar 2021 05:00:00 GMT", + "End": "Fri, 02 Apr 2021 04:00:00 GMT" + } + } + ] + ) + + sent = client.set_configuration_setting(new) + self._assert_same_keys(sent, new) + + sent.filters[0]["parameters"]["Start"] = "Thurs, 11 Mar 2021 05:00:00 GMT" + new_sent = client.set_configuration_setting(sent) + self._assert_same_keys(sent, new_sent) + + client.delete_configuration_setting(new_sent.key) + @app_config_decorator def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index ea15eb0b6ade..30b1e270f328 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -588,7 +588,8 @@ def test_feature_filter_targeting(self, client): updated_sent_config = client.set_configuration_setting(sent_config) self._assert_same_keys(sent_config, updated_sent_config) - updated_sent_config.filters.append( + filters = updated_sent_config.filters + filters.append( { "name": TARGETING, "parameters": { @@ -600,7 +601,8 @@ def test_feature_filter_targeting(self, client): } } ) - updated_sent_config.filters.append( + + filters.append( { "name": TARGETING, "parameters": { @@ -612,6 +614,7 @@ def test_feature_filter_targeting(self, client): } } ) + updated_sent_config.filters = filters sent_config = client.set_configuration_setting(updated_sent_config) self._assert_same_keys(sent_config, updated_sent_config) @@ -644,6 +647,31 @@ def test_feature_filter_time_window(self, client): client.delete_configuration_setting(new_sent.key) + @app_config_decorator + def test_feature_filter_time_window(self, client): + new = FeatureFlagConfigurationSetting( + 'time_window', + enabled=True, + filters=[ + { + "name": TIME_WINDOW, + "parameters": { + "Start": "Wed, 10 Mar 2021 05:00:00 GMT", + "End": "Fri, 02 Apr 2021 04:00:00 GMT" + } + } + ] + ) + + sent = client.set_configuration_setting(new) + self._assert_same_keys(sent, new) + + sent.filters[0]["parameters"]["Start"] = "Thurs, 11 Mar 2021 05:00:00 GMT" + new_sent = client.set_configuration_setting(sent) + self._assert_same_keys(sent, new_sent) + + client.delete_configuration_setting(new_sent.key) + @app_config_decorator def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 3fb3b74ada7d..55e0c73ea352 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -594,7 +594,8 @@ def test_feature_filter_targeting(self, client): updated_sent_config = client.set_configuration_setting(sent_config) self._assert_same_keys(sent_config, updated_sent_config) - updated_sent_config.filters.append( + filters = updated_sent_config.filters + filters.append( { "name": TARGETING, "parameters": { @@ -606,7 +607,8 @@ def test_feature_filter_targeting(self, client): } } ) - updated_sent_config.filters.append( + + filters.append( { "name": TARGETING, "parameters": { @@ -618,6 +620,7 @@ def test_feature_filter_targeting(self, client): } } ) + updated_sent_config.filters = filters sent_config = client.set_configuration_setting(updated_sent_config) self._assert_same_keys(sent_config, updated_sent_config) @@ -650,6 +653,31 @@ def test_feature_filter_time_window(self, client): client.delete_configuration_setting(new_sent.key) + @app_config_decorator + def test_feature_filter_time_window(self, client): + new = FeatureFlagConfigurationSetting( + 'time_window', + enabled=True, + filters=[ + { + "name": TIME_WINDOW, + "parameters": { + "Start": "Wed, 10 Mar 2021 05:00:00 GMT", + "End": "Fri, 02 Apr 2021 04:00:00 GMT" + } + } + ] + ) + + sent = client.set_configuration_setting(new) + self._assert_same_keys(sent, new) + + sent.filters[0]["parameters"]["Start"] = "Thurs, 11 Mar 2021 05:00:00 GMT" + new_sent = client.set_configuration_setting(sent) + self._assert_same_keys(sent, new_sent) + + client.delete_configuration_setting(new_sent.key) + @app_config_decorator def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index fc591a850e8f..b47a83707bc7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -623,7 +623,8 @@ def test_feature_filter_targeting(self, client): updated_sent_config = client.set_configuration_setting(sent_config) self._assert_same_keys(sent_config, updated_sent_config) - updated_sent_config.filters.append( + filters = updated_sent_config.filters + filters.append( { "name": TARGETING, "parameters": { @@ -635,7 +636,8 @@ def test_feature_filter_targeting(self, client): } } ) - updated_sent_config.filters.append( + + filters.append( { "name": TARGETING, "parameters": { @@ -647,6 +649,7 @@ def test_feature_filter_targeting(self, client): } } ) + updated_sent_config.filters = filters sent_config = client.set_configuration_setting(updated_sent_config) self._assert_same_keys(sent_config, updated_sent_config) @@ -679,6 +682,31 @@ def test_feature_filter_time_window(self, client): client.delete_configuration_setting(new_sent.key) + @app_config_decorator + def test_feature_filter_time_window(self, client): + new = FeatureFlagConfigurationSetting( + 'time_window', + enabled=True, + filters=[ + { + "name": TIME_WINDOW, + "parameters": { + "Start": "Wed, 10 Mar 2021 05:00:00 GMT", + "End": "Fri, 02 Apr 2021 04:00:00 GMT" + } + } + ] + ) + + sent = client.set_configuration_setting(new) + self._assert_same_keys(sent, new) + + sent.filters[0]["parameters"]["Start"] = "Thurs, 11 Mar 2021 05:00:00 GMT" + new_sent = client.set_configuration_setting(sent) + self._assert_same_keys(sent, new_sent) + + client.delete_configuration_setting(new_sent.key) + @app_config_decorator def test_feature_filter_custom(self, client): new = FeatureFlagConfigurationSetting( From 8825de1fbc9c1b0de31b9b4bdd42e28ceb197f67 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 12:26:13 -0400 Subject: [PATCH 40/60] fixes --- .../appconfiguration/_azure_appconfiguration_client.py | 6 +++--- .../aio/_azure_configuration_client_async.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index d4a21535bb6b..a4a06f425b71 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -405,7 +405,7 @@ def delete_configuration_setting(self, *args, **kwargs): :param str key: key used to identify the ConfigurationSetting :param configuration-setting: ConfigurationSetting to be deleted :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :keyword str label: label used to identify the ConfigurationSetting + :param str label: label used to identify the ConfigurationSetting :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` @@ -424,8 +424,8 @@ def delete_configuration_setting(self, *args, **kwargs): key="MyKey", label="MyLabel" ) """ - key = kwargs.pop("key", None) - label = kwargs.pop("label", None) + key = None + label = None etag = kwargs.pop("etag", None) if len(args) > 0: if isinstance(args[0], ConfigurationSetting): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 7168d80430a8..2b8f076e5e3e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -440,7 +440,7 @@ async def delete_configuration_setting( :param str key: key used to identify the ConfigurationSetting :param configuration-setting: ConfigurationSetting to be deleted :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :keyword str label: label used to identify the ConfigurationSetting + :param str label: label used to identify the ConfigurationSetting :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` @@ -460,8 +460,8 @@ async def delete_configuration_setting( key="MyKey", label="MyLabel" ) """ - key = kwargs.pop("key", None) - label = kwargs.pop("label", None) + key = None + label = None etag = kwargs.pop("etag", None) if len(args) > 0: if isinstance(args[0], ConfigurationSetting): From fd6e205b56bddb976498d44be85b91c9e39448f0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 14:13:40 -0400 Subject: [PATCH 41/60] remove overload --- .../_azure_appconfiguration_client.py | 23 +--------------- .../aio/_azure_configuration_client_async.py | 26 +------------------ .../tests/test_azure_configuration_client.py | 7 ----- .../test_azure_configuration_client_async.py | 7 ----- 4 files changed, 2 insertions(+), 61 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index a4a06f425b71..e575a5a87a87 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -387,19 +387,9 @@ def set_configuration_setting( except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") - @overload + @distributed_trace def delete_configuration_setting(self, key, label=None, **kwargs): # type: (str, Optional[str], **Any) -> ConfigurationSetting - pass - - @overload - def delete_configuration_setting(self, configuration_setting, **kwargs): - # type: (ConfigurationSetting, **Any) -> ConfigurationSetting - pass - - @distributed_trace - def delete_configuration_setting(self, *args, **kwargs): - # type: (Union[str, ConfigurationSetting], **Any) -> ConfigurationSetting """Delete a ConfigurationSetting if it exists :param str key: key used to identify the ConfigurationSetting @@ -424,18 +414,7 @@ def delete_configuration_setting(self, *args, **kwargs): key="MyKey", label="MyLabel" ) """ - key = None - label = None etag = kwargs.pop("etag", None) - if len(args) > 0: - if isinstance(args[0], ConfigurationSetting): - key = args[0].key - label = args[0].label - etag = args[0].etag if not None else etag - else: - key = args[0] - if len(args) == 2: - label = args[1] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index 2b8f076e5e3e..a3199ff1d244 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -413,27 +413,12 @@ async def set_configuration_setting( except binascii.Error: raise binascii.Error("Connection string secret has incorrect padding") - @overload + @distributed_trace_async async def delete_configuration_setting( self, key: str, label: Optional[str] = None, **kwargs: Any - ) -> ConfigurationSetting: - ... - - @overload - async def delete_configuration_setting(self, - configuration_setting: ConfigurationSetting, - **kwargs: Any - ) -> ConfigurationSetting: - ... - - @distributed_trace_async - async def delete_configuration_setting( - self, - *args: Union[str, ConfigurationSetting], - **kwargs: Any ) -> ConfigurationSetting: """Delete a ConfigurationSetting if it exists @@ -460,16 +445,7 @@ async def delete_configuration_setting( key="MyKey", label="MyLabel" ) """ - key = None - label = None etag = kwargs.pop("etag", None) - if len(args) > 0: - if isinstance(args[0], ConfigurationSetting): - key = args[0].key - label = args[0].label - etag = args[0].etag if not None else etag - else: - key = args[0] match_condition = kwargs.pop("match_condition", MatchConditions.Unconditionally) custom_headers = CaseInsensitiveDict(kwargs.get("headers")) # type: Mapping[str, Any] error_map = {401: ClientAuthenticationError, 409: ResourceReadOnlyError} diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 4a179b2a769d..b7bb57f791c0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -235,13 +235,6 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri to_delete_kv.key, label=to_delete_kv.label ) - @app_config_decorator - def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): - to_delete_kv = test_config_setting_no_label - client.delete_configuration_setting(to_delete_kv) - with pytest.raises(ResourceNotFoundError): - client.get_configuration_setting(to_delete_kv.key) - @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): to_delete_kv = test_config_setting diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 9b92d4af3445..b47a83707bc7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -189,13 +189,6 @@ def test_delete_with_key_no_label(self, client, appconfiguration_connection_stri with pytest.raises(ResourceNotFoundError): client.get_configuration_setting(to_delete_kv.key) - @app_config_decorator - def test_delete_with_configuration_setting(self, client, test_config_setting_no_label): - to_delete_kv = test_config_setting_no_label - client.delete_configuration_setting(to_delete_kv) - with pytest.raises(ResourceNotFoundError): - client.get_configuration_setting(to_delete_kv.key) - @app_config_decorator def test_delete_with_key_label(self, client, appconfiguration_connection_string, test_config_setting, test_config_setting_no_label): to_delete_kv = test_config_setting From 1e844a7c61317f87428b05cfbe53553c9ed02684 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 14:14:51 -0400 Subject: [PATCH 42/60] fixing changelog --- sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index 33f80e53a32c..d846fe241f43 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -2,15 +2,9 @@ ## 1.2.0b3 (Unreleased) ### Features Added -<<<<<<< HEAD ### Breaking Changes -======= -* `delete_configuration_setting` now takes either the string `key` or a `ConfigurationSetting` object. -### Breaking Changes - ->>>>>>> b2c245025d865bd4b8276fcd2debe981c45963aa ### Key Bugs Fixed ### Fixed From 42421123fa864fe6192cf1b98e8f234cad554e28 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 14:20:07 -0400 Subject: [PATCH 43/60] fixing docstrings --- .../_azure_appconfiguration_client.py | 8 +- .../azure/appconfiguration/_models.py | 2 + .../aio/_azure_configuration_client_async.py | 8 +- ...est_delete_with_configuration_setting.yaml | 492 ------------------ ...est_delete_with_configuration_setting.yaml | 492 ------------------ 5 files changed, 10 insertions(+), 992 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml delete mode 100644 sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index e575a5a87a87..0e7c2f194664 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -392,10 +392,10 @@ def delete_configuration_setting(self, key, label=None, **kwargs): # type: (str, Optional[str], **Any) -> ConfigurationSetting """Delete a ConfigurationSetting if it exists - :param str key: key used to identify the ConfigurationSetting - :param configuration-setting: ConfigurationSetting to be deleted - :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :param str label: label used to identify the ConfigurationSetting + :param key: key used to identify the ConfigurationSetting + :type key: str + :param label: label used to identify the ConfigurationSetting + :type label: str :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 95ff1a96f635..9f5f7f03ec25 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -178,6 +178,8 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) elif "filters" in kwargs.keys(): self.value = json.dumps({"conditions": {"client_filters": []}}) + else: + self.value = json.dumps({}) @property def enabled(self): diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index a3199ff1d244..ebe289f418d1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -422,10 +422,10 @@ async def delete_configuration_setting( ) -> ConfigurationSetting: """Delete a ConfigurationSetting if it exists - :param str key: key used to identify the ConfigurationSetting - :param configuration-setting: ConfigurationSetting to be deleted - :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :param str label: label used to identify the ConfigurationSetting + :param key: key used to identify the ConfigurationSetting + :type key: str + :param label: label used to identify the ConfigurationSetting + :type label: str :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml deleted file mode 100644 index 7ba384f50716..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_delete_with_configuration_setting.yaml +++ /dev/null @@ -1,492 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:42.462825 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"items":[]}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODYz;sn=9440863 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "label": - "test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309", "content_type": "test content - type", "value": "test value", "tags": {"tag1": "tag1", "tag2": "tag2"}}' - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '231' - Content-Type: - - application/vnd.microsoft.appconfig.kv+json - If-None-Match: - - '*' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODYz - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= - x-ms-date: - - Jun, 22 2021 15:41:43.034011 GMT - method: PUT - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - etag: - - '"DeJ0uxOCy6WQFQmWEEV3pPzZmog"' - last-modified: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY0;sn=9440864 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY0 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.182697 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 - response: - body: - string: '{"items":[{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}]}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY0;sn=9440864 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY0 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.312653 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -- request: - body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "content_type": - "test content type", "value": "test value", "tags": {"tag1": "tag1", "tag2": - "tag2"}}' - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '170' - Content-Type: - - application/vnd.microsoft.appconfig.kv+json - If-None-Match: - - '*' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY0 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= - x-ms-date: - - Jun, 22 2021 15:41:43.444692 GMT - method: PUT - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '{"etag":"0cOKAAGr1cSbx4zvam8Stj5hyyA","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - etag: - - '"0cOKAAGr1cSbx4zvam8Stj5hyyA"' - last-modified: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY1;sn=9440865 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY1 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.579818 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '{"etag":"0cOKAAGr1cSbx4zvam8Stj5hyyA","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:44 GMT - etag: - - '"0cOKAAGr1cSbx4zvam8Stj5hyyA"' - last-modified: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY2;sn=9440866 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY2 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.722785 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-length: - - '0' - date: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 404 - message: Not Found -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY2 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.855794 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"etag":"DeJ0uxOCy6WQFQmWEEV3pPzZmog","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:44+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:45 GMT - etag: - - '"DeJ0uxOCy6WQFQmWEEV3pPzZmog"' - last-modified: - - Tue, 22 Jun 2021 15:41:44 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY3;sn=9440867 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY3 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:43.994362 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:45 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -version: 1 diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml deleted file mode 100644 index 98e7dd72ec9c..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client_async.test_delete_with_configuration_setting.yaml +++ /dev/null @@ -1,492 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:44.200852 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"items":[]}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:45 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY3;sn=9440867 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "label": - "test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309", "content_type": "test content - type", "value": "test value", "tags": {"tag1": "tag1", "tag2": "tag2"}}' - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '231' - Content-Type: - - application/vnd.microsoft.appconfig.kv+json - If-None-Match: - - '*' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY3 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= - x-ms-date: - - Jun, 22 2021 15:41:44.728991 GMT - method: PUT - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - etag: - - '"NoWRLVki4rC6Y4WJnSuFLdxrHWx"' - last-modified: - - Tue, 22 Jun 2021 15:41:45 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY4;sn=9440868 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY4 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:44.881090 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 - response: - body: - string: '{"items":[{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}]}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY4;sn=9440868 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY4 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:45.012249 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -- request: - body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "content_type": - "test content type", "value": "test value", "tags": {"tag1": "tag1", "tag2": - "tag2"}}' - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '170' - Content-Type: - - application/vnd.microsoft.appconfig.kv+json - If-None-Match: - - '*' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY4 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= - x-ms-date: - - Jun, 22 2021 15:41:45.140103 GMT - method: PUT - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '{"etag":"Rivwo9kzUniW0UnKsK1xRMWYe0l","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:46+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - etag: - - '"Rivwo9kzUniW0UnKsK1xRMWYe0l"' - last-modified: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODY5;sn=9440869 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODY5 - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:45.282068 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '{"etag":"Rivwo9kzUniW0UnKsK1xRMWYe0l","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:46+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - etag: - - '"Rivwo9kzUniW0UnKsK1xRMWYe0l"' - last-modified: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODcw;sn=9440870 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODcw - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:45.415107 GMT - method: GET - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-length: - - '0' - date: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 404 - message: Not Found -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODcw - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:45.544070 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 - response: - body: - string: '{"etag":"NoWRLVki4rC6Y4WJnSuFLdxrHWx","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test - content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-22T15:41:45+00:00"}' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - etag: - - '"NoWRLVki4rC6Y4WJnSuFLdxrHWx"' - last-modified: - - Tue, 22 Jun 2021 15:41:45 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - sync-token: - - zAJw6V16=MDoxNyM5NDQwODcx;sn=9440871 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Sync-Token: - - zAJw6V16=MDoxNyM5NDQwODcx - User-Agent: - - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) - x-ms-content-sha256: - - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= - x-ms-date: - - Jun, 22 2021 15:41:45.692068 GMT - method: DELETE - uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 - response: - body: - string: '' - headers: - access-control-allow-credentials: - - 'true' - access-control-allow-origin: - - '*' - access-control-expose-headers: - - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, - Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, - x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, - If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, - Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, - x-ms-effective-locale, WWW-Authenticate - connection: - - keep-alive - content-type: - - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 - date: - - Tue, 22 Jun 2021 15:41:46 GMT - server: - - openresty/1.17.8.2 - strict-transport-security: - - max-age=15724800; includeSubDomains - status: - code: 204 - message: No Content -version: 1 From 675a9262ee01edba848ca380d3aef61606af05bf Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 23 Jun 2021 15:44:11 -0400 Subject: [PATCH 44/60] fixing attribute map --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 9f5f7f03ec25..128a55e76578 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -144,9 +144,9 @@ class FeatureFlagConfigurationSetting( _attribute_map = { "etag": {"key": "etag", "type": "str"}, - "feature_id": {"key": "key", "type": "str"}, + "feature_id": {"key": "feaure_id", "type": "str"}, "label": {"key": "label", "type": "str"}, - "content_type": {"key": "content_type", "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"}, From 2cc0ed47fb3ee4f28da0a7094532cea9802b4cfc Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 24 Jun 2021 12:37:42 -0400 Subject: [PATCH 45/60] fixing for py2.7 --- .../_azure_appconfiguration_client.py | 2 +- .../azure/appconfiguration/_models.py | 47 +++++++++++++++---- .../aio/_azure_configuration_client_async.py | 2 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 0e7c2f194664..140b7146364e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Optional, Any, Union, Mapping, overload, TYPE_CHECKING +from typing import Optional, Any, Union, Mapping, TYPE_CHECKING from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.pipeline import Pipeline diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 128a55e76578..3a9ebc0f3ee8 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -7,6 +7,11 @@ from msrest.serialization import Model from ._generated.models import KeyValue +try: + from json.decoder import JSONDecodeError +except ImportError: + JSONDecodeError = None + PolymorphicConfigurationSetting = Union[ "ConfigurationSetting", "SecretReferenceConfigurationSetting", "FeatureFlagConfigurationSetting" @@ -173,7 +178,9 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.display_name = kwargs.get("display_name", None) if not self.value: if "enabled" in kwargs.keys() and "filters" in kwargs.keys(): - self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}}) + self.value = json.dumps( + {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}} + ) elif "enabled" in kwargs.keys(): self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) elif "filters" in kwargs.keys(): @@ -187,7 +194,10 @@ def enabled(self): try: temp = json.loads(self.value) return temp.get("enabled", None) - except json.decoder.JSONDecodeError: + except ValueError: # Note: Python 2.7 exception + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") + except JSONDecodeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -198,7 +208,10 @@ def enabled(self, new_value): temp = json.loads(self.value) temp["enabled"] = new_value self.value = json.dumps(temp) - except json.decoder.JSONDecodeError: + except ValueError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") + except JSONDecodeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -206,7 +219,12 @@ def enabled(self, new_value): def filters(self): # type: () -> Union[None, List[Any]] try: - temp = json.loads(self.value) + temp = None + try: + temp = json.loads(self.value) + except ValueError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") conditions = temp.get("conditions", None) if not conditions: return None @@ -215,7 +233,7 @@ def filters(self): except AttributeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ " 'client_filters' is expected to be a dictionary") - except json.decoder.JSONDecodeError: + except JSONDecodeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -224,7 +242,12 @@ def filters(self): def filters(self, new_filters): # type: (List[Dict[str, Any]]) -> None try: - temp = json.loads(self.value) + temp = None + try: + temp = json.loads(self.value) + except ValueError: + raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") if "conditions" not in temp: temp["conditions"] = {} try: @@ -233,7 +256,7 @@ def filters(self, new_filters): except AttributeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ " 'client_filters' is expected to be a dictionary") - except json.decoder.JSONDecodeError: + except JSONDecodeError: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -329,7 +352,10 @@ def secret_id(self): try: temp = json.loads(self.value) return temp.get("secret_uri", None) - except json.decoder.JSONDecodeError: + except ValueError: + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") + except JSONDecodeError: raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -339,7 +365,10 @@ def secret_id(self, secret_id): temp = json.loads(self.value) temp["secret_uri"] = secret_id self.value = json.dumps(temp) - except json.decoder.JSONDecodeError: + except ValueError: + raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + "'value' is expected to be a dictionary") + except JSONDecodeError: raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index ebe289f418d1..e9a499157370 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- import binascii -from typing import Dict, Any, Optional, Mapping, Union, overload, TYPE_CHECKING +from typing import Dict, Any, Optional, Mapping, Union, TYPE_CHECKING from requests.structures import CaseInsensitiveDict from azure.core import MatchConditions from azure.core.async_paging import AsyncItemPaged From d526af61b0b499f857207561deca7409b52d9681 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 24 Jun 2021 13:14:57 -0400 Subject: [PATCH 46/60] mypy, pylint, and py2.7 fixes --- .../azure/appconfiguration/_models.py | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 3a9ebc0f3ee8..54de89a00505 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -10,7 +10,7 @@ try: from json.decoder import JSONDecodeError except ImportError: - JSONDecodeError = None + JSONDecodeError = None # type: ignore PolymorphicConfigurationSetting = Union[ @@ -194,10 +194,7 @@ def enabled(self): try: temp = json.loads(self.value) return temp.get("enabled", None) - except ValueError: # Note: Python 2.7 exception - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - except JSONDecodeError: + except (JSONDecodeError, ValueError) as exc: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -208,10 +205,7 @@ def enabled(self, new_value): temp = json.loads(self.value) temp["enabled"] = new_value self.value = json.dumps(temp) - except ValueError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - except JSONDecodeError: + except (JSONDecodeError, ValueError) as exc: raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -352,10 +346,7 @@ def secret_id(self): try: temp = json.loads(self.value) return temp.get("secret_uri", None) - except ValueError: - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - except JSONDecodeError: + except (JSONDecodeError, ValueError) as exc: raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -365,10 +356,7 @@ def secret_id(self, secret_id): temp = json.loads(self.value) temp["secret_uri"] = secret_id self.value = json.dumps(temp) - except ValueError: - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - except JSONDecodeError: + except (JSONDecodeError, ValueError) as exc: raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") From 218aaa9b729d8b6932f8c627b84b12f3c27aecca Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 24 Jun 2021 13:51:08 -0400 Subject: [PATCH 47/60] pylint fix --- .../azure/appconfiguration/_models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 54de89a00505..6f99c3a7d389 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -194,7 +194,7 @@ def enabled(self): try: temp = json.loads(self.value) return temp.get("enabled", None) - except (JSONDecodeError, ValueError) as exc: + except (JSONDecodeError, ValueError): raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -205,7 +205,7 @@ def enabled(self, new_value): temp = json.loads(self.value) temp["enabled"] = new_value self.value = json.dumps(temp) - except (JSONDecodeError, ValueError) as exc: + except (JSONDecodeError, ValueError): raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -346,7 +346,7 @@ def secret_id(self): try: temp = json.loads(self.value) return temp.get("secret_uri", None) - except (JSONDecodeError, ValueError) as exc: + except (JSONDecodeError, ValueError): raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") @@ -356,7 +356,7 @@ def secret_id(self, secret_id): temp = json.loads(self.value) temp["secret_uri"] = secret_id self.value = json.dumps(temp) - except (JSONDecodeError, ValueError) as exc: + except (JSONDecodeError, ValueError): raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") From 94114a78149022998e5a3512b48ceb85f1b25cd3 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 24 Jun 2021 17:12:55 -0400 Subject: [PATCH 48/60] renaming --- .../azure/appconfiguration/__init__.py | 8 ++--- .../_azure_appconfiguration_client.py | 8 +---- .../azure/appconfiguration/_constants.py | 6 ++-- .../azure/appconfiguration/_models.py | 7 ++-- .../aio/_azure_configuration_client_async.py | 8 +---- .../tests/test_azure_configuration_client.py | 36 +++++++++---------- .../test_azure_configuration_client_aad.py | 24 ++++++------- ...st_azure_configuration_client_aad_async.py | 24 ++++++------- .../test_azure_configuration_client_async.py | 28 +++++++-------- .../tests/test_consistency.py | 8 ++--- 10 files changed, 72 insertions(+), 85 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py index 2f4f1e31d339..aa7c98bd603f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/__init__.py @@ -10,7 +10,7 @@ # -------------------------------------------------------------------------- from ._azure_appconfiguration_client import AzureAppConfigurationClient -from ._constants import PERCENTAGE, TARGETING, TIME_WINDOW +from ._constants import FILTER_PERCENTAGE, FILTER_TARGETING, FILTER_TIME_WINDOW from ._models import ( ConfigurationSetting, FeatureFlagConfigurationSetting, @@ -26,7 +26,7 @@ "ResourceReadOnlyError", "FeatureFlagConfigurationSetting", "SecretReferenceConfigurationSetting", - "PERCENTAGE", - "TARGETING", - "TIME_WINDOW", + "FILTER_PERCENTAGE", + "FILTER_TARGETING", + "FILTER_TIME_WINDOW", ] diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py index 140b7146364e..d31fd0c0faf7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py @@ -166,7 +166,6 @@ def list_configuration_settings( :type label_filter: str :keyword datetime accept_datetime: filter out ConfigurationSetting created after this datetime :keyword list[str] fields: specify which fields to include in the results. Leave None to include all fields - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: An iterator of :class:`ConfigurationSetting` :rtype: ~azure.core.paging.ItemPaged[ConfigurationSetting] :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError` @@ -231,7 +230,6 @@ def get_configuration_setting( :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` :keyword datetime accept_datetime: the retrieved ConfigurationSetting that created no later than this datetime - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The matched ConfigurationSetting object :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ @@ -281,7 +279,6 @@ def add_configuration_setting(self, configuration_setting, **kwargs): :param configuration_setting: the ConfigurationSetting object to be added :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The ConfigurationSetting object returned from the App Configuration service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, :class:`ResourceExistsError` @@ -335,7 +332,6 @@ def set_configuration_setting( :type configuration_setting: :class:`ConfigurationSetting` :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` @@ -399,7 +395,6 @@ def delete_configuration_setting(self, key, label=None, **kwargs): :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request :return: The deleted ConfigurationSetting returned from the service, or None if it doesn't exist. :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ @@ -457,7 +452,6 @@ def list_revisions(self, key_filter=None, label_filter=None, **kwargs): :type label_filter: str :keyword datetime accept_datetime: filter out ConfigurationSetting created after this datetime :keyword list[str] fields: specify which fields to include in the results. Leave None to include all fields - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: An iterator of :class:`ConfigurationSetting` :rtype: ~azure.core.paging.ItemPaged[ConfigurationSetting] :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError` @@ -514,7 +508,7 @@ def set_read_only(self, configuration_setting, read_only=True, **kwargs): :type read_only: bool :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header + :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, :class:`ResourceNotFoundError` diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py index 3124b7d59611..a0d12656de30 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_constants.py @@ -4,8 +4,8 @@ # license information. # -------------------------------------------------------------------------- -TIME_WINDOW = u"Microsoft.TimeWindow" +FILTER_TIME_WINDOW = u"Microsoft.TimeWindow" -PERCENTAGE = u"Microsoft.Percentage" +FILTER_PERCENTAGE = u"Microsoft.Percentage" -TARGETING = u"Microsoft.Targeting" +FILTER_TARGETING = u"Microsoft.Targeting" diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 6f99c3a7d389..4ac8f34e172e 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -76,7 +76,7 @@ def _from_generated(cls, key_value): try: if key_value.content_type.startswith( FeatureFlagConfigurationSetting._feature_flag_content_type # pylint:disable=protected-access - ) and key_value.key.startswith(FeatureFlagConfigurationSetting.key_prefix): # type: ignore + ) and key_value.key.startswith(FeatureFlagConfigurationSetting._key_prefix): # type: ignore return FeatureFlagConfigurationSetting._from_generated( # pylint: disable=protected-access key_value ) @@ -157,7 +157,7 @@ class FeatureFlagConfigurationSetting( "read_only": {"key": "read_only", "type": "bool"}, "tags": {"key": "tags", "type": "{str}"}, } - key_prefix = ".appconfig.featureflag/" + _key_prefix = ".appconfig.featureflag/" _feature_flag_content_type = ( "application/vnd.microsoft.appconfig.ff+json;charset=utf-8" ) @@ -167,7 +167,7 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v # type: (str, **Any) -> None super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id - self.key = self.key_prefix + self.feature_id + self.key = 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) @@ -231,7 +231,6 @@ def filters(self): raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ "'value' is expected to be a dictionary") - @filters.setter def filters(self, new_filters): # type: (List[Dict[str, Any]]) -> None diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py index e9a499157370..b2ee7f98dd24 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/aio/_azure_configuration_client_async.py @@ -182,7 +182,6 @@ def list_configuration_settings( :type label_filter: str :keyword datetime accept_datetime: filter out ConfigurationSetting created after this datetime :keyword list[str] fields: specify which fields to include in the results. Leave None to include all fields - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: An iterator of :class:`ConfigurationSetting` :rtype: ~azure.core.async_paging.AsyncItemPaged[ConfigurationSetting] :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError` @@ -248,7 +247,6 @@ async def get_configuration_setting( :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` :keyword datetime accept_datetime: the retrieved ConfigurationSetting that created no later than this datetime - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The matched ConfigurationSetting object :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ @@ -302,7 +300,6 @@ async def add_configuration_setting( :param configuration_setting: the ConfigurationSetting object to be added :type configuration_setting: :class:`~azure.appconfiguration.ConfigurationSetting` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: The ConfigurationSetting object returned from the App Configuration service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, :class:`ResourceExistsError` @@ -358,7 +355,6 @@ async def set_configuration_setting( :type configuration_setting: :class:`ConfigurationSetting` :param match_condition: The match condition to use upon the etag :type match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` @@ -429,7 +425,6 @@ async def delete_configuration_setting( :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request :return: The deleted ConfigurationSetting returned from the service, or None if it doesn't exist. :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, \ @@ -489,7 +484,6 @@ def list_revisions( :type label_filter: str :keyword datetime accept_datetime: filter out ConfigurationSetting created after this datetime :keyword list[str] fields: specify which fields to include in the results. Leave None to include all fields - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header :return: An iterator of :class:`ConfigurationSetting` :rtype: ~azure.core.async_paging.AsyncItemPaged[ConfigurationSetting] :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError` @@ -548,7 +542,7 @@ async def set_read_only( :type read_only: bool :keyword match_condition: The match condition to use upon the etag :paramtype match_condition: :class:`~azure.core.MatchConditions` - :keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header + :keyword str etag: check if the ConfigurationSetting is changed. Set None to skip checking etag :return: The ConfigurationSetting returned from the service :rtype: :class:`~azure.appconfiguration.ConfigurationSetting` :raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, :class:`ResourceNotFoundError` diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index b7bb57f791c0..8f764b30adc0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -18,9 +18,9 @@ ConfigurationSetting, FeatureFlagConfigurationSetting, SecretReferenceConfigurationSetting, - PERCENTAGE, - TARGETING, - TIME_WINDOW, + FILTER_PERCENTAGE, + FILTER_TARGETING, + FILTER_TIME_WINDOW, ) from azure.identity import DefaultAzureCredential @@ -579,7 +579,7 @@ def test_feature_filter_targeting(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abc", u"def"], @@ -604,7 +604,7 @@ def test_feature_filter_targeting(self, client): filters = updated_sent_config.filters filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcd", u"defg"], @@ -617,7 +617,7 @@ def test_feature_filter_targeting(self, client): filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], @@ -642,7 +642,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -667,7 +667,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -692,7 +692,7 @@ def test_feature_filter_custom(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -717,20 +717,20 @@ def test_feature_filter_multiple(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10 } }, { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" } }, { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], @@ -765,7 +765,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "bababooey, 31 Mar 2021 25:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -781,7 +781,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "bababooey, 31 Mar 2021 25:00:00 GMT", "End": "not even trying to be a date" @@ -798,7 +798,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "bababooey, 31 Mar 2021 25:00:00 GMT", "End": "not even trying to be a date" @@ -814,7 +814,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": "stringystring" }, ] @@ -827,7 +827,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": '123' @@ -844,7 +844,7 @@ def test_breaking1(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": "invalidformat" } ] diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 30b1e270f328..2eab215015be 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -17,9 +17,9 @@ ConfigurationSetting, SecretReferenceConfigurationSetting, FeatureFlagConfigurationSetting, - PERCENTAGE, - TARGETING, - TIME_WINDOW, + FILTER_PERCENTAGE, + FILTER_TARGETING, + FILTER_TIME_WINDOW, ) from consts import ( KEY, @@ -566,7 +566,7 @@ def test_feature_filter_targeting(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abc", u"def"], @@ -591,7 +591,7 @@ def test_feature_filter_targeting(self, client): filters = updated_sent_config.filters filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcd", u"defg"], @@ -604,7 +604,7 @@ def test_feature_filter_targeting(self, client): filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], @@ -629,7 +629,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -654,7 +654,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -679,7 +679,7 @@ def test_feature_filter_custom(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -704,20 +704,20 @@ def test_feature_filter_multiple(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10 } }, { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" } }, { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 55e0c73ea352..e7d9cbe28ab4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -16,9 +16,9 @@ ConfigurationSetting, SecretReferenceConfigurationSetting, FeatureFlagConfigurationSetting, - PERCENTAGE, - TARGETING, - TIME_WINDOW, + FILTER_PERCENTAGE, + FILTER_TARGETING, + FILTER_TIME_WINDOW, ) from azure.appconfiguration.aio import AzureAppConfigurationClient from consts import ( @@ -572,7 +572,7 @@ def test_feature_filter_targeting(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abc", u"def"], @@ -597,7 +597,7 @@ def test_feature_filter_targeting(self, client): filters = updated_sent_config.filters filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcd", u"defg"], @@ -610,7 +610,7 @@ def test_feature_filter_targeting(self, client): filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], @@ -635,7 +635,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -660,7 +660,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -685,7 +685,7 @@ def test_feature_filter_custom(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -710,20 +710,20 @@ def test_feature_filter_multiple(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10 } }, { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" } }, { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index b47a83707bc7..5bbc1d63bb39 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -16,9 +16,9 @@ ConfigurationSetting, SecretReferenceConfigurationSetting, FeatureFlagConfigurationSetting, - PERCENTAGE, - TARGETING, - TIME_WINDOW, + FILTER_PERCENTAGE, + FILTER_TARGETING, + FILTER_TIME_WINDOW, ) from azure.appconfiguration.aio import AzureAppConfigurationClient from consts import ( @@ -484,7 +484,7 @@ def test_sync_tokens(self, client): enabled=True, filters = [ { - u"name": TIME_WINDOW, + u"name": FILTER_TIME_WINDOW, u"parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -503,7 +503,7 @@ def test_sync_tokens(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abc", u"def"], @@ -601,7 +601,7 @@ def test_feature_filter_targeting(self, client): enabled=True, filters=[ { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abc", u"def"], @@ -626,7 +626,7 @@ def test_feature_filter_targeting(self, client): filters = updated_sent_config.filters filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcd", u"defg"], @@ -639,7 +639,7 @@ def test_feature_filter_targeting(self, client): filters.append( { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], @@ -664,7 +664,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -689,7 +689,7 @@ def test_feature_filter_time_window(self, client): enabled=True, filters=[ { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" @@ -714,7 +714,7 @@ def test_feature_filter_custom(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -739,20 +739,20 @@ def test_feature_filter_multiple(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10 } }, { - "name": TIME_WINDOW, + "name": FILTER_TIME_WINDOW, "parameters": { "Start": "Wed, 10 Mar 2021 05:00:00 GMT", "End": "Fri, 02 Apr 2021 04:00:00 GMT" } }, { - "name": TARGETING, + "name": FILTER_TARGETING, "parameters": { u"Audience": { u"Users": [u"abcde", u"defgh"], diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index ffd49f02e97a..e9c1a5347b8b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -7,7 +7,7 @@ from azure.appconfiguration import ( FeatureFlagConfigurationSetting, SecretReferenceConfigurationSetting, - PERCENTAGE, + FILTER_PERCENTAGE, ) from wrapper import app_config_decorator @@ -41,7 +41,7 @@ def test_update_json_by_value(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -121,7 +121,7 @@ def test_feature_flag_set_value(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" @@ -146,7 +146,7 @@ def test_feature_flag_set_enabled(self, client): enabled=True, filters=[ { - "name": PERCENTAGE, + "name": FILTER_PERCENTAGE, "parameters": { "Value": 10, "User": "user1" From a1d8216c9d90467843e54864652f8c2a76a10fcb Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 24 Jun 2021 17:55:58 -0400 Subject: [PATCH 49/60] testing typeerror --- .../azure/appconfiguration/_models.py | 34 +- ..._configuration_client.test_type_error.yaml | 465 ++++++++++++++++++ .../tests/test_azure_configuration_client.py | 10 + 3 files changed, 503 insertions(+), 6 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_type_error.yaml diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 4ac8f34e172e..8a63898c08b4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ +import collections import json from typing import Dict, Optional, Any, List, Union from msrest.serialization import Model @@ -86,7 +87,7 @@ def _from_generated(cls, key_value): return SecretReferenceConfigurationSetting._from_generated( # pylint: disable=protected-access key_value ) - except (KeyError, AttributeError, TypeError): + except (KeyError, AttributeError): pass return cls( @@ -165,6 +166,8 @@ class FeatureFlagConfigurationSetting( def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value # type: (str, **Any) -> None + if kwargs.pop("key", None) or kwargs.pop("value", None): + raise TypeError("Unexpected keyword argument, do not provide 'key' or 'value' as a keyword-arg") super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id self.key = self._key_prefix + self.feature_id @@ -258,6 +261,17 @@ def _from_generated(cls, key_value): # type: (KeyValue) -> Union[FeatureFlagConfigurationSetting, ConfigurationSetting] if key_value is None: return key_value + enabled = None + filters = None + try: + temp = json.loads(key_value.value) + if isinstance(temp, dict): + enabled = temp.get("enabled") + if "conditions" in temp.keys(): + filters = temp["conditions"].get("client_filters") + except (ValueError, JSONDecodeError): + pass + return cls( feature_id=key_value.key.lstrip(".appconfig.featureflag").lstrip("/"), # type: ignore label=key_value.label, @@ -266,7 +280,8 @@ def _from_generated(cls, key_value): tags=key_value.tags, read_only=key_value.locked, etag=key_value.etag, - value=key_value.value, + enabled=enabled, + filters=filters ) def _to_generated(self): @@ -324,11 +339,13 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting): ) kind = "SecretReference" - def __init__(self, key, secret_id, label=None, **kwargs): + def __init__(self, key, secret_id, **kwargs): # type: (str, str, Optional[str], **Any) -> None + if kwargs.pop("value", None): + raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) self.key = key - self.label = label + self.label = kwargs.pop("label", None) self.content_type = kwargs.get( "content_type", self._secret_reference_content_type ) @@ -364,12 +381,17 @@ def _from_generated(cls, key_value): # type: (KeyValue) -> SecretReferenceConfigurationSetting if key_value is None: return key_value + secret_uri = None + try: + temp = json.loads(key_value.value) + secret_uri = temp.get("secret_uri") + except (ValueError, JSONDecodeError): + pass return cls( key=key_value.key, # type: ignore - value=key_value.value, label=key_value.label, - secret_id=key_value.value, # type: ignore + secret_id=secret_uri, # type: ignore last_modified=key_value.last_modified, tags=key_value.tags, read_only=key_value.locked, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_type_error.yaml b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_type_error.yaml new file mode 100644 index 000000000000..43a42d7e94d4 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration/tests/recordings/test_azure_configuration_client.test_type_error.yaml @@ -0,0 +1,465 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:50.575634 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[{"etag":"wenIrlKKbh4NapQN07sSHd5RtYp","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:31+00:00"}]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:51 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjIx;sn=9507221 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjIx + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:51.243942 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"wenIrlKKbh4NapQN07sSHd5RtYp","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:31+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:52 GMT + etag: + - '"wenIrlKKbh4NapQN07sSHd5RtYp"' + last-modified: + - Thu, 24 Jun 2021 21:50:31 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjIy;sn=9507222 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "label": + "test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309", "content_type": "test content + type", "value": "test value", "tags": {"tag1": "tag1", "tag2": "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '231' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjIy + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 5b/E4qQlXHTRod+n+f+xjK6c/tRVR8uxoC62FjvGJPw= + x-ms-date: + - Jun, 24 2021 21:50:51.431688 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"cc8PuncVGckYPLBhamJpQdWygZ9","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:52+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:52 GMT + etag: + - '"cc8PuncVGckYPLBhamJpQdWygZ9"' + last-modified: + - Thu, 24 Jun 2021 21:50:52 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjIz;sn=9507223 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjIz + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:51.665156 GMT + method: GET + uri: https://fake_app_config.azconfig-test.io/kv?key=PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309&api-version=1.0 + response: + body: + string: '{"items":[{"etag":"hwo8MHlFR3NYRBXz5OviIT1p4j1","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:32+00:00"},{"etag":"cc8PuncVGckYPLBhamJpQdWygZ9","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:52+00:00"}]}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kvset+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:52 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjIz;sn=9507223 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjIz + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:51.844728 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"hwo8MHlFR3NYRBXz5OviIT1p4j1","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:32+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:52 GMT + etag: + - '"hwo8MHlFR3NYRBXz5OviIT1p4j1"' + last-modified: + - Thu, 24 Jun 2021 21:50:32 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjI0;sn=9507224 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"key": "PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309", "content_type": + "test content type", "value": "test value", "tags": {"tag1": "tag1", "tag2": + "tag2"}}' + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '170' + Content-Type: + - application/vnd.microsoft.appconfig.kv+json + If-None-Match: + - '*' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjI0 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 4rt07HteiPg5NxofrgzMmlQPTVbo1no7aKxDSI5uUU4= + x-ms-date: + - Jun, 24 2021 21:50:52.018701 GMT + method: PUT + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"Ah1pS1pReIEAXcabySU7b1qNIZq","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:52+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:53 GMT + etag: + - '"Ah1pS1pReIEAXcabySU7b1qNIZq"' + last-modified: + - Thu, 24 Jun 2021 21:50:52 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjI1;sn=9507225 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjI1 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:52.281596 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?label=test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309&api-version=1.0 + response: + body: + string: '{"etag":"cc8PuncVGckYPLBhamJpQdWygZ9","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":"test_label1_1d7b2b28-549e-11e9-b51c-2816a84d0309","content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:52+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:53 GMT + etag: + - '"cc8PuncVGckYPLBhamJpQdWygZ9"' + last-modified: + - Thu, 24 Jun 2021 21:50:52 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjI2;sn=9507226 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Sync-Token: + - zAJw6V16=MDoxNyM5NTA3MjI2 + User-Agent: + - azsdk-python-appconfiguration/1.2.0b3 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-content-sha256: + - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= + x-ms-date: + - Jun, 24 2021 21:50:52.464027 GMT + method: DELETE + uri: https://fake_app_config.azconfig-test.io/kv/PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309?api-version=1.0 + response: + body: + string: '{"etag":"Ah1pS1pReIEAXcabySU7b1qNIZq","key":"PYTHON_UNIT_test_key_a6af8952-54a6-11e9-b600-2816a84d0309","label":null,"content_type":"test + content type","value":"test value","tags":{"tag1":"tag1","tag2":"tag2"},"locked":false,"last_modified":"2021-06-24T21:50:52+00:00"}' + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-origin: + - '*' + access-control-expose-headers: + - DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, + Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, + x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, + If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, + Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, + x-ms-effective-locale, WWW-Authenticate + connection: + - keep-alive + content-type: + - application/vnd.microsoft.appconfig.kv+json; charset=utf-8 + date: + - Thu, 24 Jun 2021 21:50:53 GMT + etag: + - '"Ah1pS1pReIEAXcabySU7b1qNIZq"' + last-modified: + - Thu, 24 Jun 2021 21:50:52 GMT + server: + - openresty/1.17.8.2 + strict-transport-security: + - max-age=15724800; includeSubDomains + sync-token: + - zAJw6V16=MDoxNyM5NTA3MjI3;sn=9507227 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 8f764b30adc0..98fe5c8ec5f4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import Type from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError from devtools_testutils import AzureTestCase, PowerShellPreparer @@ -893,3 +894,12 @@ def test_breaking2(self, client): new.content_type = "fkaeyjfdkal;" client.set_configuration_setting(new) new1 = client.get_configuration_setting(new.key) + + @app_config_decorator + def test_type_error(self, client): + with pytest.raises(TypeError): + _ = FeatureFlagConfigurationSetting("blash", key="blash") + with pytest.raises(TypeError): + _ = FeatureFlagConfigurationSetting("blash", value="blash") + with pytest.raises(TypeError): + _ = SecretReferenceConfigurationSetting("blash", value="blash") \ No newline at end of file From f94ebbb4b822ce44afe00a534a70a315dc6a1d1a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 25 Jun 2021 13:25:02 -0400 Subject: [PATCH 50/60] value property instead of enabled and filters --- .../azure/appconfiguration/_models.py | 173 ++++++++++-------- .../tests/test_azure_configuration_client.py | 12 +- 2 files changed, 104 insertions(+), 81 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 8a63898c08b4..d81c636429a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -168,7 +168,7 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v # type: (str, **Any) -> None if kwargs.pop("key", None) or kwargs.pop("value", None): raise TypeError("Unexpected keyword argument, do not provide 'key' or 'value' as a keyword-arg") - super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) + # super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id self.key = self._key_prefix + self.feature_id self.label = kwargs.get("label", None) @@ -179,82 +179,109 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.etag = kwargs.get("etag", None) self.description = kwargs.get("description", None) self.display_name = kwargs.get("display_name", None) - if not self.value: - if "enabled" in kwargs.keys() and "filters" in kwargs.keys(): - self.value = json.dumps( - {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}} - ) - elif "enabled" in kwargs.keys(): - self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) - elif "filters" in kwargs.keys(): - self.value = json.dumps({"conditions": {"client_filters": []}}) - else: - self.value = json.dumps({}) + self.filters = kwargs.get("filters", []) + self.enabled = kwargs.get("enabled", None) + self._value = json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) + # self._filters = FeaturesList([]) + # if not self.value: + # if "enabled" in kwargs.keys() and "filters" in kwargs.keys(): + # self.value = json.dumps( + # {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}} + # ) + # self._filters = FeaturesList(self.value["conditions"]["client_filters"]) + # elif "enabled" in kwargs.keys(): + # self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) + # elif "filters" in kwargs.keys(): + # self.value = json.dumps({"conditions": {"client_filters": []}}) + # else: + # self.value = json.dumps({}) @property - def enabled(self): - # type: () -> Union[None, bool] - try: - temp = json.loads(self.value) - return temp.get("enabled", None) - except (JSONDecodeError, ValueError): - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - - @enabled.setter - def enabled(self, new_value): - # type: (bool) -> None - try: - temp = json.loads(self.value) - temp["enabled"] = new_value - self.value = json.dumps(temp) - except (JSONDecodeError, ValueError): - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") + def value(self): + self._value = json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) + return self._value - @property - def filters(self): - # type: () -> Union[None, List[Any]] + @value.setter + def value(self, new_value): try: - temp = None - try: - temp = json.loads(self.value) - except ValueError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") + temp = json.loads(new_value) + self._value = new_value + self.enabled = temp.get("enabled", None) conditions = temp.get("conditions", None) - if not conditions: - return None - try: - return conditions.get("client_filters", []) - except AttributeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ - " 'client_filters' is expected to be a dictionary") - except JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - - @filters.setter - def filters(self, new_filters): - # type: (List[Dict[str, Any]]) -> None - try: - temp = None - try: - temp = json.loads(self.value) - except ValueError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") - if "conditions" not in temp: - temp["conditions"] = {} - try: - temp["conditions"]["client_filters"] = new_filters - self.value = json.dumps(temp) - except AttributeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ - " 'client_filters' is expected to be a dictionary") - except JSONDecodeError: - raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") + if conditions: + self.filters = conditions.get("client_filters", []) + else: + self.filters = [] + except (JSONDecodeError, ValueError): + self._value = new_value + self.enabled = None + self.filters = [] + + + # @property + # def enabled(self): + # # type: () -> Union[None, bool] + # try: + # temp = json.loads(self.value) + # return temp.get("enabled", None) + # except (JSONDecodeError, ValueError): + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + + # @enabled.setter + # def enabled(self, new_value): + # # type: (bool) -> None + # try: + # temp = json.loads(self.value) + # temp["enabled"] = new_value + # self.value = json.dumps(temp) + # except (JSONDecodeError, ValueError): + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + + # @property + # def filters(self): + # # type: () -> Union[None, List[Any]] + # try: + # temp = None + # try: + # temp = json.loads(self.value) + # except ValueError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + # conditions = temp.get("conditions", None) + # if not conditions: + # return None + # try: + # return conditions.get("client_filters", []) + # except AttributeError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ + # " 'client_filters' is expected to be a dictionary") + # except JSONDecodeError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + + # @filters.setter + # def filters(self, new_filters): + # # type: (List[Dict[str, Any]]) -> None + # try: + # temp = None + # try: + # temp = json.loads(self.value) + # except ValueError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + # if "conditions" not in temp: + # temp["conditions"] = {} + # try: + # temp["conditions"]["client_filters"] = new_filters + # self.value = json.dumps(temp) + # except AttributeError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ + # " 'client_filters' is expected to be a dictionary") + # except JSONDecodeError: + # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): @@ -290,7 +317,7 @@ def _to_generated(self): return KeyValue( key=self.key, label=self.label, - value=self.value, + value=self._value, content_type=self.content_type, last_modified=self.last_modified, tags=self.tags, diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 98fe5c8ec5f4..26469d55702b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -5,8 +5,7 @@ # -------------------------------------------------------------------------- from typing import Type from azure.core import MatchConditions -from azure.core.exceptions import HttpResponseError -from devtools_testutils import AzureTestCase, PowerShellPreparer +from devtools_testutils import AzureTestCase from azure.core.exceptions import ( ResourceModifiedError, ResourceNotFoundError, @@ -23,7 +22,6 @@ FILTER_TARGETING, FILTER_TIME_WINDOW, ) -from azure.identity import DefaultAzureCredential from consts import ( KEY, @@ -532,7 +530,7 @@ def test_config_setting_feature_flag(self, client): temp = json.loads(changed_flag.value) assert temp['enabled'] == False - c = json.loads(copy.deepcopy(changed_flag.value)) + c = json.loads(changed_flag.value) c['enabled'] = True changed_flag.value = json.dumps(c) assert changed_flag.enabled == True @@ -602,8 +600,7 @@ def test_feature_filter_targeting(self, client): updated_sent_config = client.set_configuration_setting(sent_config) self._assert_same_keys(sent_config, updated_sent_config) - filters = updated_sent_config.filters - filters.append( + updated_sent_config.filters.append( { "name": FILTER_TARGETING, "parameters": { @@ -616,7 +613,7 @@ def test_feature_filter_targeting(self, client): } ) - filters.append( + updated_sent_config.filters.append( { "name": FILTER_TARGETING, "parameters": { @@ -628,7 +625,6 @@ def test_feature_filter_targeting(self, client): } } ) - updated_sent_config.filters = filters sent_config = client.set_configuration_setting(updated_sent_config) self._assert_same_keys(sent_config, updated_sent_config) From 8e63b29c54f7275fd064c7cdb7a500f10b211283 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 25 Jun 2021 13:26:56 -0400 Subject: [PATCH 51/60] fixing value configuring --- .../azure/appconfiguration/_models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index d81c636429a9..ba962d11c26f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -198,7 +198,12 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v @property def value(self): - self._value = json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) + if not self.enabled and not self.filters: + return self._value + elif not self.enabled: + self._value = json.dumps({"conditions": {"client_filters": self.filters}}) + elif not self.filters: + self._value = json.dumps({"enabled": self.enabled}) return self._value @value.setter From 576dbec0c5925458f0b6453af8e87d9fe0d50e1b Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 25 Jun 2021 14:25:54 -0400 Subject: [PATCH 52/60] fixing tests for only value @property on featflag --- .../azure/appconfiguration/_models.py | 15 ++++++----- .../tests/test_azure_configuration_client.py | 12 ++++----- .../test_azure_configuration_client_aad.py | 12 ++++----- ...st_azure_configuration_client_aad_async.py | 12 ++++----- .../test_azure_configuration_client_async.py | 12 ++++----- .../tests/test_consistency.py | 25 ++++++++++--------- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index ba962d11c26f..51372efb1590 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -198,13 +198,13 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v @property def value(self): - if not self.enabled and not self.filters: + if self.enabled is None and self.filters is None: return self._value - elif not self.enabled: + elif self.enabled is None: self._value = json.dumps({"conditions": {"client_filters": self.filters}}) - elif not self.filters: + elif self.filters is None: self._value = json.dumps({"enabled": self.enabled}) - return self._value + return json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) @value.setter def value(self, new_value): @@ -212,15 +212,14 @@ def value(self, new_value): temp = json.loads(new_value) self._value = new_value self.enabled = temp.get("enabled", None) + self.filters = None conditions = temp.get("conditions", None) if conditions: - self.filters = conditions.get("client_filters", []) - else: - self.filters = [] + self.filters = conditions.get("client_filters", None) except (JSONDecodeError, ValueError): self._value = new_value self.enabled = None - self.filters = [] + self.filters = None # @property diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 26469d55702b..5fd8c17f8985 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -539,9 +539,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.enabled + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.enabled client.delete_configuration_setting(changed_flag.key) @@ -565,9 +565,9 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.secret_id + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 2eab215015be..2fb4f0930078 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -527,9 +527,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.enabled + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.enabled client.delete_configuration_setting(changed_flag.key) @@ -553,9 +553,9 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.secret_id + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index e7d9cbe28ab4..b801c28660fd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -532,9 +532,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.enabled + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.enabled client.delete_configuration_setting(changed_flag.key) @@ -559,9 +559,9 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.secret_id + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 5bbc1d63bb39..545755fde64c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -561,9 +561,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.enabled + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.enabled client.delete_configuration_setting(changed_flag.key) @@ -588,9 +588,9 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - with pytest.raises(ValueError): - set_flag.value = "bad_value" - _ = set_flag.secret_id + # with pytest.raises(ValueError): + # set_flag.value = "bad_value" + # _ = set_flag.secret_id client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index e9c1a5347b8b..bb0675665197 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -51,7 +51,7 @@ def test_update_json_by_value(self, client): ) set_flag = client.set_configuration_setting(feature_flag) - set_flag.value = { + set_flag.value = json.dumps({ 'conditions': { 'client_filters': [ { @@ -72,7 +72,7 @@ def test_update_json_by_value(self, client): 'description': '', 'enabled': False, 'id': key, - } + }) set_flag = client.set_configuration_setting(set_flag) assert isinstance(set_flag, FeatureFlagConfigurationSetting) @@ -85,10 +85,11 @@ def test_feature_flag_invalid_json(self, client): feature_flag = FeatureFlagConfigurationSetting(key, enabled=True) set_flag = client.set_configuration_setting(feature_flag) - set_flag.value = [] - received = client.set_configuration_setting(set_flag) + with pytest.raises(TypeError): + set_flag.value = [] + received = client.set_configuration_setting(set_flag) - assert isinstance(received, FeatureFlagConfigurationSetting) + # assert isinstance(received, FeatureFlagConfigurationSetting) @app_config_decorator def test_feature_flag_invalid_json_string(self, client): @@ -108,10 +109,10 @@ def test_feature_flag_invalid_json_access_properties(self, client): set_flag = client.set_configuration_setting(feature_flag) set_flag.value = "hello world" - with pytest.raises(ValueError): - a = set_flag.enabled - with pytest.raises(ValueError): - b = set_flag.filters + # with pytest.raises(ValueError): + # a = set_flag.enabled + # with pytest.raises(ValueError): + # b = set_flag.filters @app_config_decorator def test_feature_flag_set_value(self, client): @@ -129,14 +130,14 @@ def test_feature_flag_set_value(self, client): } ] ) - feature_flag.value = { + feature_flag.value = json.dumps({ "conditions": { "client_filters": [] }, "enabled": False - } + }) - assert feature_flag.value["enabled"] == False + assert feature_flag.enabled == False @app_config_decorator def test_feature_flag_set_enabled(self, client): From 6f3904251c01dc948f1d2476f204debc96c1c50a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 25 Jun 2021 14:30:10 -0400 Subject: [PATCH 53/60] working for secref --- .../azure/appconfiguration/_models.py | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 51372efb1590..a2c243c8ff0c 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -374,7 +374,7 @@ def __init__(self, key, secret_id, **kwargs): # type: (str, str, Optional[str], **Any) -> None if kwargs.pop("value", None): raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") - super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) + # super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) self.key = key self.label = kwargs.pop("label", None) self.content_type = kwargs.get( @@ -384,28 +384,44 @@ def __init__(self, key, secret_id, **kwargs): self.last_modified = kwargs.get("last_modified", None) self.read_only = kwargs.get("read_only", None) self.tags = kwargs.get("tags", {}) - if not self.value: - self.value = json.dumps({"secret_uri": secret_id}) + self.secret_id = secret_id + self._value = json.dumps({"secret_uri": secret_id}) @property - def secret_id(self): - # type: () -> Optional[str] - try: - temp = json.loads(self.value) - return temp.get("secret_uri", None) - except (JSONDecodeError, ValueError): - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") + def value(self): + self._value = json.dumps({"secret_uri": self.secret_id}) + return self._value - @secret_id.setter - def secret_id(self, secret_id): + @value.setter + def value(self, new_value): try: - temp = json.loads(self.value) - temp["secret_uri"] = secret_id - self.value = json.dumps(temp) - except (JSONDecodeError, ValueError): - raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - "'value' is expected to be a dictionary") + temp = json.loads(new_value) + self._value = new_value + self.secret_id = temp.get("secret_uri") + except(JSONDecodeError, ValueError): + self._value= new_value + self.secret_id = None + + + # @property + # def secret_id(self): + # # type: () -> Optional[str] + # try: + # temp = json.loads(self.value) + # return temp.get("secret_uri", None) + # except (JSONDecodeError, ValueError): + # raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") + + # @secret_id.setter + # def secret_id(self, secret_id): + # try: + # temp = json.loads(self.value) + # temp["secret_uri"] = secret_id + # self.value = json.dumps(temp) + # except (JSONDecodeError, ValueError): + # raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ + # "'value' is expected to be a dictionary") @classmethod def _from_generated(cls, key_value): From 5d1a5ce9bbc726d1b335b6fdfde0aeba87d9b2da Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 28 Jun 2021 11:34:47 -0400 Subject: [PATCH 54/60] pylint and mypy fixes --- .../azure/appconfiguration/_models.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index a2c243c8ff0c..92107c72a92a 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -2,9 +2,8 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -import collections import json -from typing import Dict, Optional, Any, List, Union +from typing import Any, Union from msrest.serialization import Model from ._generated.models import KeyValue @@ -77,7 +76,9 @@ def _from_generated(cls, key_value): try: if key_value.content_type.startswith( FeatureFlagConfigurationSetting._feature_flag_content_type # pylint:disable=protected-access - ) and key_value.key.startswith(FeatureFlagConfigurationSetting._key_prefix): # type: ignore + ) and key_value.key.startswith( # type: ignore + FeatureFlagConfigurationSetting._key_prefix # pylint: disable=protected-access + ): return FeatureFlagConfigurationSetting._from_generated( # pylint: disable=protected-access key_value ) @@ -164,7 +165,7 @@ class FeatureFlagConfigurationSetting( ) kind = "FeatureFlag" - def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value + def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value, super-init-not-called # type: (str, **Any) -> None if kwargs.pop("key", None) or kwargs.pop("value", None): raise TypeError("Unexpected keyword argument, do not provide 'key' or 'value' as a keyword-arg") @@ -200,10 +201,12 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v def value(self): if self.enabled is None and self.filters is None: return self._value - elif self.enabled is None: + if self.enabled is None: self._value = json.dumps({"conditions": {"client_filters": self.filters}}) - elif self.filters is None: + return self._value + if self.filters is None: self._value = json.dumps({"enabled": self.enabled}) + return self._value return json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) @value.setter @@ -295,7 +298,7 @@ def _from_generated(cls, key_value): enabled = None filters = None try: - temp = json.loads(key_value.value) + temp = json.loads(key_value.value) # type: ignore if isinstance(temp, dict): enabled = temp.get("enabled") if "conditions" in temp.keys(): @@ -370,8 +373,8 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting): ) kind = "SecretReference" - def __init__(self, key, secret_id, **kwargs): - # type: (str, str, Optional[str], **Any) -> None + def __init__(self, key, secret_id, **kwargs): # pylint: disable=super-init-not-called + # type: (str, str, **Any) -> None if kwargs.pop("value", None): raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") # super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) @@ -399,7 +402,7 @@ def value(self, new_value): self._value = new_value self.secret_id = temp.get("secret_uri") except(JSONDecodeError, ValueError): - self._value= new_value + self._value = new_value self.secret_id = None @@ -430,7 +433,7 @@ def _from_generated(cls, key_value): return key_value secret_uri = None try: - temp = json.loads(key_value.value) + temp = json.loads(key_value.value) # type: ignore secret_uri = temp.get("secret_uri") except (ValueError, JSONDecodeError): pass From c7255805b8ee965cb86f3ef8e468e385fc248a40 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 28 Jun 2021 13:16:00 -0400 Subject: [PATCH 55/60] test fix --- .../azure-appconfiguration/tests/test_consistency.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py index bb0675665197..33fe8a9a588b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_consistency.py @@ -109,6 +109,8 @@ def test_feature_flag_invalid_json_access_properties(self, client): set_flag = client.set_configuration_setting(feature_flag) set_flag.value = "hello world" + assert set_flag.enabled == None + assert set_flag.filters == None # with pytest.raises(ValueError): # a = set_flag.enabled # with pytest.raises(ValueError): From 108816d4637d9bc93688d8365161d9cf61edde55 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 28 Jun 2021 13:38:49 -0400 Subject: [PATCH 56/60] cleaning up --- .../azure/appconfiguration/_models.py | 101 ------------------ .../tests/test_azure_configuration_client.py | 12 +-- .../test_azure_configuration_client_aad.py | 11 +- ...st_azure_configuration_client_aad_async.py | 12 +-- .../test_azure_configuration_client_async.py | 11 +- 5 files changed, 20 insertions(+), 127 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 92107c72a92a..1ec1dc4155d1 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -183,19 +183,6 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v self.filters = kwargs.get("filters", []) self.enabled = kwargs.get("enabled", None) self._value = json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) - # self._filters = FeaturesList([]) - # if not self.value: - # if "enabled" in kwargs.keys() and "filters" in kwargs.keys(): - # self.value = json.dumps( - # {"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": kwargs.pop("filters")}} - # ) - # self._filters = FeaturesList(self.value["conditions"]["client_filters"]) - # elif "enabled" in kwargs.keys(): - # self.value = json.dumps({"enabled": kwargs.pop("enabled"), "conditions": {"client_filters": []}}) - # elif "filters" in kwargs.keys(): - # self.value = json.dumps({"conditions": {"client_filters": []}}) - # else: - # self.value = json.dumps({}) @property def value(self): @@ -224,72 +211,6 @@ def value(self, new_value): self.enabled = None self.filters = None - - # @property - # def enabled(self): - # # type: () -> Union[None, bool] - # try: - # temp = json.loads(self.value) - # return temp.get("enabled", None) - # except (JSONDecodeError, ValueError): - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - - # @enabled.setter - # def enabled(self, new_value): - # # type: (bool) -> None - # try: - # temp = json.loads(self.value) - # temp["enabled"] = new_value - # self.value = json.dumps(temp) - # except (JSONDecodeError, ValueError): - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - - # @property - # def filters(self): - # # type: () -> Union[None, List[Any]] - # try: - # temp = None - # try: - # temp = json.loads(self.value) - # except ValueError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - # conditions = temp.get("conditions", None) - # if not conditions: - # return None - # try: - # return conditions.get("client_filters", []) - # except AttributeError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ - # " 'client_filters' is expected to be a dictionary") - # except JSONDecodeError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - - # @filters.setter - # def filters(self, new_filters): - # # type: (List[Dict[str, Any]]) -> None - # try: - # temp = None - # try: - # temp = json.loads(self.value) - # except ValueError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - # if "conditions" not in temp: - # temp["conditions"] = {} - # try: - # temp["conditions"]["client_filters"] = new_filters - # self.value = json.dumps(temp) - # except AttributeError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format." + \ - # " 'client_filters' is expected to be a dictionary") - # except JSONDecodeError: - # raise ValueError("'value' of FeatureFlagConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - @classmethod def _from_generated(cls, key_value): # type: (KeyValue) -> Union[FeatureFlagConfigurationSetting, ConfigurationSetting] @@ -377,7 +298,6 @@ def __init__(self, key, secret_id, **kwargs): # pylint: disable=super-init-not- # type: (str, str, **Any) -> None if kwargs.pop("value", None): raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") - # super(SecretReferenceConfigurationSetting, self).__init__(**kwargs) self.key = key self.label = kwargs.pop("label", None) self.content_type = kwargs.get( @@ -405,27 +325,6 @@ def value(self, new_value): self._value = new_value self.secret_id = None - - # @property - # def secret_id(self): - # # type: () -> Optional[str] - # try: - # temp = json.loads(self.value) - # return temp.get("secret_uri", None) - # except (JSONDecodeError, ValueError): - # raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - - # @secret_id.setter - # def secret_id(self, secret_id): - # try: - # temp = json.loads(self.value) - # temp["secret_uri"] = secret_id - # self.value = json.dumps(temp) - # except (JSONDecodeError, ValueError): - # raise ValueError("'value' of SecretReferenceConfigurationSetting is not in the proper format. " + \ - # "'value' is expected to be a dictionary") - @classmethod def _from_generated(cls, key_value): # type: (KeyValue) -> SecretReferenceConfigurationSetting diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 5fd8c17f8985..298e53a8fac3 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -482,7 +482,6 @@ def _assert_same_keys(self, key1, key2): @app_config_decorator def test_sync_tokens(self, client): - sync_tokens = copy.deepcopy(client._sync_token_policy._sync_tokens) sync_token_header = self._order_dict(sync_tokens) sync_token_header = ",".join(str(x) for x in sync_token_header.values()) @@ -539,9 +538,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.enabled + set_flag.value = "bad_value" + assert set_flag.enabled == None + assert set_flag.filters == None client.delete_configuration_setting(changed_flag.key) @@ -565,9 +564,8 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.secret_id + set_flag.value = "bad_value" + assert set_flag.secret_id == None client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 2fb4f0930078..6858af4a341b 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -527,9 +527,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.enabled + set_flag.value = "bad_value" + assert set_flag.enabled == None + assert set_flag.filters == None client.delete_configuration_setting(changed_flag.key) @@ -553,9 +553,8 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.secret_id + set_flag.value = "bad_value" + assert set_flag.secret_id == None client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index b801c28660fd..22590fcbed99 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -532,10 +532,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.enabled - + set_flag.value = "bad_value" + assert set_flag.enabled == None + assert set_flag.filters == None client.delete_configuration_setting(changed_flag.key) @app_config_decorator @@ -559,9 +558,8 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.secret_id + set_flag.value = "bad_value" + assert set_flag.secret_id == None client.delete_configuration_setting(secret_reference.key) diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 545755fde64c..6f13e2ffd2fe 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -561,9 +561,9 @@ def test_config_setting_feature_flag(self, client): assert changed_flag.enabled == None assert changed_flag.value == json.dumps({}) - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.enabled + set_flag.value = "bad_value" + assert set_flag.enabled == None + assert set_flag.filters == None client.delete_configuration_setting(changed_flag.key) @@ -588,9 +588,8 @@ def test_config_setting_secret_reference(self, client): updated_flag.value = json.dumps({'secret_uri': new_uri2}) assert updated_flag.secret_id == new_uri2 - # with pytest.raises(ValueError): - # set_flag.value = "bad_value" - # _ = set_flag.secret_id + set_flag.value = "bad_value" + assert set_flag.secret_id == None client.delete_configuration_setting(secret_reference.key) From dd84819b62a22b8ce41afacabb912bbfcd646005 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 28 Jun 2021 13:51:38 -0400 Subject: [PATCH 57/60] xiangs comment --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 1ec1dc4155d1..7a6a892c671f 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -167,7 +167,7 @@ class FeatureFlagConfigurationSetting( def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-value, super-init-not-called # type: (str, **Any) -> None - if kwargs.pop("key", None) or kwargs.pop("value", None): + if "key" in kwargs.keys() or "value" in kwargs.keys(): raise TypeError("Unexpected keyword argument, do not provide 'key' or 'value' as a keyword-arg") # super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id @@ -241,7 +241,6 @@ def _from_generated(cls, key_value): def _to_generated(self): # type: () -> KeyValue - return KeyValue( key=self.key, label=self.label, @@ -296,7 +295,7 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting): def __init__(self, key, secret_id, **kwargs): # pylint: disable=super-init-not-called # type: (str, str, **Any) -> None - if kwargs.pop("value", None): + if "value" in kwargs.keys(): raise TypeError("Unexpected keyword argument, do not provide 'value' as a keyword-arg") self.key = key self.label = kwargs.pop("label", None) From 3330b66b52937a50e18eca6ea56f09811eb06b01 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 28 Jun 2021 16:22:12 -0400 Subject: [PATCH 58/60] patching storage stuff --- .../devtools_testutils/storage_testcase.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py b/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py index a67427dc5ecc..a0f2ce6259c8 100644 --- a/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py +++ b/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py @@ -14,8 +14,12 @@ pass from azure.mgmt.storage import StorageManagementClient -from azure.mgmt.storage.models import StorageAccount, Endpoints, BlobServiceProperties, DeleteRetentionPolicy, \ - LastAccessTimeTrackingPolicy +from azure.mgmt.storage.models import StorageAccount, Endpoints, BlobServiceProperties, DeleteRetentionPolicy + +try: + from azure.mgmt.storage.models import LastAccessTimeTrackingPolicy +except ImportError: + pass from azure_devtools.scenario_tests.exceptions import AzureTestError From ad4d59200826040a45ac0fc560cece563642af5a Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 29 Jun 2021 11:42:32 -0400 Subject: [PATCH 59/60] fixing value property --- .../azure/appconfiguration/_models.py | 26 ++++++++++++------- .../tests/test_azure_configuration_client.py | 2 +- .../test_azure_configuration_client_aad.py | 2 +- ...st_azure_configuration_client_aad_async.py | 2 +- .../test_azure_configuration_client_async.py | 2 +- .../devtools_testutils/storage_testcase.py | 7 +++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index 7a6a892c671f..d879a81751b0 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -169,7 +169,6 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v # type: (str, **Any) -> None if "key" in kwargs.keys() or "value" in kwargs.keys(): raise TypeError("Unexpected keyword argument, do not provide 'key' or 'value' as a keyword-arg") - # super(FeatureFlagConfigurationSetting, self).__init__(**kwargs) self.feature_id = feature_id self.key = self._key_prefix + self.feature_id self.label = kwargs.get("label", None) @@ -186,15 +185,17 @@ def __init__(self, feature_id, **kwargs): # pylint: disable=dangerous-default-v @property def value(self): - if self.enabled is None and self.filters is None: - return self._value - if self.enabled is None: - self._value = json.dumps({"conditions": {"client_filters": self.filters}}) + try: + temp = json.loads(self._value) + temp["enabled"] = self.enabled + + if "conditions" not in temp.keys(): + temp["conditions"] = {} + temp["conditions"]["client_filters"] = self.filters + self._value = json.dumps(temp) return self._value - if self.filters is None: - self._value = json.dumps({"enabled": self.enabled}) + except (JSONDecodeError, ValueError): return self._value - return json.dumps({"enabled": self.enabled, "conditions": {"client_filters": self.filters}}) @value.setter def value(self, new_value): @@ -311,8 +312,13 @@ def __init__(self, key, secret_id, **kwargs): # pylint: disable=super-init-not- @property def value(self): - self._value = json.dumps({"secret_uri": self.secret_id}) - return self._value + try: + temp = json.loads(self._value) + temp["secret_uri"] = self.secret_id + self._value = json.dumps(temp) + return self._value + except (JSONDecodeError, ValueError): + return self._value @value.setter def value(self, new_value): diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py index 298e53a8fac3..d2956512d072 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client.py @@ -536,7 +536,7 @@ def test_config_setting_feature_flag(self, client): changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == json.dumps({}) + assert changed_flag.value == json.dumps({'enabled': None, "conditions": {"client_filters": None}}) set_flag.value = "bad_value" assert set_flag.enabled == None diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py index 6858af4a341b..49e3bd0e9138 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad.py @@ -525,7 +525,7 @@ def test_config_setting_feature_flag(self, client): changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == json.dumps({}) + assert changed_flag.value == json.dumps({'enabled': None, "conditions": {"client_filters": None}}) set_flag.value = "bad_value" assert set_flag.enabled == None diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py index 22590fcbed99..f4ecad553be9 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_aad_async.py @@ -530,7 +530,7 @@ def test_config_setting_feature_flag(self, client): changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == json.dumps({}) + assert changed_flag.value == json.dumps({'enabled': None, "conditions": {"client_filters": None}}) set_flag.value = "bad_value" assert set_flag.enabled == None diff --git a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py index 6f13e2ffd2fe..2d63ece79821 100644 --- a/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py +++ b/sdk/appconfiguration/azure-appconfiguration/tests/test_azure_configuration_client_async.py @@ -559,7 +559,7 @@ def test_config_setting_feature_flag(self, client): changed_flag.value = json.dumps({}) assert changed_flag.enabled == None - assert changed_flag.value == json.dumps({}) + assert changed_flag.value == json.dumps({'enabled': None, "conditions": {"client_filters": None}}) set_flag.value = "bad_value" assert set_flag.enabled == None diff --git a/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py b/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py index a0f2ce6259c8..c3a9ebee87c3 100644 --- a/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py +++ b/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py @@ -13,11 +13,10 @@ except: pass -from azure.mgmt.storage import StorageManagementClient -from azure.mgmt.storage.models import StorageAccount, Endpoints, BlobServiceProperties, DeleteRetentionPolicy - try: - from azure.mgmt.storage.models import LastAccessTimeTrackingPolicy + # Note: these models are only available from v17.0.0 and higher, if you need them you'll also need azure-core 1.4.0 and higher + from azure.mgmt.storage import StorageManagementClient + from azure.mgmt.storage.models import StorageAccount, Endpoints, LastAccessTimeTrackingPolicy, BlobServiceProperties, DeleteRetentionPolicy except ImportError: pass From 8ddc1e32bcfb2074e542508db18095e9fd9c1da3 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 29 Jun 2021 12:36:17 -0400 Subject: [PATCH 60/60] to generated update --- .../azure-appconfiguration/azure/appconfiguration/_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py index d879a81751b0..2ff870e99b16 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_models.py @@ -245,7 +245,7 @@ def _to_generated(self): return KeyValue( key=self.key, label=self.label, - value=self._value, + value=self.value, content_type=self.content_type, last_modified=self.last_modified, tags=self.tags,