Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(api) - update raise from status to support too many request e… TKT-6264 #148

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.21.7
_______
- Raise AnalysisRateLimitError when analysis rejected due to rate limit exceeded error returning from server

1.21.6
_______
- Fix sending data in the body of the request
Expand Down
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.21.6'
__version__ = '1.21.7'
3 changes: 2 additions & 1 deletion intezer_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def raise_for_status(response: requests.Response,
elif response.status_code == HTTPStatus.CONFLICT:
if response_json.get('result', {}).get('is_skipped_by_rule'):
raise errors.AnalysisSkippedByRuleError(response)
elif response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
raise errors.AnalysisRateLimitError(response)
almogch marked this conversation as resolved.
Show resolved Hide resolved
elif response.status_code == HTTPStatus.FORBIDDEN:
if response_json.get('error') == 'Insufficient Permissions':
raise errors.InsufficientPermissionsError(response)
elif response.status_code == HTTPStatus.BAD_REQUEST:
http_error_msg = '\n'.join([f'{key}:{value}.' for key, value in response_json.get('message', {}).items()])


if should_raise:
if not http_error_msg:
http_error_msg = f'{response.status_code} Client Error: {reason} for url: {response.url}'
Expand Down
4 changes: 4 additions & 0 deletions intezer_sdk/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ def __init__(self, response: requests.Response):
class AnalysisSkippedByRuleError(ServerError):
def __init__(self, response: requests.Response):
super().__init__('Analysis skipped by rule', response)

class AnalysisRateLimitError(ServerError):
def __init__(self, response: requests.Response):
super().__init__('Analysis rate limit reached', response)
Loading