6
6
import binascii
7
7
import functools
8
8
from datetime import datetime
9
- from typing import Any , Dict , List , Mapping , Optional , Union , cast , overload
9
+ from typing import Any , Dict , List , Optional , Union , cast , overload
10
10
from typing_extensions import Literal
11
11
from azure .core import MatchConditions
12
12
from azure .core .paging import ItemPaged
21
21
ResourceNotModifiedError ,
22
22
)
23
23
from azure .core .rest import HttpRequest , HttpResponse
24
- from azure .core .utils import CaseInsensitiveDict
25
24
from ._azure_appconfiguration_error import ResourceReadOnlyError
26
25
from ._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy
27
26
from ._generated import AzureAppConfiguration
@@ -321,16 +320,15 @@ def add_configuration_setting(self, configuration_setting: ConfigurationSetting,
321
320
added_config_setting = client.add_configuration_setting(config_setting)
322
321
"""
323
322
key_value = configuration_setting ._to_generated ()
324
- custom_headers : Mapping [str , Any ] = CaseInsensitiveDict (kwargs .get ("headers" ))
325
323
error_map = {412 : ResourceExistsError }
326
324
try :
327
325
key_value_added = self ._impl .put_key_value (
328
326
entity = key_value ,
329
327
key = key_value .key , # type: ignore
330
328
label = key_value .label ,
331
329
if_none_match = "*" ,
332
- headers = custom_headers ,
333
330
error_map = error_map ,
331
+ ** kwargs ,
334
332
)
335
333
return ConfigurationSetting ._from_generated (key_value_added )
336
334
except binascii .Error as exc :
@@ -358,9 +356,9 @@ def set_configuration_setting(
358
356
Will use the value from param configuration_setting if not set.
359
357
:return: The ConfigurationSetting returned from the service
360
358
:rtype: ~azure.appconfiguration.ConfigurationSetting
361
- :raises: :class:`~azure.core.exceptions.HttpResponseError`, \
359
+ :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \
360
+ :class:`~azure.core.exceptions.HttpResponseError`, \
362
361
:class:`~azure.core.exceptions.ClientAuthenticationError`, \
363
- :class:`~azure.core.exceptions.ResourceReadOnlyError`, \
364
362
:class:`~azure.core.exceptions.ResourceModifiedError`, \
365
363
:class:`~azure.core.exceptions.ResourceNotModifiedError`, \
366
364
:class:`~azure.core.exceptions.ResourceNotFoundError`, \
@@ -380,7 +378,6 @@ def set_configuration_setting(
380
378
returned_config_setting = client.set_configuration_setting(config_setting)
381
379
"""
382
380
key_value = configuration_setting ._to_generated ()
383
- custom_headers : Mapping [str , Any ] = CaseInsensitiveDict (kwargs .get ("headers" ))
384
381
error_map : Dict [int , Any ] = {409 : ResourceReadOnlyError }
385
382
if match_condition == MatchConditions .IfNotModified :
386
383
error_map .update ({412 : ResourceModifiedError })
@@ -398,8 +395,8 @@ def set_configuration_setting(
398
395
label = key_value .label ,
399
396
if_match = prep_if_match (configuration_setting .etag , match_condition ),
400
397
if_none_match = prep_if_none_match (etag or configuration_setting .etag , match_condition ),
401
- headers = custom_headers ,
402
398
error_map = error_map ,
399
+ ** kwargs ,
403
400
)
404
401
return ConfigurationSetting ._from_generated (key_value_set )
405
402
except binascii .Error as exc :
@@ -414,7 +411,7 @@ def delete_configuration_setting( # pylint:disable=delete-operation-wrong-retur
414
411
etag : Optional [str ] = None ,
415
412
match_condition : MatchConditions = MatchConditions .Unconditionally ,
416
413
** kwargs ,
417
- ) -> ConfigurationSetting :
414
+ ) -> Union [ None , ConfigurationSetting ] :
418
415
"""Delete a ConfigurationSetting if it exists
419
416
420
417
:param key: key used to identify the ConfigurationSetting
@@ -426,9 +423,9 @@ def delete_configuration_setting( # pylint:disable=delete-operation-wrong-retur
426
423
:paramtype match_condition: ~azure.core.MatchConditions
427
424
:return: The deleted ConfigurationSetting returned from the service, or None if it doesn't exist.
428
425
:rtype: ~azure.appconfiguration.ConfigurationSetting
429
- :raises: :class:`~azure.core.exceptions.HttpResponseError`, \
426
+ :raises: :class:`~azure.appconfiguration.ResourceReadOnlyError`, \
427
+ :class:`~azure.core.exceptions.HttpResponseError`, \
430
428
:class:`~azure.core.exceptions.ClientAuthenticationError`, \
431
- :class:`~azure.core.exceptions.ResourceReadOnlyError`, \
432
429
:class:`~azure.core.exceptions.ResourceModifiedError`, \
433
430
:class:`~azure.core.exceptions.ResourceNotModifiedError`, \
434
431
:class:`~azure.core.exceptions.ResourceNotFoundError`, \
@@ -442,7 +439,6 @@ def delete_configuration_setting( # pylint:disable=delete-operation-wrong-retur
442
439
key="MyKey", label="MyLabel"
443
440
)
444
441
"""
445
- custom_headers : Mapping [str , Any ] = CaseInsensitiveDict (kwargs .get ("headers" ))
446
442
error_map : Dict [int , Any ] = {409 : ResourceReadOnlyError }
447
443
if match_condition == MatchConditions .IfNotModified :
448
444
error_map .update ({412 : ResourceModifiedError })
@@ -458,10 +454,12 @@ def delete_configuration_setting( # pylint:disable=delete-operation-wrong-retur
458
454
key = key ,
459
455
label = label ,
460
456
if_match = prep_if_match (etag , match_condition ),
461
- headers = custom_headers ,
462
457
error_map = error_map ,
458
+ ** kwargs ,
463
459
)
464
- return ConfigurationSetting ._from_generated (key_value_deleted ) # type: ignore
460
+ if key_value_deleted :
461
+ return ConfigurationSetting ._from_generated (key_value_deleted )
462
+ return None
465
463
except binascii .Error as exc :
466
464
raise binascii .Error ("Connection string secret has incorrect padding" ) from exc
467
465
0 commit comments