1 00:00:06,760 --> 00:00:08,300 - [Instructor] Learning to code 2 00:00:08,300 --> 00:00:10,733 and work with programmable infrastructures 3 00:00:10,733 --> 00:00:14,410 is extremely important in today's environment. 4 00:00:14,410 --> 00:00:17,710 You saw the value of using APIs in previous lessons. 5 00:00:17,710 --> 00:00:21,809 You also saw the capabilities of SDN solutions, 6 00:00:21,809 --> 00:00:24,651 and the benefits of an SDN solution. 7 00:00:24,651 --> 00:00:26,670 So whether you actually have configured 8 00:00:26,670 --> 00:00:27,980 a large network in the past 9 00:00:27,980 --> 00:00:29,590 or you're just getting started, 10 00:00:29,590 --> 00:00:30,860 you know that this is actually, 11 00:00:30,860 --> 00:00:34,144 probably, a very challenging task, right? 12 00:00:34,144 --> 00:00:38,660 It involve a lot of clicking around in GUIs, or typing, 13 00:00:38,660 --> 00:00:41,647 or copy and pasting, and many repetitive tasks. 14 00:00:41,647 --> 00:00:46,647 So nowadays, network infrastructure devices and components 15 00:00:48,661 --> 00:00:52,835 are enabled to support APIs 16 00:00:52,835 --> 00:00:55,927 and many programmability capabilities 17 00:00:55,927 --> 00:00:57,928 to complete powerful task 18 00:00:57,928 --> 00:01:00,690 and reduce all that repetitive work, 19 00:01:00,690 --> 00:01:02,720 and save you a lot of time. 20 00:01:02,720 --> 00:01:05,190 So using APIs, you can actually make requests, 21 00:01:05,190 --> 00:01:07,580 like the ones that I'm actually showing in here, 22 00:01:07,580 --> 00:01:10,310 to get a status of an interface, 23 00:01:10,310 --> 00:01:13,529 or get information about the last change that, you know, 24 00:01:13,529 --> 00:01:16,370 that interface was actually changed, 25 00:01:16,370 --> 00:01:19,720 or actually applying different configuration changes 26 00:01:19,720 --> 00:01:21,700 like shutting down the interface, 27 00:01:21,700 --> 00:01:24,483 or shutting down an interface on a thousand devices 28 00:01:24,483 --> 00:01:27,002 at the same time, or enabling an interface 29 00:01:27,002 --> 00:01:29,490 on a thousand devices at the same times, right? 30 00:01:29,490 --> 00:01:33,683 So it allows you to really scale across the organizations. 31 00:01:34,710 --> 00:01:36,764 Now, many modern programming languages, 32 00:01:36,764 --> 00:01:40,940 like Python, and Go, and things like JavaScript, 33 00:01:40,940 --> 00:01:42,739 and Swift, and many others, 34 00:01:42,739 --> 00:01:46,820 are flexible and easier to learn than their predecessors. 35 00:01:46,820 --> 00:01:48,360 Especially Python, right? 36 00:01:48,360 --> 00:01:50,647 A lot of times, you know, I get this question, 37 00:01:50,647 --> 00:01:52,720 "Should I actually learn a programming language 38 00:01:52,720 --> 00:01:53,637 to get into security?" 39 00:01:53,637 --> 00:01:55,960 "Should I learn a programming language 40 00:01:55,960 --> 00:01:57,270 to get into networking?" 41 00:01:57,270 --> 00:01:59,040 And my answer is, "Absolutely." 42 00:01:59,040 --> 00:02:02,700 I always suggest to start with Python. 43 00:02:02,700 --> 00:02:04,458 Python is one of the programming languages 44 00:02:04,458 --> 00:02:06,250 recommended first to learn, 45 00:02:06,250 --> 00:02:08,375 not only because of network programmability, 46 00:02:08,375 --> 00:02:10,010 but many other scenarios. 47 00:02:10,010 --> 00:02:12,572 And it's actually one of the languages that are used 48 00:02:12,572 --> 00:02:17,572 for many different things, from just a quick script, 49 00:02:17,986 --> 00:02:22,986 to automation, to data science, machine learning, and so on. 50 00:02:24,130 --> 00:02:25,380 There are many different sites 51 00:02:25,380 --> 00:02:26,757 that allow you to get started. 52 00:02:26,757 --> 00:02:30,474 And here, I'm actually showing you a few resources. 53 00:02:30,474 --> 00:02:33,812 And I also have, in my GitHub repository, 54 00:02:33,812 --> 00:02:36,330 a lot of different references 55 00:02:36,330 --> 00:02:39,010 that allow you to actually get started with Python. 56 00:02:39,010 --> 00:02:42,661 This training is not a Python class, and it's not gonna, 57 00:02:42,661 --> 00:02:45,590 you know, walk you through how to actually learn Python, 58 00:02:45,590 --> 00:02:47,657 or Go, or Swift, or JavaScript. 59 00:02:47,657 --> 00:02:49,750 But, you know, what I'm doing is, actually, 60 00:02:49,750 --> 00:02:53,492 I'm putting as much information possible 61 00:02:53,492 --> 00:02:56,499 in the GitHub repositories that we have available for you, 62 00:02:56,499 --> 00:02:59,002 that if you're not exposed to these programming languages, 63 00:02:59,002 --> 00:03:01,570 you can actually get started. 64 00:03:01,570 --> 00:03:04,768 Now, combining programming capabilities with developer tools 65 00:03:04,768 --> 00:03:09,036 like get or Git, or GitHub, and GitLab repositories, 66 00:03:09,036 --> 00:03:12,810 and also package management system and virtual environments, 67 00:03:12,810 --> 00:03:14,200 it actually allows you to create 68 00:03:14,200 --> 00:03:18,080 your own set of very powerful tools and workflow. 69 00:03:18,080 --> 00:03:20,749 And later, you're gonna learn more about, actually, 70 00:03:20,749 --> 00:03:22,980 you know, RESTful APIs. 71 00:03:22,980 --> 00:03:25,123 We're gonna go over a brief introduction of Git, 72 00:03:25,123 --> 00:03:27,261 and interpreting basic Python scripts 73 00:03:27,261 --> 00:03:30,002 used to call different security appliances. 74 00:03:30,002 --> 00:03:32,763 And you're gonna learn, also, about pxGrid, 75 00:03:32,763 --> 00:03:36,120 which is a solution that you can take advantage of 76 00:03:36,120 --> 00:03:38,371 to integrate many different capabilities 77 00:03:38,371 --> 00:03:41,835 with devices like the Cisco ISE, 78 00:03:41,835 --> 00:03:44,113 the identity service engine. 79 00:03:44,113 --> 00:03:48,336 Now, another amazing thing is the power of code reuse 80 00:03:48,336 --> 00:03:50,400 and online communities, right? 81 00:03:50,400 --> 00:03:52,536 In the past, if you actually wanted to create some program, 82 00:03:52,536 --> 00:03:54,991 you always have to start from scratch. 83 00:03:54,991 --> 00:03:57,077 But nowadays, you can actually collaborate 84 00:03:57,077 --> 00:04:01,627 and use a lot of open source and a lot of modules, 85 00:04:01,627 --> 00:04:03,530 like I was talking about Python. 86 00:04:03,530 --> 00:04:06,979 So you can take advantage of tons and tons of Python modules 87 00:04:06,979 --> 00:04:11,493 that allows you not only to perform some very quick tasks, 88 00:04:11,493 --> 00:04:14,926 but they're Python modules that are used 89 00:04:14,926 --> 00:04:18,550 for network programmability as well. 90 00:04:18,550 --> 00:04:20,640 For example, here I'm actually showing the package 91 00:04:20,640 --> 00:04:21,530 called requests. 92 00:04:21,530 --> 00:04:23,513 It is a Python package that is installed 93 00:04:23,513 --> 00:04:27,742 using a package manager for Python called pip, right? 94 00:04:27,742 --> 00:04:29,190 And if you're not familiar with pip, 95 00:04:29,190 --> 00:04:30,870 I actually have a reference here for you. 96 00:04:30,870 --> 00:04:34,286 And basically, the requests library allows you to make 97 00:04:34,286 --> 00:04:39,286 HTTP and HTTP requests in Python in very, very easy way. 98 00:04:39,824 --> 00:04:41,336 And the reason that I'm mentioning this 99 00:04:41,336 --> 00:04:45,080 is because Python requests and that package 100 00:04:45,080 --> 00:04:47,282 is actually used a lot nowadays, 101 00:04:47,282 --> 00:04:49,560 whenever we interact with APIs. 102 00:04:49,560 --> 00:04:51,928 So later, whenever we're gonna be introducing APIs 103 00:04:51,928 --> 00:04:55,871 and introducing different Python scripts 104 00:04:55,871 --> 00:04:57,706 to call security appliances 105 00:04:57,706 --> 00:05:00,116 and other devices in the network, 106 00:05:00,116 --> 00:05:03,890 the requests package in Python or the module, 107 00:05:03,890 --> 00:05:06,890 it actually is used fairly often. 108 00:05:06,890 --> 00:05:08,910 And, you know, it will be good for you 109 00:05:08,910 --> 00:05:12,690 to at least become familiar with this package. 110 00:05:12,690 --> 00:05:13,984 For example, here, I'm actually just using 111 00:05:13,984 --> 00:05:17,406 the interactive Python shell interpreter 112 00:05:17,406 --> 00:05:20,618 to import the requests package, 113 00:05:20,618 --> 00:05:24,016 and then send an HTTP GET request to a website. 114 00:05:24,016 --> 00:05:26,510 In this case, it's actually h4cker.org. 115 00:05:26,510 --> 00:05:28,589 And the HTTP request is actually successful, 116 00:05:28,589 --> 00:05:33,589 and that's why you see the 200 message response below. 117 00:05:33,750 --> 00:05:37,310 Now, the W3Schools website has a very good explanation 118 00:05:37,310 --> 00:05:41,530 of the HTTP status code messages, right? 119 00:05:41,530 --> 00:05:45,882 So I mentioned to you the 200 message response. 120 00:05:45,882 --> 00:05:48,055 But I want to actually, at least, 121 00:05:48,055 --> 00:05:51,804 summarize all the response here for your benefit 122 00:05:51,804 --> 00:05:53,500 and for your reference. 123 00:05:53,500 --> 00:05:56,762 The messages in the 100 range are informational. 124 00:05:56,762 --> 00:06:00,400 The 200 range are related to successful transactions, 125 00:06:00,400 --> 00:06:02,014 and that's what you actually want to get 126 00:06:02,014 --> 00:06:07,014 whenever you interact with any HTTP or HTTPS device. 127 00:06:08,230 --> 00:06:09,826 And especially whenever you're interacting 128 00:06:09,826 --> 00:06:11,780 with APIs as well, right? 129 00:06:11,780 --> 00:06:16,780 So we want to get, you know, the status code message 200. 130 00:06:18,196 --> 00:06:20,650 Now, in the 300 range, 131 00:06:20,650 --> 00:06:23,770 that's actually related to HTTP redirection. 132 00:06:23,770 --> 00:06:25,470 So if you actually visit a website 133 00:06:25,470 --> 00:06:27,830 and it redirects you to another one, you might get something 134 00:06:27,830 --> 00:06:32,666 like an HTTP status code of 302, right? 135 00:06:32,666 --> 00:06:35,835 And you also have the messages in the 400 range, 136 00:06:35,835 --> 00:06:38,726 and those are related to client errors. 137 00:06:38,726 --> 00:06:43,726 And the 500 range, those are related to server errors. 138 00:06:43,800 --> 00:06:45,839 Now, I'm spending a little bit of time here 139 00:06:45,839 --> 00:06:50,839 explaining a lot of the HTTP protocol underlying functions. 140 00:06:51,298 --> 00:06:54,001 And the reason for that is because you need to know 141 00:06:54,001 --> 00:06:55,083 or have an understanding 142 00:06:55,083 --> 00:06:57,118 of these functions and functionality 143 00:06:57,118 --> 00:07:00,182 in order to be successful interpreting, 144 00:07:00,182 --> 00:07:03,590 and also interacting, with APIs. 145 00:07:03,590 --> 00:07:06,580 And for, of course, network programmability, right? 146 00:07:06,580 --> 00:07:08,610 Whenever HTTP servers and browsers 147 00:07:08,610 --> 00:07:09,570 communicate to each other, 148 00:07:09,570 --> 00:07:12,640 they perform interactions based on headers, 149 00:07:12,640 --> 00:07:14,142 as well as body content. 150 00:07:14,142 --> 00:07:16,561 Now, the HTTP request, 151 00:07:16,561 --> 00:07:20,110 and in HTTP, there's an HTTP request from the client 152 00:07:20,110 --> 00:07:22,320 and a response from the server. 153 00:07:22,320 --> 00:07:25,690 But in the request, it actually has a different structure. 154 00:07:25,690 --> 00:07:27,030 You have the method, 155 00:07:27,030 --> 00:07:32,030 which is how that request will actually be sent 156 00:07:32,289 --> 00:07:35,573 to the server and the entities, you know? 157 00:07:35,573 --> 00:07:38,750 So things like, for example, GET. A GET request. 158 00:07:38,750 --> 00:07:40,551 And actually, that's used to retrieve information 159 00:07:40,551 --> 00:07:42,160 from the server. 160 00:07:42,160 --> 00:07:44,498 HEAD is basically the same as GET, 161 00:07:44,498 --> 00:07:47,248 but it actually returns only the HTTP headers 162 00:07:47,248 --> 00:07:51,110 and no document body from the server. 163 00:07:51,110 --> 00:07:53,993 You also have POST, which actually sends data to the server, 164 00:07:53,993 --> 00:07:58,660 typically using HTML forms, API requests, and the like. 165 00:07:58,660 --> 00:08:03,179 Now, you also have TRACE to do a message loop-back test 166 00:08:03,179 --> 00:08:06,314 along the path to the target resource. 167 00:08:06,314 --> 00:08:07,604 You also have PUT 168 00:08:07,604 --> 00:08:11,450 to upload a representation of the specified URI. 169 00:08:11,450 --> 00:08:15,030 DELETE, which deletes the specified resource options, 170 00:08:15,030 --> 00:08:18,324 which actually is returning the HTTP methods 171 00:08:18,324 --> 00:08:20,720 that the server supports. 172 00:08:20,720 --> 00:08:23,884 And CONNECT, which converts the request connection 173 00:08:23,884 --> 00:08:27,442 to a transparent TCP/IP tunnel. 174 00:08:27,442 --> 00:08:29,050 And as I mentioned to you, 175 00:08:29,050 --> 00:08:32,240 the server after receiving this request 176 00:08:32,240 --> 00:08:34,020 generates a response, right? 177 00:08:34,020 --> 00:08:36,943 And the server response has three digit status codes 178 00:08:36,943 --> 00:08:39,320 that are a brief, human-readable interpretation 179 00:08:39,320 --> 00:08:40,250 of the status code. 180 00:08:40,250 --> 00:08:43,353 And those are the ones that I explained to you earlier.