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

Filter by extension

Filter by extension

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

### Features Added

- Added `match_conditions` parameter to `by_page()` method in `list_configuration_settings()` to efficiently monitor configuration changes using etags without fetching unchanged data.
- Added support for custom authentication audiences via the `audience` keyword argument in `AzureAppConfigurationClient` constructor to enable authentication against sovereign clouds.

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion sdk/appconfiguration/azure-appconfiguration/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/appconfiguration/azure-appconfiguration",
"Tag": "python/appconfiguration/azure-appconfiguration_5a7879bd17"
"Tag": "python/appconfiguration/azure-appconfiguration_43ad21e0c9"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ._models import (
ConfigurationSetting,
ConfigurationSettingPropertiesPaged,
ConfigurationSettingPaged,
ConfigurationSettingsFilter,
ConfigurationSnapshot,
ConfigurationSettingLabel,
Expand Down Expand Up @@ -236,7 +237,7 @@ def list_configuration_settings(self, *args: Optional[str], **kwargs: Any) -> It
key_filter, kwargs = get_key_filter(*args, **kwargs)
label_filter, kwargs = get_label_filter(*args, **kwargs)
command = functools.partial(self._impl.get_key_values_in_one_page, **kwargs) # type: ignore[attr-defined]
return ItemPaged(
return ConfigurationSettingPaged(
command,
key=key_filter,
label=label_filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
"""
import json
import urllib.parse
from typing import Any, Iterable, List, Optional, Union, MutableMapping, Type
from azure.core import MatchConditions
Expand All @@ -28,9 +29,15 @@
AzureAppConfigurationClientOperationsMixin as AzureAppConfigClientOpGenerated,
ClsType,
build_azure_app_configuration_get_key_values_request,
prep_if_match,
prep_if_none_match,
)
from .. import models as _models
from .._model_base import _deserialize
from .._serialization import Serializer

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False


class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated):
Expand Down Expand Up @@ -144,8 +151,28 @@ def prepare_request(next_link=None):
}
)
_next_request_params["api-version"] = self._config.api_version

# Add etag and match_condition to headers
_next_headers = dict(_headers)
accept = _headers.pop("Accept", None)
if etag is not None:
if sync_token is not None:
_next_headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
if accept_datetime is not None:
_next_headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
if accept is not None:
_next_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
if_match = prep_if_match(etag, match_condition)
if if_match is not None:
_next_headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
if_none_match = prep_if_none_match(etag, match_condition)
if if_none_match is not None:
_next_headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
_request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
"GET",
urllib.parse.urljoin(next_link, _parsed_next_link.path),
params=_next_request_params,
headers=_next_headers,
)
path_format_arguments = {
"endpoint": self._serialize.url(
Expand All @@ -157,20 +184,31 @@ def prepare_request(next_link=None):
return _request

_request = prepare_request(continuation_token)

_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200]:
valid_status_codes = [200]
if etag is not None and match_condition is not None:
valid_status_codes.append(304)

if response.status_code not in valid_status_codes:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = _deserialize(_models.Error, response.json())
raise HttpResponseError(response=response, model=error)

response_headers = response.headers
deserialized = pipeline_response.http_response.json()
deserialized = json.loads("{}")
if response.status_code != 304:
deserialized = pipeline_response.http_response.json()
else:
unparsed_link = pipeline_response.http_response.headers.get("Link")
next_link = None
if unparsed_link:
next_link = unparsed_link[1 : unparsed_link.index(">")]
deserialized["@nextLink"] = next_link

if cls:
return cls(pipeline_response, deserialized, response_headers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
"""
import json
import urllib.parse
from typing import Any, AsyncIterable, List, Optional, Union, MutableMapping, Type
from azure.core import MatchConditions
Expand All @@ -26,8 +27,13 @@
ClsType,
build_azure_app_configuration_get_key_values_request,
)
from ..._operations._operations import prep_if_match, prep_if_none_match
from ... import models as _models
from ..._model_base import _deserialize
from ..._serialization import Serializer

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False


class AzureAppConfigurationClientOperationsMixin(AzureAppConfigClientOpGenerated):
Expand Down Expand Up @@ -141,8 +147,28 @@ def prepare_request(next_link=None):
}
)
_next_request_params["api-version"] = self._config.api_version

# Add etag and match_condition to headers
_next_headers = dict(_headers)
accept = _headers.pop("Accept", None)
if etag is not None:
if sync_token is not None:
_next_headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
if accept_datetime is not None:
_next_headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
if accept is not None:
_next_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
if_match = prep_if_match(etag, match_condition)
if if_match is not None:
_next_headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
if_none_match = prep_if_none_match(etag, match_condition)
if if_none_match is not None:
_next_headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
_request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
"GET",
urllib.parse.urljoin(next_link, _parsed_next_link.path),
params=_next_request_params,
headers=_next_headers,
)
path_format_arguments = {
"endpoint": self._serialize.url(
Expand All @@ -161,13 +187,25 @@ def prepare_request(next_link=None):
)
response = pipeline_response.http_response

if response.status_code not in [200]:
valid_status_codes = [200]
if etag is not None and match_condition is not None:
valid_status_codes.append(304)

if response.status_code not in valid_status_codes:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = _deserialize(_models.Error, response.json())
raise HttpResponseError(response=response, model=error)

response_headers = response.headers
deserialized = pipeline_response.http_response.json()
deserialized = json.loads("{}")
if response.status_code != 304:
deserialized = pipeline_response.http_response.json()
else:
unparsed_link = pipeline_response.http_response.headers.get("Link")
next_link = None
if unparsed_link:
next_link = unparsed_link[1 : unparsed_link.index(">")]
deserialized["@nextLink"] = next_link

if cls:
return cls(pipeline_response, deserialized, response_headers)
Expand Down
Loading