Client
psengine.asi.client
¶
ASIClient
¶
ASIClient(
api_token: Union[str, None] = None,
http_proxy: str = None,
https_proxy: str = None,
verify: Union[str, bool] = None,
auth: tuple[str, str] = None,
cert: Union[str, tuple[str, str], None] = None,
timeout: int = None,
retries: int = None,
backoff_factor: int = None,
status_forcelist: list = None,
pool_max_size: int = None,
)
Bases: BaseHTTPClient
Recorded Future ASI Attack Surface Intelligence API client.
| PARAMETER | DESCRIPTION |
|---|---|
api_token
|
A Recorded Future ASI API key.
TYPE:
|
http_proxy
|
An HTTP proxy URL.
TYPE:
|
https_proxy
|
An HTTPS proxy URL.
TYPE:
|
verify
|
An SSL verification flag or path to CA bundle.
TYPE:
|
auth
|
Basic Auth credentials.
TYPE:
|
cert
|
Client certificates.
TYPE:
|
timeout
|
A request timeout. Defaults to 120.
TYPE:
|
retries
|
A number of retries. Defaults to 5.
TYPE:
|
backoff_factor
|
A backoff factor. Defaults to 1.
TYPE:
|
status_forcelist
|
A list of status codes to force a retry. Defaults to [502, 503, 504].
TYPE:
|
pool_max_size
|
The maximum number of connections in the pool. Defaults to 120.
TYPE:
|
Source code in psengine/asi/client.py
backoff_factor
instance-attribute
¶
http_proxy
instance-attribute
¶
https_proxy
instance-attribute
¶
pool_max_size
instance-attribute
¶
status_forcelist
instance-attribute
¶
status_forcelist = (
status_forcelist
if status_forcelist is not None
else client_status_forcelist
)
call
¶
call(
method: str,
url: str,
data: Union[dict, list[dict], bytes, None] = None,
*,
params: Union[dict, None] = None,
headers: Union[dict, None] = None,
**kwargs,
) -> Response
Invoke an HTTP request using the requests library.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
An HTTP method.
TYPE:
|
url
|
A URL to make the request to.
TYPE:
|
data
|
A request body.
TYPE:
|
params
|
HTTP query parameters.
TYPE:
|
headers
|
If specified, overrides default headers and does not set the token.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If method is not one of GET, PUT, POST, DELETE, HEAD, OPTIONS, PATCH. |
HTTPError
|
If the response status is not 2xx. |
JSONDecodeError
|
If the response contains malformed JSON. |
ConnectTimeout
|
If the connection to the server times out. |
ConnectionError
|
If the request fails before completing. |
ReadTimeout
|
If the server did not send any data in time. |
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A requests.Response object. |
Source code in psengine/base_http_client.py
can_connect
¶
Check if the client can reach the specified API URL.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
An HTTP method.
TYPE:
|
url
|
A URL to test.recordedfuture.com.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if connection returns status 200, else False. |
Source code in psengine/base_http_client.py
request
¶
request(
method: str,
url: str,
data: Union[dict, list[dict], bytes, None] = None,
*,
params: Optional[dict] = None,
headers: Optional[dict] = None,
**kwargs,
) -> Response
Perform an HTTP request against Recorded Future ASI.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
An HTTP method, one of GET, PUT, POST, DELETE, HEAD, OPTIONS, PATCH.
TYPE:
|
url
|
A URL or API path to make the request to.
TYPE:
|
data
|
A request body.
TYPE:
|
params
|
HTTP query parameters.
TYPE:
|
headers
|
If specified, it overrides default headers and does not set the API key.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Response
|
A requests.Response object. |
Source code in psengine/asi/client.py
request_paged
¶
request_paged(
method: str,
url: str,
data: Optional[dict] = None,
*,
params: Optional[dict] = None,
headers: Optional[dict] = None,
max_results: int = DEFAULT_LIMIT,
objects_per_page: Optional[int] = Field(
ge=1,
le=MAX_ASI_PAGE_SIZE,
default=DEFAULT_ASI_PAGE_SIZE,
),
**kwargs,
) -> dict[str, Any]
Perform a paged request using ASI cursor-based pagination.
Automatically handles cursor-based pagination internally, aggregating all pages
up to max_results.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
An HTTP method. Supports GET and POST.
TYPE:
|
url
|
A URL or API path to make the request to.
TYPE:
|
data
|
A request body.
TYPE:
|
params
|
HTTP query parameters.
TYPE:
|
headers
|
If specified, it overrides default headers and does not set the API key.
TYPE:
|
max_results
|
The maximum number of results to return.
TYPE:
|
objects_per_page
|
Requested page size.
TYPE:
|
Example response structure
The data field contains records aggregated from all fetched pages.
The meta field is copied from the last fetched page.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Paged records merged into a single dictionary. |
Source code in psengine/asi/client.py
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 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 | |
set_urllib_log_level
¶
Set log level for urllib3 library.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
A log level to be set: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.
TYPE:
|
Source code in psengine/base_http_client.py
is_api_token_format_valid
¶
Check if the token format is valid.
The function performs a simple regex check but does not validate the token against the API.
| PARAMETER | DESCRIPTION |
|---|---|
token
|
A Recorded Future ASI API token.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the token format is valid, False otherwise. |