Skip to content

Commit

Permalink
Merge pull request #149 from intezer/feat/rate-limit
Browse files Browse the repository at this point in the history
Feat/rate limit TKT-6264
  • Loading branch information
almogch authored Dec 18, 2024
2 parents 19dbda9 + 82469fa commit 4c9391d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
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

0 comments on commit 4c9391d

Please sign in to comment.