Skip to content

Commit

Permalink
Adding variables for retry and modes options (#2695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Funke committed Jun 14, 2022
1 parent d610036 commit b296c51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions botocore/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ def _validate_s3_configuration(self, s3):
)

def _validate_retry_configuration(self, retries):
valid_options = ('max_attempts', 'mode', 'total_max_attempts')
valid_modes = ('legacy', 'standard', 'adaptive')
if retries is not None:
for key, value in retries.items():
if key not in ['max_attempts', 'mode', 'total_max_attempts']:
if key not in valid_options:
raise InvalidRetryConfigurationError(
retry_config_option=key
retry_config_option=key,
valid_options=valid_options,
)
if key == 'max_attempts' and value < 0:
raise InvalidMaxRetryAttemptsError(
Expand All @@ -292,12 +295,11 @@ def _validate_retry_configuration(self, retries):
provided_max_attempts=value,
min_value=1,
)
if key == 'mode' and value not in (
'legacy',
'standard',
'adaptive',
):
raise InvalidRetryModeError(provided_retry_mode=value)
if key == 'mode' and value not in valid_modes:
raise InvalidRetryModeError(
provided_retry_mode=value,
valid_modes=valid_modes,
)

def merge(self, other_config):
"""Merges the config object with another config object
Expand Down
4 changes: 2 additions & 2 deletions botocore/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class InvalidRetryConfigurationError(BotoCoreError):

fmt = (
'Cannot provide retry configuration for "{retry_config_option}". '
'Valid retry configuration options are: \'max_attempts\''
'Valid retry configuration options are: {valid_options}'
)


Expand All @@ -653,7 +653,7 @@ class InvalidRetryModeError(InvalidRetryConfigurationError):

fmt = (
'Invalid value provided to "mode": "{provided_retry_mode}" must '
'be one of: "legacy", "standard", "adaptive"'
'be one of: {valid_modes}'
)


Expand Down

0 comments on commit b296c51

Please sign in to comment.