How to use the greynoise.__version__.__version__ function in greynoise

To help you get started, we’ve selected a few greynoise 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 GreyNoise-Intelligence / pygreynoise / tests / cli / test_subcommand.py View on Github external
def test_version(self):
        """Version returned."""
        runner = CliRunner()
        expected_output = "greynoise {}".format(__version__)

        result = runner.invoke(subcommand.version)
        assert result.exit_code == 0
        assert result.output.startswith(expected_output)
github GreyNoise-Intelligence / pygreynoise / src / greynoise / api.py View on Github external
:param endpoint: Endpoint to send the request to.
        :type endpoint: str
        :param params: Request parameters.
        :type param: dict
        :param json: Request's JSON payload.
        :type json: dict
        :returns: Response's JSON payload
        :rtype: dict
        :raises RequestFailure: when HTTP status code is not 2xx

        """
        if params is None:
            params = {}
        headers = {
            "User-Agent": "GreyNoise/{}".format(__version__),
            "key": self.api_key,
        }
        url = "/".join([self.BASE_URL, self.API_VERSION, endpoint])
        LOGGER.msg(
            "Sending API request...", url=url, params=params, json=json, level="debug"
        )
        response = self.session.get(
            url, headers=headers, timeout=self.timeout, params=params, json=json
        )

        if "application/json" in response.headers.get("Content-Type", ""):
            body = response.json()
        else:
            body = response.text

        if response.status_code == 429:
github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / subcommand.py View on Github external
def version():
    """Get version and OS information for your GreyNoise commandline installation."""
    click.echo(
        "greynoise {}\n"
        "  Python {}\n"
        "  {}\n".format(__version__, platform.python_version(), platform.platform())
    )
github GreyNoise-Intelligence / pygreynoise / src / greynoise / api / __init__.py View on Github external
:type endpoint: str
        :param params: Request parameters
        :type param: dict
        :param json: Request's JSON payload
        :type json: dict
        :param method: Request method name
        :type method: str
        :returns: Response's JSON payload
        :rtype: dict
        :raises RequestFailure: when HTTP status code is not 2xx

        """
        if params is None:
            params = {}
        headers = {
            "User-Agent": "GreyNoise/{}".format(__version__),
            "key": self.api_key,
        }
        url = "/".join([self.api_server, self.API_VERSION, endpoint])
        LOGGER.debug(
            "Sending API request...", url=url, method=method, params=params, json=json
        )
        request_method = getattr(self.session, method)
        response = request_method(
            url, headers=headers, timeout=self.timeout, params=params, json=json
        )
        content_type = response.headers.get("Content-Type", "")
        if "application/json" in content_type:
            body = response.json()
        else:
            body = response.text