network-api

network-api

Introduction

network-api is a tool that can be used to interact with your network using REST API calls. It can be used to expose your network to developers who are more familiar with REST API framework without having to understand the underlying protocol and complexities of interacting with the network programmatically.

Technology Stack

The tool uses the following technologies to provide a simple API interface to interact with the network.

  • FastAPI as a web framework for building APIs.
  • NAPALM to interact with the actual network devices.

Application Architecture

The application architecture can be illustrated in the below drawing:

No alt text provided for this image

The application flow can be characterised as below:

  1. The clients interact with the network-api tool using HTTP GET requests. The HTTP GET request is served by the FastAPI application.
  2. The FastAPI application invoked the appropriate NAPALM function to interact with the network devices.
  3. The NAPALM function gets the details of the network device like IP address, username and password from the local inventory file.
  4. The NAPALM function uses ssh as the transport protocol to connect to the network device and execute its getter.
  5. The NAPALM function returns the output of the getter to the FastAPI application.
  6. The FastAPI application returns the output to the client.

API Documentation

FastAPI automatically generates interactive API documentation. The generated documentation follows the Swagger 2.0 specification.

A screen shot of the generated API documentation is as below:

No alt text provided for this image

Sampel Output

You can interact with the application using your choice of a web-browser or an API platform like Postman or simple curl commands.

For the sake of representation, below are screenshots of the GET /facts and GET /interfaces endpoints using Postman.

device_facts

No alt text provided for this image

interfaces

No alt text provided for this image

Project Repository

If you are keen to test the application, the code base with detailed instructions on how to install it and replicate it to your environment can be found here.

Teach me your waaaaaaays oh wise yoda 🙌🏻

Interesting concept. Please keep posting about it 🙂

Nice, thank you very much for sharing.

To view or add a comment, sign in

More articles by Sudarshan V

  • HashiCorp Vault + Python

    Intro The simplest use case of HashiCorp Vault is to use it as a secrets manager to store your secrets in a secure and…

  • Ansible + Microsoft Excel (Custom module)

    Here is my first attempt at writing a custom Ansible Module. Synopsis This module writes a list of dictionaries into an…

    2 Comments
  • Network Configuration Analyser

    In my short experience working as a Network and Security Consultant, I have constantly found myself interacting with…

    5 Comments

Others also viewed

Explore content categories