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

Feat/rate limit TKT-6264 #149

Merged
merged 3 commits into from
Dec 18, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.21.8
_______
- Raise AnalysisRateLimitError for all endpoints when rate limit exceeded error returning from server

1.21.7
_______
- Raise AnalysisRateLimitError when analysis rejected due to rate limit exceeded error returning from server
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.7'
__version__ = '1.21.8'
2 changes: 2 additions & 0 deletions intezer_sdk/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,8 @@ def _assert_analysis_response_status_code(response: Response):
raise errors.AnalysisIsAlreadyRunningError(response, running_analysis_id)
elif response.status_code == HTTPStatus.FORBIDDEN:
raise errors.InsufficientQuotaError(response)
elif response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
raise errors.AnalysisRateLimitError(response)
elif response.status_code == HTTPStatus.BAD_REQUEST:
data = response.json()
error = data.get('error', '')
Expand Down
5 changes: 4 additions & 1 deletion intezer_sdk/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def __init__(self, response: requests.Response):

class AlertInProgressError(AlertError):
def __init__(self, alert_id: str):
super().__init__(f'The alert {alert_id} is being processed at the moment, please try again later')
super().__init__(
f'The alert {alert_id} is being processed at the moment, please try again later'
)


class AlertNotFoundError(AlertError):
Expand All @@ -178,6 +180,7 @@ 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)
Expand Down
Loading