mirror of
https://github.com/brygphilomena/pyhuntress.git
synced 2026-05-13 11:34:29 +00:00
Add exception response for 504
This commit is contained in:
parent
7532b475a7
commit
2bc5c5a4ca
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "pyhuntress"
|
name = "pyhuntress"
|
||||||
version = "0.2.16"
|
version = "0.2.17"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
||||||
]
|
]
|
||||||
|
|||||||
@ -21,6 +21,7 @@ from pyhuntress.exceptions import (
|
|||||||
PermissionsFailedException,
|
PermissionsFailedException,
|
||||||
ServerError,
|
ServerError,
|
||||||
TooManyRequestsException,
|
TooManyRequestsException,
|
||||||
|
RequestTimedOutException,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -77,6 +78,7 @@ class HuntressClient(ABC):
|
|||||||
method,
|
method,
|
||||||
url,
|
url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
timeout=180,
|
||||||
data=data,
|
data=data,
|
||||||
params=cast(dict[str, Any], params or {}),
|
params=cast(dict[str, Any], params or {}),
|
||||||
stream=stream,
|
stream=stream,
|
||||||
@ -86,6 +88,7 @@ class HuntressClient(ABC):
|
|||||||
method,
|
method,
|
||||||
url,
|
url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
timeout=180,
|
||||||
params=cast(dict[str, Any], params or {}),
|
params=cast(dict[str, Any], params or {}),
|
||||||
stream=stream,
|
stream=stream,
|
||||||
)
|
)
|
||||||
@ -130,5 +133,7 @@ class HuntressClient(ABC):
|
|||||||
return self._make_request(method, url, data, params, headers, retry_count)
|
return self._make_request(method, url, data, params, headers, retry_count)
|
||||||
raise Timeout(response=response)
|
raise Timeout(response=response)
|
||||||
raise ServerError(response)
|
raise ServerError(response)
|
||||||
|
if response.status_code == 504:
|
||||||
|
raise RequestTimedOutException(response)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@ -87,3 +87,7 @@ class ServerError(HuntressException):
|
|||||||
class ObjectExistsError(HuntressException):
|
class ObjectExistsError(HuntressException):
|
||||||
_code_explanation = "Object Exists"
|
_code_explanation = "Object Exists"
|
||||||
_error_suggestion = "This resource already exists."
|
_error_suggestion = "This resource already exists."
|
||||||
|
|
||||||
|
class RequestTimedOutException(HuntressException):
|
||||||
|
_code_explanation = "Request Timed Out"
|
||||||
|
_error_suggestion = "This resource is possibly busy or not responding. Try again later or use a smaller request."
|
||||||
|
|||||||
@ -120,7 +120,7 @@ class SATPhishingCampaigns(HuntressModel):
|
|||||||
] | None = Field(default=None, alias="Type")
|
] | None = Field(default=None, alias="Type")
|
||||||
id: str | None = Field(default=None, alias="Id")
|
id: str | None = Field(default=None, alias="Id")
|
||||||
attributes: dict[str, Any] | None = Field(default=None, alias="Attributes")
|
attributes: dict[str, Any] | None = Field(default=None, alias="Attributes")
|
||||||
relationships: dict[str, dict[str, dict[str, str]]] | None = Field(default=None, alias="Relationships")
|
relationships: dict[str, dict[str, Any]] | None = Field(default=None, alias="Relationships")
|
||||||
links: dict[str, str] | None = Field(default=None, alias="Links")
|
links: dict[str, str] | None = Field(default=None, alias="Links")
|
||||||
meta: dict[str, dict[str, int]] | None = Field(default=None, alias="Meta")
|
meta: dict[str, dict[str, int]] | None = Field(default=None, alias="Meta")
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class SATPhishingScenarios(HuntressModel):
|
|||||||
] | None = Field(default=None, alias="Type")
|
] | None = Field(default=None, alias="Type")
|
||||||
id: str | None = Field(default=None, alias="Id")
|
id: str | None = Field(default=None, alias="Id")
|
||||||
attributes: dict[str, Any] | None = Field(default=None, alias="Attributes")
|
attributes: dict[str, Any] | None = Field(default=None, alias="Attributes")
|
||||||
relationships: dict[str, dict[str, dict[str, str]]] | None = Field(default=None, alias="Relationships")
|
relationships: dict[str, dict[str, dict[str, Any]]] | None = Field(default=None, alias="Relationships")
|
||||||
links: dict[str, str] | None = Field(default=None, alias="Links")
|
links: dict[str, str] | None = Field(default=None, alias="Links")
|
||||||
meta: dict[str, dict[str, int]] | None = Field(default=None, alias="Meta")
|
meta: dict[str, dict[str, int]] | None = Field(default=None, alias="Meta")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user