Skip to content

Commit

Permalink
fix: honor retryMaxAllowedNumber (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims authored Apr 4, 2024
2 parents f18f786 + 9989f94 commit 2adb952
Show file tree
Hide file tree
Showing 4 changed files with 440 additions and 9 deletions.
1 change: 1 addition & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ git_push.sh
test/*
!test/__init__.py
!test/test_open_fga_api.py
!test/test_configuration.py
!test/test_credentials.py
!test/test_client.py
!test/test_client_sync.py
Expand Down
1 change: 1 addition & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ test-requirements.txt
test/__init__.py
test/test_client.py
test/test_client_sync.py
test/test_configuration.py
test/test_credentials.py
test/test_oauth2.py
test/test_oauth2_sync.py
Expand Down
51 changes: 42 additions & 9 deletions openfga_sdk/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,28 @@ def max_retry(self):
"""
Return the maximum number of retry
"""
if self._max_retry > 15:
raise FgaValidationException(
"RetryParams.max_retry exceeds maximum allowed limit of 15"
)

return self._max_retry

@max_retry.setter
def max_retry(self, value):
"""
Update the maximum number of retry
"""
if not isinstance(value, int) or value < 0:
raise FgaValidationException(
"RetryParams.max_retry must be an integer greater than or equal to 0"
)

if value > 15:
raise FgaValidationException(
"RetryParams.max_retry exceeds maximum allowed limit of 15"
)

self._max_retry = value

@property
Expand All @@ -77,6 +92,11 @@ def min_wait_in_ms(self, value):
"""
Update the minimum wait (in ms) in between retry
"""
if not isinstance(value, int) or value < 0:
raise FgaValidationException(
"RetryParams.min_wait_in_ms must be an integer greater than or equal to 0"
)

self._min_wait_in_ms = value


Expand Down Expand Up @@ -287,15 +307,6 @@ def __deepcopy__(self, memo):
result.debug = self.debug
return result

def __setattr__(self, name, value):
object.__setattr__(self, name, value)
if name == "disabled_client_side_validations":
s = set(filter(None, value.split(",")))
for v in s:
if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
raise ApiValueError(f"Invalid keyword: '{v}''")
self._disabled_client_side_validations = s

@classmethod
def set_default(cls, default):
"""Set default instance of configuration.
Expand Down Expand Up @@ -574,6 +585,11 @@ def api_scheme(self):
@api_scheme.setter
def api_scheme(self, value):
"""Update connection scheme (https or http)."""
if value is not None and value not in ["https", "http"]:
raise FgaValidationException(
f"api_scheme `{value}` must be either `http` or `https`"
)

self._scheme = value

@property
Expand Down Expand Up @@ -631,3 +647,20 @@ def retry_params(self, value):
Update retry parameters
"""
self._retry_params = value

@property
def disabled_client_side_validations(self):
"""Return disable_client_side_validations."""
return self._disabled_client_side_validations

@disabled_client_side_validations.setter
def disabled_client_side_validations(self, value):
"""Update disable_client_side_validations."""
self._disabled_client_side_validations = {}

if isinstance(value, str) and value:
s = set(filter(None, value.split(",")))
for v in s:
if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
raise FgaValidationException(f"Invalid keyword: '{v}''")
self._disabled_client_side_validations = s
Loading

0 comments on commit 2adb952

Please sign in to comment.