Metadata-Version: 2.1
Name: simple-netbox
Version: 0.1.1
Summary: Simple REST-client for Netbox
Home-page: https://github.com/jinjamator/simple_netbox
Author: Wilhelm Putz
Author-email: wilhelm.putz@cancom.com
License: ASL V2
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: System :: Installation/Setup
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE

Introduction
==================

simple_netbox is a simplified REST Client for Netbox



Features
-----------------

simple_netbox has following features:
    * manage login
    * simple CRUD via ensure_exists and ensure_absent helper functions
    * auto add slug on creation of objects if not supplied 
    * CRUD interface for all possible API URLs
    * create curl commands from all calls (for documentation purposes)

Installation
------------

Install simple_netbox by running:

.. code-block:: bash

    pip3 install simple_netbox


Examples
---------

CRUD a site
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python
    
    from simple_netbox import NetboxClient
    import logging
    from getpass import getpass
    import secrets
    import string

    logger = logging.getLogger()
    logging.basicConfig(encoding="utf-8", level=logging.INFO)


    URL=input("Please Enter Netbox URL: ") or "http://localhost:8000"
    token=input("Please Enter the Netbox token: ") or "not set"


    nb = NetboxClient(URL,token=token,log_curl_commands=True)

    logging.info("list all sites")
    logging.info(nb.api.dcim.sites.list()) # alternativly nb.api.dcim.sites.get() can be used


    logging.info("create site demo1, slug will be autogenerated if not supplied") 

    site_id=nb.api.dcim.sites.create(body={"name":"demo1"})["id"] # alternativly nb.api.dcim.sites.post() can be used 

    logging.info("to filter results on server side following syntax can be used")

    logging.info(nb.api.dcim.sites.list(params={"name":"demo1"})) # alternativly nb.api.dcim.sites.get() can be used


    nb.api.dcim.sites.patch(site_id,body={"description":"demo1 desc"})

    logging.info(f"delete site demo1 (id:{site_id})") 

    nb.api.dcim.sites.delete(site_id)


    logging.info(f"create site demo2 via ensure_exists")

    nb.api.dcim.sites.ensure_exists(name="demo2")

    logging.info(f"update site demo2 via ensure_exists")

    nb.api.dcim.sites.ensure_exists(name="demo2", description="nice location")

    logging.info(f"delete site demo2 via ensure_absent")

    nb.api.dcim.sites.ensure_absent(name="demo2")

    print(nb.api.curl_commands)


Contribute
----------

- Issue Tracker: https://github.com/jinjamator/simple_netbox/issues
- Source Code: https://github.com/jinjamator/simple_netbox

Roadmap
-----------------

Selected Roadmap items:
    * add more documentation
    * add some more examples

For documentation please refer to https://simple_netbox.readthedocs.io/en/latest/

License
-----------------

This project is licensed under the Apache License Version 2.0

