Source code for api.pdns.v3.search

"""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": 950, "limit": 734, "responseCode": 200, "count": 218, "data": [{"createdTimestamp": 1491189000, "lastUpdatedTimestamp": 1296141085, "times": 513, "tlp": "white", "query": "Provide crime seven whom.", "answer": "Conference truth free PM smile free.", "minTtl": 442, "maxTtl": 240, "lastSeenTimestamp": 548315225, "firstSeenTimestamp": 888091500, "rrclass": "in", "rrtype": "dname"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Keep Mrs ask will film usually evidence.", "messageTemplate": "Day office none consumer explain while think.", "field": "Everything realize industry possible clearly include relate husband.", "parameter": {}, "timestamp": 876852453}], "currentPage": 641, "size": 284} """ from requests import post from argus_api.exceptions import http url = "https://portal.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