"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('pdns','v3','search'))
def search_records(query: str = None, rrClass: list = None, rrType: list = None, customerID: list = None, tlp: list = None, limit: int = None, aggregateResult: bool = 'False', includeAnonymousResults: bool = 'False', offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Search against PassiveDNS with criteria and return matching records (PUBLIC)
Search against PassiveDNS with criteria and return matching records. If user exceeds current resource limits, this operation may return status code 402. If that happens, the metaData key millisUntilResourcesAvailable gives a hint as to how long the client needs to wait before attempting again.
:param str query: Lookup query
:param list rrClass: Lookup with specified record classes
:param list rrType: Lookup with specified record types
:param list customerID: Lookup for specified customer IDs
:param list tlp: Lookup with specified TLPs, public usage only TLP white allowed
:param int limit: Max number of results to be returned, default unset means default limit 25 will be used, 0 means unlimited
:param bool aggregateResult: Whether aggregate results (default true)
:param bool includeAnonymousResults: Whether include anonymous results (default true)
:param int offset: Number of results to be skipped first, default 0 (default 0)
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises ResourceLimitExceeded.Exception: on 402
:raises AccessDeniedException: on 403
:returns: {"offset": 590, "limit": 144, "responseCode": 200, "count": 546, "data": [{"createdTimestamp": 551854811, "lastUpdatedTimestamp": 706755618, "times": 772, "tlp": "red", "query": "Artist party instead under left hundred.", "answer": "Party it likely relate leave language firm.", "minTtl": 666, "maxTtl": 90, "lastSeenTimestamp": 515916111, "firstSeenTimestamp": 46287212, "rrclass": "in", "rrtype": "cname"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "He brother education half discussion enough music picture.", "messageTemplate": "Condition nation after positive.", "field": "Color something film chance seek music.", "parameter": {}, "timestamp": 746812648}], "currentPage": 179, "size": 191}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/pdns/v3/search".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if query:
body.update({"query": query})
if aggregateResult:
body.update({"aggregateResult": aggregateResult})
if includeAnonymousResults:
body.update({"includeAnonymousResults": includeAnonymousResults})
if rrClass:
body.update({"rrClass": rrClass})
if rrType:
body.update({"rrType": rrType})
if customerID:
body.update({"customerID": customerID})
if tlp:
body.update({"tlp": tlp})
if limit:
body.update({"limit": limit})
if offset:
body.update({"offset": offset})
response = post(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response