Free CCNP 350-401 ENCOR Complete Course: 6.4: REST APIs Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- In this video, we're going to discuss REST APIs or Representational State Transfer application programming interfaces. Long name, basically short name REST APIs. Application programming interfaces allow us to get one application to interact with another application. As an example, if you want to use the functionality of Google Maps rather than developing your own mapping system, you can integrate Google Maps with your application and then you can send queries to Google Maps using an application and then get responses back from Google Maps. REST APIs are used everywhere! It's really important that you learn the basics of REST APIs, you have to have an understanding of REST APIs and have an understanding of DNA Center. In this video however, I'm gonna show you how you can interact with a Cisco device using a REST API and a Python script. So we're gonna write Python script that interacts with the REST API on a Cisco router. If you want to differentiate yourself from others it's well worth learning REST APIs, well worth learning Python. (upbeat techno music playing) - Okay APIs are used everywhere. You probably use then all the time without realizing. Applications talk to other applications using application programming interfaces. These are becoming more and more and more important. It's a very difficult for applications to share information using non-structured data. In a separate video, I spoke about JSON and how you need to use JSON formatting to share information between devices. Structured data is really important! Having a structured application programming interface is really important, if you want machines talking to machines. Here's an example, notice that lamp. I press a button on my phone, it goes off. This is a Hue Lamp, it has an exposed API. Now because of APIs, I can once again do this. Alexa, turn off David Office Old Big Lamp. - Okay. - Notice the lamp when off. Very simple example of an API. Alexa, turn on David Office Old Big Lamp. - Okay. - Alexa, Off! So, that's an example of one program talking to another program. We've got a Hue lamp system, we've got Alexa and they are talking to each other and application programming interfaces allow me to do interesting things like that. Where I can get one device to interact with another device and do something. Now I'm going to cover this section differently to other instructors. Too many of them say connect to this Dev Net server but they're using a Pre Bolt application or Pre Bolt information and it's very difficult to replicate what they're doing if you don't download Pre Bolt stuff from Cisco DevNet. So I wanna show you this from the ground up. I wanna show you how you can interact with REST APIs without using Pre Bolt stuff that's been downloaded. I'm gonna show you how to download an application called Postman. I'm gonna show you how you can manually update Postman with IP addresses and other information, not using Pre Bolt stuff. So I'm gonna show you how you can overcome some issues that you will encounter if you do this manually rather than using Pre Bolt stuff. There's an issue with certificates, as an example. You have to tell Postman to accept self-signed certificates otherwise it wont' interact with the devices that are using self-signed certificates. We're gonna manually configure IP addresses rather than, once again using Pre Bolt stuff. But to make it easier for you, I've created this entire PowerPoint Presentation. In this PowerPoint Presentation, I've given you links to Cisco's DevNet labs. So the DevNet DNA Center always on Labs, the URL is here. Here is the username and here is the password. So you can simply download this PowerPoint Presentation and use it. All the links are here that I'm using. All the information is within this document. As an example, here's the API documentation. A question people often ask is, "How do I know what APIs to use?" Well there's an example of the API documentation for DNA center. There's also a DevNet Lab that you can follow if you want to. So if you want to go through one of the DevNet Labs, there is a good example of a DevNet Lab. But what I'm gonna show you as an example is how to connect to labs manually. So we're going to use Postman, which is an application I'll show you in a moment how to download. It allows you very easily to interact with APIs, allows you to do some basic testing and check for issues. Really good application for testing APIs. So I'm gonna show you the URL to connect to. I'll show you how to bypass the issue with self-signed certificates. You need to turn this off, otherwise you will have problems. If you try and connect to some of their labs, it's not going to work because you need to turn this off otherwise Postman by default rejects the connection. All the username and password information is within this document. And I'm showing you step by step what to do. I'm gonna demonstrate it practically using a video. So I'm gonna show you how to do this but I've also given you this entire PowerPoint Presentation so that you can keep this as reference for later. I've also included a Python script. So this is a very basic Python script that allows me to connect to a Cisco router. And this example, we're going to connect to a Cisco xe router. We're going to connect to this router on this port number and then we gonna get a list of interfaces from the router using an API. So I really hope this helps you. If you follow along in this video, you should get a really good understanding. And I'll show you step by step how to interact with both DNA Center as well as with an xe router, in other words with a Cisco router. But you can download this PowerPoint Presentation and have it as as reference to really help you, after you've watched these videos. Six months from today, you might just wanna have this as a reference. Now you can use SSH to simple SSH to a router and configure a router. The problem is when you type 'show version' or 'show IP interface brief' that data that's displayed is for human consumption. In other words, humans will understand the information but machines will struggle with the information that's displayed. If they show version command as run on different routers; Cisco Nexus, Cisco IOS, Classic IOS, Monolithic IOS versus xe then the output will be slightly different and machines will struggle with that output. What you really want, is that my application can talk to your application using and exposed and well documented API. Now that's the theory! In reality, APIs change. In reality, not all devices use the same API. So if you talk to DNA Center the APIs that it uses will be different to IOS xe router. And it can change from version to version. That is a frustration of APIs. But longterm, hopefully Cisco will standardize the APIs more and more. This is where the world is going. We are no longer gonna manually configure devices using a CLI. We're gonna have applications interacting with other applications and programming other applications. So my program will program that program in the same way that an Alexa can be used to interact with many devices out there. Now there's some theory with regards to REST. I'm gonna quickly go through it now. Don't get hung up about the theory! Jump to the next video if the theory is a bit boring. You're gonna learn more if I show you the stuff practically. I've given you the PowerPoint slide that contains some useful information. So download that if you want to uh for reading later or for studying. But you're going to learn much more if you just do it. Don't read about it. If you do it practically the stuff will make sense. So if you find this boring, please go to the next video. Do it practically and then you can come back to the theory. (upbeat happy music playing) - Now the first question is, "What is REST?" And a great place to look for good information is RESTfulAPI.net. And we're told that REST is an acronym for REpresentational State Transfer. It is an architectural style for distributed hypermedia systems that was first presented by Roy Fielding in 2000 in his famous dissertation. They've got a link to his dissertation. And you can read this whole dissertation to get an idea of what it's about. He talks about how it's Client-Server and it's Stateless, Caching is supported and a whole bunch of other detailed information. So if you really want to get into it, you can have a look at this. But let's just summarize it. I wanna go through this fairly quickly and actually show you practically how it works because you'll learn a lot more if you see it practically rather than just looking at some theory. First thing is it's Client-server, by separating the user interface concerns from the data storage concerns, we improve the portability of the user interface across multiple platforms. It's basically a client talking to a server. So I've got a PC talking to a server, client-server model, similar to what we do with HTTP. I wanna go to Facebook.com or some kind of web server, I've got a client running on my computer here, MAC, and I'm connecting to the server. I send a get, I get back a bunch of information that's then displayed on my web browser interface. It's stateless. Each request from client to server must contain all the information necessary to understand the request. And it cannot take advantage of stored context on the server. Session state is therefore entirely kept on the client. That's very different to SOAP, which was an older way of implementing APIs in an enterprise. In that example, state information is maintained on the server. Here we don't maintain state on the server. Everything needs to be maintained on the client. Its also cacheable. Cache constraints require that data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable, then a client cache is given the right to reuse that response data for later equivalent requests. You may have come across cacheing on your web browser many many times. Data is cache by web browsers. Happens a lot! If I want to force a page to refresh, as an example, I have to press Ctrl+R on a MAC. You sometimes have to reforce a refresh of the page because stale information will be stored on your local computer. So something could be changed on your server but you don't see the changes on your PC. So on Windows and other browsers you have to press Ctrl+F5 to refresh the page and force a download of all the elements, such as the pictures and other information rather than using a locally stored cache of some of the information. So we might not want everything stored in cache so REST APIs as an example and web servers will allow information to be cached on the local client rather than pulling everything from the server every time I go to a web page or I make an API call Okay, so that's enough about the principles. Have a read of this if you're interested. They also talk about a resource, key abstraction of information in REST is a resource. Any information that can be named can be a resource. Which could be a document, an image, a service, a collection of resources, etc. etc. So I would suggest you have a quick read of some of this. But you're gonna learn a lot more if I just demonstrate this practically, so that's what I'm gonna do. Now something else you'll come across is CRUD, which in computer programming means Create Read Update and Delete. And are four basic functions of persistent storage. These are four actions performed by an application. We could create something on a server. We could read data from the server. We could update something on the server and we can delete information on the server. Now I'm gonna demonstrate the use of Postman in a moment. But notice, here we've got GET, here we've got POST, here we've got DELETE, we've got PATCH we've got other what are known as HTTP verbs. So POST will allow me to create new data structures and variables. That's the C in CRUD for create. GET allows me to read or retrieve verbal name structures or values. PATCH and PUT allow me to update or replace values of some variable. And DELETE, fairly easy to understand, allows me to delete variables and data structures. Now Postman, an application that we're going to use in a moment has those HTTP verbs but it's not gonna mean much to you just by reading about this stuff. It means a lot more if we just do it, so I'm gonna show you practically how to do it. (upbeat techno music playing)
Info
Channel: David Bombal
Views: 29,170
Rating: undefined out of 5
Keywords: encor, ccnp, rest, rest api, restful api, 350-401, python, json, ccna, ccnp encor, ccnp enterprise, ccnp training, new ccnp, ccnp study, cisco certifications, cisco training, cisco, cisco certified network professional, ccnp certification, encor 350-401, ccnp automation, ccie, ccie encor, cisco ccnp exam, ccie enterprise, cisco certification 2020, cisco ccnp, cisco encor training, cisco encor exam, 2020 ccnp, ccnp review, cisco ccna, ccna study, ccna training, cisco encor test
Id: 5iA_ZBcFwEU
Channel Id: undefined
Length: 13min 49sec (829 seconds)
Published: Thu May 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.