Bases: object
The Broker handles validation and submission of requests as well as consumption and returning of the result. It is leveraged by the other classes.
Since the Broker takes care of the entire request/response cycle, it can be used on its own to interact with the ThreatExchange API without the need for the other classes if a developer wishes to use it.
Validate arguments and convert them into GET parameters.
| Parameters: |
|
|---|---|
| Returns: | dict |
Send a DELETE request.
| Parameters: | |
|---|---|
| Returns: | dict (using json.loads()) |
Send a GET request.
| Parameters: | |
|---|---|
| Returns: | dict (using json.loads()) |
Generator for managing GET requests. For each GET request it will yield the next object in the results until there are no more objects. If the GET response contains a ‘next’ value in the ‘paging’ section, the generator will automatically fetch the next set of results and continue the process until the total limit has been reached or there is no longer a ‘next’ value.
| Parameters: | |
|---|---|
| Returns: | Generator |
Return a new instance of klass.
| Parameters: |
|
|---|---|
| Returns: | new instance of klass |
Handle the results of a request.
| Parameters: | resp (response object) – The HTTP response. |
|---|---|
| Returns: | dict (using json.loads()) |
Verifies the timestamp provided is a valid timestamp.
Valid timestamps are based on PHP’s “strtotime” function. As of right now even with python’s “dateutil” library there are some strtotime valid strings that do not validate properly. Until such a time as this can become accurate and robust enough to have feature parity with strtotime, this will always return True and leave proper timestamps to the API user.
| Parameters: | timestamp (str) – Value to verify is a timestamp. |
|---|---|
| Returns: | True |
Send a POST request.
| Parameters: | |
|---|---|
| Returns: | dict (using json.loads()) |
If strict_text is provided, sanitize it.
‘true’ will be used if strict_text is in [True, ‘true’, ‘True’, 1]. ‘false’ will be used if strict_text is in [False, ‘false’, ‘False’, 0].
If we receive any other value strict_text will be set to None and ignored when building the GET request.
| Parameters: | strict_text (bool, str, int) – The value to sanitize. |
|---|---|
| Returns: | str, None |