Skip to main content

A CLI for RIPEStat

Project description

The RIPEStat CLI

A command line wrapper for the RIPEStat API.

How it Works

ripestat maxmind-geo-lite 193.0.6.158
193.0.6.158/32
╒═══════════╤════════╤══════════════╤════════════╤═════════════════════════════════════════════════╕
│ Country    City    Resources       Coverage  URL                                             │
╞═══════════╪════════╪══════════════╪════════════╪═════════════════════════════════════════════════╡
│ NL                 193.0.0.0/20         100  https://www.google.com/maps/@52.3824,4.8995,12z │
╘═══════════╧════════╧══════════════╧════════════╧═════════════════════════════════════════════════╛

Installation

It's a python program, so you install it with pip:

$ pip install ripe.stat.cli

However, since it's a command-line tool, you might want to consider using pipx to install it, as it will then be automatically added to your ${PATH} and pipx will handle the virtualenv shenanigans for you:

$ pipx install ripe.stat.cli

Tab Completion

One of the nicer quirks of this tool is the tab completion. You can do handy stuff like ripestat ma<tab> and it'll autocomplete ripestat maxmind-geo-lite for you. If you want to enable that, you need a few things:

  1. Install argcomplete. This is a dependency of ripestat-cli, so it'll be available in the virtualenv, but that may not be convenient. You can always install this with your operating system's package manager. Something like apt install python-argcomplete or pacman -S python-argcomplete for example.
  2. Once installed, you just have to enable autocompletion as per the official docs. In short, this means running this on Debian-based systems:
    $ sudo activate-global-python-argcomplete
    
    or this on Arch-based systems:
    $ sudo activate-global-python-argcomplete --dest /usr/share/bash-completion/completions
    
    Alternatively, you can also install it at the user-level by dumping the output of this command into a file that's sourced at login time:
    $ sudo activate-global-python-argcomplete --dest=-
    

Extending

This little project doesn't yet support all of RIPEStat's many, many endpoints, but extending it to do so is quite easy if you're motivated:

  1. Create a folder under ripe/stat/cli/templates named for the endpoint exactly as it appears in the API. For example, the AS Overview folder would be named as-overview because that's what you see in the URL.
  2. In that folder create a file called: spec.json. The contents of which can just be copied from one of the existing folders. The idea is to expand this in the future should we want to support things like sorting or different arguments etc. For now though, it just tells the command handler that we need to accept an argument called resource.
  3. Finally, create a Jinja template in that same folder called template.jinja. This template will be handed the contents of the data portion of the API response. You have all the powers that Jinja grants you in there, so go nuts. If you're looking for inspiration, just look at same file in the other folders.
  4. Optionally, you can also add your own filters to ripe/stat/cli/filters.py. Currently, we have colourise() and as_table() in there, but if you need something special, this is where you probably want to put it.

TODO

For the most part, this does you'd expect -- at least for the few endpoints currently supported. There are two glaring things that really should be done soon though:

  1. Error handling: If the RIPEStat API barks at you with an error, this script should print out a user-friendly message, maybe with some emojis and some nice colour. At the moment, it just explodes.
  2. Tests: There aren't any! Unit tests for each filter & formatter are a bare minimum, but an end-to-end test for each endpoint would be ideal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ripe.stat.cli-0.1.0.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

ripe.stat.cli-0.1.0-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file ripe.stat.cli-0.1.0.tar.gz.

File metadata

  • Download URL: ripe.stat.cli-0.1.0.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.18.7-arch1-1

File hashes

Hashes for ripe.stat.cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c55207df9ccfe20695cdbb932c944685df0f5943e3dda6c490ea09bf4e519b0f
MD5 8d7dc82177ab9fb0a231fdfb4a746090
BLAKE2b-256 50acd4337128fbe6589551475c17e3ab95b8efbb43498b4fdf24bcccf50a9e22

See more details on using hashes here.

File details

Details for the file ripe.stat.cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ripe.stat.cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.18.7-arch1-1

File hashes

Hashes for ripe.stat.cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e5f4f21ae6e6e38e8ea177ecccf95ef585e9f14a574faf82f30d4ec9c236bf0
MD5 cd47901ff8ef268fdf176af59378b13c
BLAKE2b-256 fba62d4292cae3072b3344be74d3944282a94f3ab27191abc64492e2f558cf89

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page