How to use the ipinfo.icon_ipinfo.actions.ip_lookup.schema.Input.IP function in ipinfo

To help you get started, we’ve selected a few ipinfo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / ipinfo / icon_ipinfo / actions / ip_lookup / action.py View on Github external
def run(self, params={}):

        # Set variables
        ip = params.get(Input.IP)
        token = self.connection.token
        server = self.connection.domain

        # Check if token is provided and set correct URL
        if token:
            url = f"{server}{ip}/json?token={token}"
            self.logger.info('API token was provided by user')
        else:
            url = f"{server}{ip}/json"

        # Make request
        request = requests.get(url)
        dic = request.json()
        return dic