Giter Club home page Giter Club logo

pynautobot's Introduction

pynautobot

Pynautobot build main

Python API client library for Nautobot.

Pynautobot was initially developed as a fork of pynetbox. Pynetbox was originally developed by Zach Moody at DigitalOcean and the NetBox Community.

The complete documentation for pynautobot can be found at Read the Docs.

Questions? Comments? Join us in the #nautobot Slack channel on Network to Code!

Installation

You can install via pip or poetry

Using pip

$ pip install pynautobot
...

Using poetry

$ git clone https://github.com/nautobot/pynautobot.git
...
$ pip install poetry
...
$ poetry shell
Virtual environment already activated: /home/user/pynautobot/.venv
$ poetry install
...

Quick Start

A short introduction is provided here; the full documention for pynautobot is at Read the Docs.

To begin, import pynautobot and instantiate an Api object, passing the url and token.

import pynautobot
nautobot = pynautobot.api(
    url="http://localhost:8000",
    token="d6f4e314a5b5fefd164995169f28ae32d987704f",
)

The Api object provides access to the Apps in Nautobot. The Apps provide access to the Models and the field data stored in Nautobot. Pynautobot uses the Endpoint class to represent Models. For example, here is how to access Devices stored in Nautobot:

devices = nautobot.dcim.devices
devices
<pynautobot.core.endpoint.Endpoint object at 0x7fe801e62fa0>

Queries

Pynautobot provides several ways to retrieve objects from Nautobot. Only the get() method is show here. To continue from the example above, the Endpoint object returned will be used to get the device named hq-access-01.

switch = devices.get(nam="hq-access-01")

The object returned from the get() method is an implementation of the Record class. This object provides access to the field data from Nautobot.

switch.id
'6929b68d-8f87-4470-8377-e7fdc933a2bb'
switch.name
'hq-access-01'
switch.site
hq

Threading

Pynautobot supports multithreaded calls for .filter() and .all() queries. It is highly recommended you have MAX_PAGE_SIZE in your Nautobot install set to anything except 0 or None. The default value of 1000 is usually a good value to use. To enable threading, add threading=True parameter when instantiating the Api object:

nautobot = pynautobot.api(
    url="http://localhost:8000",
    token="d6f4e314a5b5fefd164995169f28ae32d987704f",
    threading=True,
)

Related projects

Please see our wiki for a list of relevant community projects.

pynautobot's People

Contributors

abringenberg avatar david-kn avatar dgarros avatar dimaqa avatar explody avatar fach avatar fragmentedpacket avatar funzoneq avatar h-otter avatar ignatenkobrain avatar jakubkrysl avatar jdrew82 avatar jeremystretch avatar jerradgit avatar jifox avatar jifoxpa avatar jmcgill298 avatar jqueuniet avatar jsenecal avatar jvanderaa avatar lamiskin avatar mandarg avatar markkuleinio avatar raddessi avatar stefanmcshane avatar tweippert avatar tyler-8 avatar victorpavlushin avatar vincentbernat avatar weisdd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.