Skip to content

RobW3LGA/BGPLookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BGPLookup Build Status

A sandcastle built with a bulldozer.

Project: Build a CLI tool using Python

This started out as a simple project to build a Python utility library and explore WebAPI and RESTConf. The result was an experiment into async calls using Click/AsyncClick, HTTPX, pydantic for strong typing and pytest as an intro to dependency injection and Functional Python

All API calls are provided by BGPView. For valid data, try Postman to view https://api.bgpview.io/search

Installation

Python version check (minimum) from a virtual environment session:

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>python --version
Python 3.6.10

Install into virtual environment session after download/clone:

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>pip install -e ./BGPLookup-master
...

Examples

Example One (and a good starting point):

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>bgplookup --help
Usage: bgplookup [OPTIONS] [DATAKEYS]...

Options:
  --asn INTEGER            Target host is 'https://api.bgpview.io'.
                           Provide details for given ASN (1-64496).
                           Follow with optional datakeys (space separated).
  --peers                  Provide peer details for given ASN.
  -ix, --exchange INTEGER  Provide details for given Inet Exchange (1-853).
                           Follow with optional datakeys (space separated).
  --prefix TEXT            The base IP address/Length of the announced prefix.
                           Follow with optional datakeys (space separated).
  --debug                  Output the raw JSON response, if received.
  -v, --version            Show version and exit.
  --help                   Show this message and exit.

Example Two:

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>bgplookup --asn 61138

This command is the equivalent to the API call: https://api.bgpview.io/asn/61138

Example Three:

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>bgplookup --asn 61138 --peers

This command is the equivalent to the API call: https://api.bgpview.io/asn/61138/peers

Example Four:

(0.1.0) C:\[Projects Folder]\bgplookup-project\0.1.0>bgplookup --prefix 192.209.63.0/24 ASNS RIR_ALLOCATION IANA_ASSIGNMENT

For a bit of fun, the challenge was to isolate and display selected first-level data groups

Special thank you to the fine folks at World Wide Technology for the guidance and inspiration

About

A sandcastle built with a bulldozer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages