Plugs: https://learninglabs.cisco.com Coding 101 Lab Coding 102 Lab

Slides:



Advertisements
Similar presentations
Building and using REST information services Rion Dooley.
Advertisements

Building RESTful Interfaces
1Proprietary and Confidential AirVantage API – Getting started David SCIAMMA – June 13th 2014.
Definitions, Definitions, Definitions Lead to Understanding.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CSCI 323 – Web Development Chapter 1 - Setting the Scene We’re going to move through the first few chapters pretty quick since they are a review for most.
IT 210 The Internet & World Wide Web introduction.
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
Beyond the UI Using Tools to Improve Testing Jeremy Traylor
JavaScript & jQuery the missing manual Chapter 11
© 2011 Autodesk Automating Autodesk® Revit® Server Rod Howarth Software Development Manager – Bornhorst + Ward.
FTP (File Transfer Protocol) & Telnet
2013Dr. Ali Rodan 1 Handout 1 Fundamentals of the Internet.
Designing and Implementing Web Data Services in Perl
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
WEB API: WHY THEY MATTER ECOL 453/ Nirav Merchant
Copyright © Orbeon, Inc. All rights reserved. Erik Bruchez Applications of XML Pipelines XML Prague, June 16 th, 2007.
CSCI 6962: Server-side Design and Programming Web Services.
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Or, Hey can’t we just do it using HTTP for the envelope?
Copyright © Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential. Drupal Web Services 1 Authored by: Chaitanya Anil Kulkarni Presented.
RESTful Web Service 2014 년 12 월 한연희
1 Seminar on Service Oriented Architecture Principles of REST.
Integrating and Troubleshooting Citrix Access Gateway.
A FIRST TOUCH ON NOSQL SERVERS: COUCHDB GENOVEVA VARGAS SOLAR, JAVIER ESPINOSA CNRS, LIG-LAFMIA, FRANCE
Copyright © 2012 UNICOM Systems, Inc. Confidential Information z/Ware Product Overview illustro Systems International A Division of UNICOM Global.
Google Data Protocol Guy Mark Lifshitz. Motivation Google’s Mission: – Organize the world’s information – Make information universally accessible – Provide.
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
How to Deploy and Configure the Smart Net Total Care CSPC Collector
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
Advanced Web Technologies Lecture #4 By: Faraz Ahmed.
Introduction to Web Services
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
ICM – API Server & Forms Gary Ratcliffe.
RESTful Web Services What is RESTful?
ICM – API Server Gary Ratcliffe. 2 Agenda Webinar Programme API Server Overview JSON-RPC iCM API Service API Server and Forms New services under.
RESTful Web Services A MIDAS MISSION PRESENTATION APRIL 29, 2015.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
Overview of Servlets and JSP
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 7 Omar Meqdadi Department of Computer Science and Software Engineering University of.
© 2015 Cisco System Inc. All rights reserved Cisco Confidential 1 © 2015 Cisco System Inc. All rights reserved. 1 Subject Line Customization for Notifications.
Feeling RESTful? Well, first we’ll define a Web Service –A web page meant to be consumed by a computer via an autonomous program as opposed to a web browser.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
National College of Science & Information Technology.
Web Development. Agenda Web History Network Architecture Types of Server The languages of the web Protocols API 2.
Lesson 11: Web Services and API's
SDN controllers App Network elements has two components: OpenFlow client, forwarding hardware with flow tables. The SDN controller must implement the network.
The Client-Server Model
API (Application Program Interface)
Content from Python Docs.
Node.js Express Web Applications
z/Ware 2.0 Technical Overview
Data Virtualization Tutorial… CORS and CIS
Node.js Express Web Services
An introduction to REST for SharePoint 2013
Lesson 11: Web Services & API's
Testing REST IPA using POSTMAN
WEB API.
$, $$, $$$ API testing Edition
Testing RESTful Web APIs
Python and REST Kevin Hibma.
Web-Services and RESTful APIs
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Plugs: https://learninglabs.cisco.com Coding 101 Lab Coding 102 Lab Use Coding 102 for system setup help: Chrome A text editor (text wrangler, notepad ++, sublime text etc.) Postman REST Client -- http://www.getpostman.com/ Python Go to command prompt and type python Install instructions -- http://learnpythonthehardway.org/book/ex0.html Python Requests library -- http://docs.python-requests.org

More Plugs: learninglabs.cisco.com Check these out

What We Know

Easier Network Element Management REST / JSON is the answer of the day Customers Demand Easier Network Element Management

The Evolution of Device Interaction Bootstrap Configure Extend Plug n Play PoAP Smart Install Auto Install CLI Controllers Openstack Puppet/Chef REST JSON RPC NETCONF CLI I2RS onePK OpenFlow Onbox Python EEM Evolving First – categorize the different APIs/protocols/frameworks into buckets. Some cross buckets, some enable technologies in other buckets, but in general, they are all optimized for particular kinds of tasks. Bootstrap – day one configuration Configure – into the capabilities of the network device Extending what you can do with the device. Dynamic programming, also sometimes used to do configuration Generally speaking optimized for extension Look from bottom up. CLI is tool of choice for bootstrap and configure. Middle bucket is where we want to concentrate on. By far the most things people want is a configurator, and to handle configuration tasks. Solve immediate pain points Traditional

REST Follows a Familiar Model Web Browsing REST API Twitter: IDs of last five followers {"ids":[303776224, 19449911, 607032789, 86544242, 2506725913, 17631389], "next_cursor":0, "next_cursor_str":"0", "previous_cursor":0, "previous_cursor_str":"0"} HTTP GET HTTP GET HTML JSON/XML Here is an example of a rest call to twitter This is a real return value Describes how data should be displayed to please human viewer Describes data in a format applications can understand

REST is An Architectural Style (Not a protocol) REST= REpresentational State Transfer Proposed by Roy Fielding in 2000 Developed by W3C in parallel with HTTP 1.1 Simple CRUD using HTTP Stateless client-server model Uses URIs to identify resources of interest Rest its an architectural style, it is not a protocol it is a suggestion on how to behave works over crud ( Create, Read, Update, Delete)

There Are LOTS of RESTful APIs Thousands of programs use rest apis

Why Does This Matter for Networking? Easy to use Why Does This Matter for Networking? Human Readable Software Friendly Large Developer Base Client Libraries in Many Languages Lot of people that can program rest Easy

REST: It’s Not Just for Web Services Products and applications can consume restful apis Even at cisco Vmware ucs ucs-director, open daylight

REST: Coming Soon to a Device Near You Supported on CSR1kV since XE 3.10 ASR1K in XE 3.14 Primarily for Config DNS, NTP, Interface, Routing, ACL, NAT Some Stats Interface, CPU, Memory Runs in a service container Uses onePK Python APIs under the hood Seeing experimentation on bringing rest apis to you Csr1kv Kind of limited now but being built out

Sample: Grab Hosts from APIC-EM Application Policy Infrastructure Controller (APIC) Enterprise Module (EM) 3rd Party App Request Response 3rd Party App GET http://{APIC-EMController}/api/v0/host/{start}/{no. rec} List of Hosts returned in JSON Cisco APIC-EM Request Response

Anatomy of a REST Request Method GET, POST, PUT, DELETE URL Example: http://{APIC-EMController}/api/v0/host/1/3 Authentication Basic HTTP, OAuth, none Custom Headers HTTP Headers Example: Content-Type: application/json Request Body JSON or XML containing data needed to complete request JSON -- JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. http://www.json.org/

And what is in the Response? HTTP Status Codes http://www.w3.org/Protocols/HTTP/HTRESP.html 200 OK 201 Created 500 Internal Error Headers Body JSON XML

REST in Action: How can I try it? HTTP clients can help you quickly test web services Postman - http://www.getpostman.com/ Firefox RestClient - https://addons.mozilla.org/en-US/firefox/addon/restclient/ Command Line using curl - http://curl.haxx.se/docs/httpscripting.html#GET SOAPUI Many IDEs have consoles for testing REST Services built in

Cost

REST Demo – Using Postman

REST Demo – Using Postman

REST Demo – Using Postman Get Hosts Method: GET URL: http://APIC-EMController/api/v0/host/{startIndex}/{recordsToReturn} Get Devices URL: http://APIC-EMController/api/v0/network-device/{startIndex}/{recordsToReturn} Get Policies URL: http://APIC-EMController/api/v0/policy/{startIndex}/{recordsToReturn} Get Applications URL: http://APIC-EMController/api/v0/application/{startIndex}/{recordsToReturn}

REST DEMO – Using the POST or PUT Method To send data to a REST service and either create or update data, you will need to use POST or PUT. Create Policy Example Method: POST URL: http://APIC-EMController/api/v0/policy Custom Headers: Content-Type: application/json Request Body: JSON that specifies details of new policy What if the Content-Type header is missing? What if there is a mistake in the JSON Request Body? Handy tool for validating JSON -- http://jsonlint.com/

REST Demo – Using POST or PUT Method Show what happens if you forget the Content-Type Header

First REST call from Python Source code file: apic-em1.py #import requests library import requests #specify URL url = 'http://Your-API-EM-Controller/api/v0/host’ #Call REST API response = requests.get(url) #Print Response print response.text More info on requests library - http://docs.python-requests.org/en/latest/index.html

Python Examples Download Sample Code https://github.com/CiscoDevNet/coding-skills-sample-code Coding 102 apic-em1.py – simple example to get list of hosts apic-em-helloworld.py – “hello world” type example to show list of devices learning-lab-basics.py – Retrieves device list and pretty prints JSON learning-lab-basics-step2.py – Retrieves network device list and parses JSON to display networkDeviceId values learning-lab-basics-step3.py – Retrieves and lists all devices, hosts, policies and configured applications learning-lab-create-policy.py – Shows how to create a new policy using the POST Method

AD-HOC REST (REST like) Interface Leverage existing automation technology Brownfield

Bonus JSON-RPC

Comparison: REST/JSON-RPC Similar: Both Send/Receive JSON over HTTP JSON-RPC (N9K NX-API) REST (CSR 1000v) Both send and receive json over http Sometimes they seem the same Differences are not that important

Comparison: REST/JSON-RPC Different: Resources (URIs) REST: Many Resources https://172.6.1.118/api/v1… …/global/banner …/global/hostname …/global/reload …/interfaces/… …/routing-svc/… …/nat-svc/… …/acl/… … JSON-RPC: Few Resources https://10.10.10.8/ins Differences between them Rest operates on the idea of these different resources acls/interfaces… Resources for each thing you want to do Json has much fewer resources CSR1kV N9K

Different: Methods GET: Retrieve/List PUT: Replace REST: Standard HTTP Methods GET: Retrieve/List PUT: Replace POST: Create New Entry DELETE: Delete JSON-RPC: POST + body method Rest only uses standard http methods Json rpc uses post. And puts information in the body of what you should do

JSON-RPC Details A very simple remote procedure call protocol encoded in JSON, sent over HTTP http://www.jsonrpc.org/specification JSON RPC Request Properties method – (string) name of the method to be invoked. params – (array) objects to be passed as parameters to the defined method. Id – (any type) used to match the response with request JSON RPC Response Properties result - data returned by the invoked method. error - specified Error code if there was an error invoking the method, otherwise null. id - id of the corresponding request.

NXAPI Switch# conf t Switch(config)# feature nxapi CLI Interaction with device over HTTP / HTTPS Input/Output encoded in JSON or XML (key for programmability) [ { "jsonrpc": "2.0", "method": "cli", "params": { "cmd": "show clock", "version": 1 }, "id": 1 } ] Show clock NXAPI Web Server (NGINX) Switch# conf t Switch(config)# feature nxapi Switch(config)# exit HTTP / HTTPS { "jsonrpc": "2.0", "result": { "body": { "simple_time": "15:00:37.762 PST Mon Aug 18 2014\n" } }, "id": 1

NXAPI – Web Sandbox Point browser to IP Address of Network Element Enter CLI Commands See formatted input and output

NXAPI – Python Generation Click on the Python button, and the tool will generate python Interaction code for you.