Coder Social home page Coder Social logo

pyrestconf's Introduction

PyRESTCONF

Author: Lisa Roach

Description:

This repository contains a module for making RESTconf calls with python.

You must add your ip address, port, username, and password for the constructor.

Usage:

For PUT, POST, and PATCH, you must have a configuration of JSON or XML formatted using a valid YANG model. If your device does not have the YANG model available, you will not be able to use it. Examples of YANG models can be found here:

OpenConfig: [https://github.com/openconfig/public]

YangModels: [https://github.com/YangModels/yang]

For GET and DELETE you must know the name of the YANG module and container that you wish the make changes too.

#JSON

json_rest_object = JSONRestCalls(ip_address, port, username, password)
response_put = json_rest_object.put(data, 'yang_endpoint:container')
response_get = json_rest_object.get('yang_endpoint:container')

#XML

xml_rest_object = XMLRestCalls(ip_address, port, username, password)
response_put = xml_rest_object.put(data, 'yang_endpoint:container')
response_get = xml_rest_object.get('yang_endpoint:container')

Examples:

#GET (same for DELETE)

rest_object = JSONRestCalls('127.0.0.1', 80, admin, admin)
response = rest_object.get('yang_module:container')
print response.content # prints the GET object as a string
print response.json() # prints the GET object as a dictionary
print response.status_code # prints the status code of the response
print response.reason # prints the reason for the status code

#PUT (works same for POST and PATCH)

rest_object = JSONRestCalls('127.0.0.1', 80, admin, admin)
response = rest_object.put(data, 'bgp:bgp')
print response.status_code
print response.reason # prints the reason for the status code

pyrestconf's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.