msticpy/sectools/tiproviders/http_base.py
def lookup_ioc(  # type: ignore
        self, ioc: str, ioc_type: str = None, query_type: str = None, **kwargs
    ) -> LookupResult:
        """
        Lookup a single IoC observable.

        Parameters
        ----------
        ioc : str
            IoC observable
        ioc_type : str, optional
            IocType, by default None (type will be inferred)
        query_type : str, optional
            Specify the data subtype to be queried, by default None.
            If not specified the default record type for the IoC type
            will be returned.

        Returns
        -------
        LookupResult
            The lookup result:
            result - Positive/Negative,
            details - Lookup Details (or status if failure),
            raw_result - Raw Response
            reference - URL of IoC

        Raises
        ------
        NotImplementedError
            If attempting to use an HTTP method or authentication
            protocol that is not supported.

        Notes
        -----
        Note: this method uses memoization (lru_cache) to cache results
        for a particular observable to try avoid repeated network calls for
        the same item.

        """
        result = self._check_ioc_type(
            ioc=ioc, ioc_type=ioc_type, query_subtype=query_type
        )

        result.provider = kwargs.get("provider_name", self.__class__.__name__)
        if result.status:
            return result

        req_params: Dict[str, Any] = {}
        try:
            verb, req_params = self._substitute_parms(
                result.safe_ioc, result.ioc_type, query_type
            )
            if verb == "GET":
                response = self._requests_session.get(**req_params)
            else:
                raise NotImplementedError(f"Unsupported verb {verb}")
            result.status = response.status_code
            result.reference = req_params["url"]
            if result.status == 200:
                try:
                    result.raw_result = response.json()
                    result.result, severity, result.details = self.parse_results(result)
                except JSONDecodeError:
                    result.raw_result = f"""There was a problem parsing results from this lookup:
                                        {response.text}"""
                    result.result = False
                    severity = TISeverity.information
                    result.details = {}
                result.set_severity(severity)
                result.status = TILookupStatus.ok.value
            else:
                result.raw_result = str(response)
                result.result = False
                result.details = self._response_message(result.status)
            return result
        except (  # pylint: disable=duplicate-code
            LookupError,
            JSONDecodeError,
            NotImplementedError,
            ConnectionError,
        ) as err:
            self._err_to_results(result, err)
            if not isinstance(err, LookupError):
                url = req_params.get("url", None) if req_params else None
                result.reference = url
            return result

        Lookup a single IoC observable.

        Parameters
        ----------
        ioc : str
            IoC observable
        ioc_type : str, optional
            IocType, by default None (type will be inferred)
        query_type : str, optional
            Specify the data subtype to be queried, by default None.
            If not specified the default record type for the IoC type
            will be returned.

        Returns
        -------
        LookupResult
            The lookup result:
            result - Positive/Negative,
            details - Lookup Details (or status if failure),
            raw_result - Raw Response
            reference - URL of IoC

        Raises
        ------
        NotImplementedError
            If attempting to use an HTTP method or authentication
            protocol that is not supported.

        Notes
        -----
        Note: this method uses memoization (lru_cache) to cache results
        for a particular observable to try avoid repeated network calls for
        the same item.

        
Lookup a single IoC observable.
Parameters

ioc : str
IoC observable
ioc_type : str, optional
IocType, by default None (type will be inferred)
query_type : str, optional
Specify the data subtype to be queried, by default None.
If not specified the default record type for the IoC type
will be returned.

Returns

LookupResult
The lookup result:
result - Positive/Negative,
details - Lookup Details (or status if failure),
raw_result - Raw Response
reference - URL of IoC

Raises

NotImplementedError
If attempting to use an HTTP method or authentication
protocol that is not supported.

Notes

this method uses memoization (lru_cache) to cache results
for a particular observable to try avoid repeated network calls for
the same item.
Lookup a single IoC observable . Parameters ioc : str IoC observable ioc_type : str optional IocType by default None ( type will be inferred ) query_type : str optional Specify the data subtype to be queried by default None . If not specified the default record type for the IoC type will be returned . Returns LookupResult The lookup result : result - Positive / Negative details - Lookup Details ( or status if failure ) raw_result - Raw Response reference - URL of IoC Raises NotImplementedError If attempting to use an HTTP method or authentication protocol that is not supported . Notes this method uses memoization ( lru_cache ) to cache results for a particular observable to try avoid repeated network calls for the same item .
def lookup_ioc(  
        self, ioc: str, ioc_type: str = None, query_type: str = None, **kwargs
    ) -> LookupResult:
        result = self._check_ioc_type(
            ioc=ioc, ioc_type=ioc_type, query_subtype=query_type
        )
        result.provider = kwargs.get("provider_name", self.__class__.__name__)
        if result.status:
            return result
        req_params: Dict[str, Any] = {}
        try:
            verb, req_params = self._substitute_parms(
                result.safe_ioc, result.ioc_type, query_type
            )
            if verb == "GET":
                response = self._requests_session.get(**req_params)
            else:
                raise NotImplementedError(f"Unsupported verb {verb}")
            result.status = response.status_code
            result.reference = req_params["url"]
            if result.status == 200:
                try:
                    result.raw_result = response.json()
                    result.result, severity, result.details = self.parse_results(result)
                except JSONDecodeError:
                    result.raw_result = f"""There was a problem parsing results from this lookup:
                                        {response.text}"""
                    result.result = False
                    severity = TISeverity.information
                    result.details = {}
                result.set_severity(severity)
                result.status = TILookupStatus.ok.value
            else:
                result.raw_result = str(response)
                result.result = False
                result.details = self._response_message(result.status)
            return result
        except (  
            LookupError,
            JSONDecodeError,
            NotImplementedError,
            ConnectionError,
        ) as err:
            self._err_to_results(result, err)
            if not isinstance(err, LookupError):
                url = req_params.get("url", None) if req_params else None
                result.reference = url
            return result
def lookup_ioc ( self , ioc : str , ioc_type : str = None , query_type : str = None , ** kwargs ) -> LookupResult : result = self . _check_ioc_type ( ioc = ioc , ioc_type = ioc_type , query_subtype = query_type ) result . provider = kwargs . get ( "provider_name" , self . __class__ . __name__ ) if result . status : return result req_params : Dict [ str , Any ] = { } try : verb , req_params = self . _substitute_parms ( result . safe_ioc , result . ioc_type , query_type ) if verb == "GET" : response = self . _requests_session . get ( ** req_params ) else : raise NotImplementedError ( f"Unsupported verb {verb}" ) result . status = response . status_code result . reference = req_params [ "url" ] if result . status == 200 : try : result . raw_result = response . json ( ) result . result , severity , result . details = self . parse_results ( result ) except JSONDecodeError : result . raw_result = f"""There was a problem parsing results from this lookup:
                                        {response.text}""" result . result = False severity = TISeverity . information result . details = { } result . set_severity ( severity ) result . status = TILookupStatus . ok . value else : result . raw_result = str ( response ) result . result = False result . details = self . _response_message ( result . status ) return result except ( LookupError , JSONDecodeError , NotImplementedError , ConnectionError , ) as err : self . _err_to_results ( result , err ) if not isinstance ( err , LookupError ) : url = req_params . get ( "url" , None ) if req_params else None result . reference = url return result
Lookup a single IoC observable.
Lookup a single IoC observable .
# type: ignore """
        Lookup a single IoC observable.

        Parameters
        ----------
        ioc : str
            IoC observable
        ioc_type : str, optional
            IocType, by default None (type will be inferred)
        query_type : str, optional
            Specify the data subtype to be queried, by default None.
            If not specified the default record type for the IoC type
            will be returned.

        Returns
        -------
        LookupResult
            The lookup result:
            result - Positive/Negative,
            details - Lookup Details (or status if failure),
            raw_result - Raw Response
            reference - URL of IoC

        Raises
        ------
        NotImplementedError
            If attempting to use an HTTP method or authentication
            protocol that is not supported.

        Notes
        -----
        Note: this method uses memoization (lru_cache) to cache results
        for a particular observable to try avoid repeated network calls for
        the same item.

        """ # pylint: disable=duplicate-code
self
ioc
str
ioc_type
str
query_type
str