Manager
psengine.classic_alerts.classic_alert_mgr.ClassicAlertMgr
¶
Alert Manager for Classic Alert (v3) API.
PARAMETER | DESCRIPTION |
---|---|
rf_token
|
Recorded Future API token.
TYPE:
|
Source code in psengine/classic_alerts/classic_alert_mgr.py
fetch
¶
fetch(
id_: str = Field(min_length=4),
fields: Optional[list[str]] = ALL_CA_FIELDS,
tagged_text: Optional[bool] = None,
) -> ClassicAlert
Fetch a specific alert.
The alert can be saved to a file as shown below:
PARAMETER | DESCRIPTION |
---|---|
id_
|
The alert ID to be fetched.
TYPE:
|
fields
|
Fields to include in the search result. Note:
Defaults fields are
TYPE:
|
tagged_text
|
Entities in the alert title and message body will be marked up with entity IDs.
TYPE:
|
Example
Endpoint
v3/alerts/{id_}
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertFetchError
|
If a fetch of the alert via the API fails. |
RETURNS | DESCRIPTION |
---|---|
ClassicAlert
|
ClassicAlert model. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
fetch_all_images
¶
fetch_all_images(alert: ClassicAlert) -> None
Fetch all images from an alert and store them in the alert object under @images
.
PARAMETER | DESCRIPTION |
---|---|
alert
|
Alert to fetch images from.
TYPE:
|
Endpoint
v3/alerts/image
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
fetch_bulk
¶
fetch_bulk(
ids: list[str],
fields: Optional[list[str]] = ALL_CA_FIELDS,
tagged_text: Optional[bool] = None,
max_workers: Optional[int] = 0,
) -> list[ClassicAlert]
Fetch multiple alerts.
PARAMETER | DESCRIPTION |
---|---|
ids
|
Alert IDs that should be fetched.
TYPE:
|
fields
|
Fields to include in the search result. Note:
Defaults fields are
TYPE:
|
tagged_text
|
Entities in the alert title and message body will be marked up with entity IDs.
TYPE:
|
max_workers
|
Number of workers to multithread requests.
TYPE:
|
Example
Alternatively, save all alerts to a single file:
Endpoint
v3/alerts/{id_}
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertFetchError
|
If a fetch of the alert via the API fails. |
RETURNS | DESCRIPTION |
---|---|
list[ClassicAlert]
|
List of ClassicAlert models. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
fetch_hits
¶
fetch_hits(
ids: Union[str, list[str]],
tagged_text: Optional[bool] = None,
) -> list[ClassicAlertHit]
Fetch a list of all the data that caused the alert to trigger (hits).
PARAMETER | DESCRIPTION |
---|---|
ids
|
One or more alert IDs to fetch.
TYPE:
|
tagged_text
|
Entities in the alert title and message body will be marked up with entity IDs.
TYPE:
|
Endpoint
v3/alerts/hits
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertFetchError
|
If a fetch of the alert hit via the API fails. |
RETURNS | DESCRIPTION |
---|---|
list[ClassicAlertHit]
|
List of ClassicAlertHit models. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
fetch_image
¶
Fetch an image.
PARAMETER | DESCRIPTION |
---|---|
id_
|
Image ID to fetch, for example: img:d4620c6a-c789-48aa-b652-b47e0d06d91a
TYPE:
|
Endpoint
v3/alerts/image
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertImageFetchError
|
If a fetch of the alert image via the API fails. |
RETURNS | DESCRIPTION |
---|---|
bytes
|
Image content. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
fetch_rules
¶
fetch_rules(
freetext: Union[str, list[str], None] = None,
max_results: int = Field(
default=DEFAULT_LIMIT, ge=1, le=1000
),
) -> list[AlertRuleOut]
Search for alerting rules.
PARAMETER | DESCRIPTION |
---|---|
freetext
|
Filter by a freetext search.
TYPE:
|
max_results
|
Maximum number of rules to return. Maximum 1000.
TYPE:
|
Endpoint
v2/alert/rules
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type or value. |
NoRulesFoundError
|
If a rule has not been found. |
RETURNS | DESCRIPTION |
---|---|
list[AlertRuleOut]
|
List of AlertRule models. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
search
¶
search(
triggered: Optional[str] = None,
status: Optional[str] = None,
rule_id: Union[str, list[str], None] = None,
freetext: Optional[str] = None,
tagged_text: Optional[bool] = None,
order_by: Optional[str] = None,
direction: Optional[str] = None,
fields: Optional[list[str]] = REQUIRED_CA_FIELDS,
max_results: Optional[int] = Field(
ge=1, le=1000, default=DEFAULT_LIMIT
),
max_workers: Optional[int] = Field(
ge=0, le=50, default=0
),
alerts_per_page: Optional[int] = Field(
ge=1, le=1000, default=ALERTS_PER_PAGE
),
) -> list[ClassicAlert]
Search for triggered alerts.
Does pagination requests on batches of alerts_per_page
up to max_results
.
PARAMETER | DESCRIPTION |
---|---|
triggered
|
Filter on triggered time. Format: -1d or [2017-07-30,2017-07-31].
TYPE:
|
status
|
Filter on status, such as:
TYPE:
|
rule_id
|
Filter by a specific Alert Rule ID.
TYPE:
|
freetext
|
Filter by a freetext search.
TYPE:
|
tagged_text
|
Entities in the alert title and message body will be marked up.
TYPE:
|
order_by
|
Sort by a specific field, such as:
TYPE:
|
direction
|
Sort direction, such as:
TYPE:
|
fields
|
Fields to include in the search result. Note:
Defaults fields are
TYPE:
|
max_results
|
Maximum number of records to return. Maximum 1000.
TYPE:
|
max_workers
|
Number of workers to use for concurrent fetches.
Applied only when multiple
TYPE:
|
alerts_per_page
|
Number of items to retrieve per page.
TYPE:
|
Warning
Paginating with a high number of items per page may lead to timeout errors from the API.
Endpoint
v3/alerts/
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertSearchError
|
If connection error occurs. |
RETURNS | DESCRIPTION |
---|---|
list[ClassicAlert]
|
List of ClassicAlert models. |
Source code in psengine/classic_alerts/classic_alert_mgr.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
update
¶
Update one or more alerts.
It is possible to update the assignee, statusInPortal
, and a note tied to the alert.
PARAMETER | DESCRIPTION |
---|---|
updates
|
List of updates to perform.
TYPE:
|
Example
Endpoint
v2/alert/update
Source code in psengine/classic_alerts/classic_alert_mgr.py
update_status
¶
Update the status of one or several alerts.
PARAMETER | DESCRIPTION |
---|---|
ids
|
One or more alert IDs.
TYPE:
|
status
|
Status to update to.
TYPE:
|
Endpoint
v2/alert/update
RAISES | DESCRIPTION |
---|---|
ValidationError
|
If any supplied parameter is of incorrect type. |
AlertUpdateError
|
If connection error occurs. |