WEBVTT

1
00:00.000 --> 00:00.500 align:middle line:84%


2
00:00.500 --> 00:03.360 align:middle line:90%
So it's time for us to actually
look at a Python script

3
00:03.360 --> 00:05.920 align:middle line:90%
and see what is it that
this Python script does.

4
00:05.920 --> 00:07.060 align:middle line:84%
Here's the spoiler alert.

5
00:07.060 --> 00:09.210 align:middle line:90%
I'll tell you right now
what this script does

6
00:09.210 --> 00:14.310 align:middle line:90%
is it connects to a FirePOWER
Management Center REST API,

7
00:14.310 --> 00:18.210 align:middle line:90%
and it retrieves a
list of applications

8
00:18.210 --> 00:20.580 align:middle line:90%
that FirePOWER Management
Center is monitoring.

9
00:20.580 --> 00:22.350 align:middle line:84%
It is a pretty basic script.

10
00:22.350 --> 00:24.330 align:middle line:90%
There are only a
couple interactions

11
00:24.330 --> 00:25.740 align:middle line:84%
that take place in this script.

12
00:25.740 --> 00:28.680 align:middle line:90%
But still, if you are brand
new to Python and API,

13
00:28.680 --> 00:30.502 align:middle line:90%
this could be a
little overwhelming.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:28.680 --> 00:30.502 align:middle line:90%
this could be a
little overwhelming.

14
00:30.502 --> 00:31.960 align:middle line:90%
So what we're going
to do is, we're

15
00:31.960 --> 00:34.440 align:middle line:90%
going to pull out the sample
code that I've created,

16
00:34.440 --> 00:36.940 align:middle line:90%
and we're going to go
through it one line at a time

17
00:36.940 --> 00:39.188 align:middle line:90%
so that we really
understand what's going on.

18
00:39.188 --> 00:40.980 align:middle line:90%
In the first Nugget
that we're going to do,

19
00:40.980 --> 00:42.522 align:middle line:90%
right now, we're
going to just set up

20
00:42.522 --> 00:45.120 align:middle line:90%
the basics of how the
Python script works

21
00:45.120 --> 00:47.910 align:middle line:90%
by importing what's
called libraries

22
00:47.910 --> 00:50.170 align:middle line:84%
as well as setting up variables.

23
00:50.170 --> 00:53.290 align:middle line:90%
This is a couple of major topics
that make Python really cool,

24
00:53.290 --> 00:54.550 align:middle line:84%
so let's get going.

25
00:54.550 --> 00:57.330 align:middle line:90%
So this is the code that we're
going to be working with.

26
00:57.330 --> 01:00.100 align:middle line:90%
If we scroll down here
for just a second,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

26
00:57.330 --> 01:00.100 align:middle line:90%
If we scroll down here
for just a second,

27
01:00.100 --> 01:02.910 align:middle line:90%
you can see there's a lot
of stuff that's going on

28
01:02.910 --> 01:04.590 align:middle line:84%
right now, and that's OK.

29
01:04.590 --> 01:06.720 align:middle line:90%
It looks a little
complicated and overwhelming,

30
01:06.720 --> 01:07.770 align:middle line:84%
but don't worry.

31
01:07.770 --> 01:09.660 align:middle line:90%
The entire point
of this skill is

32
01:09.660 --> 01:12.420 align:middle line:90%
so that we can read it
and understand what it is

33
01:12.420 --> 01:14.328 align:middle line:84%
that it's really trying to do.

34
01:14.328 --> 01:15.870 align:middle line:90%
Now, as we go through
this, I'm going

35
01:15.870 --> 01:18.962 align:middle line:90%
to show you where you can
actually access this code

36
01:18.962 --> 01:20.920 align:middle line:90%
and what is it trying to
do in the first place.

37
01:20.920 --> 01:22.170 align:middle line:84%
What is it trying to target.

38
01:22.170 --> 01:24.030 align:middle line:84%
Let's set that up right now.

39
01:24.030 --> 01:26.310 align:middle line:90%
You may be looking on
your screen right here,

40
01:26.310 --> 01:27.990 align:middle line:84%
and you see this URL.

41
01:27.990 --> 01:32.490 align:middle line:90%
This is the FirePOWER Management
Center REST API sandbox.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

41
01:27.990 --> 01:32.490 align:middle line:90%
This is the FirePOWER Management
Center REST API sandbox.

42
01:32.490 --> 01:35.610 align:middle line:90%
This exists in the
DevNet sandbox.

43
01:35.610 --> 01:39.630 align:middle line:90%
You can get there by going
to devnetsandbox.cisco.com,

44
01:39.630 --> 01:44.070 align:middle line:90%
and you can reserve a private
instance of the FirePOWER

45
01:44.070 --> 01:45.270 align:middle line:84%
Management Center.

46
01:45.270 --> 01:48.060 align:middle line:90%
All you would then have to
do is change the user name

47
01:48.060 --> 01:50.610 align:middle line:90%
and password later when
we get to that point.

48
01:50.610 --> 01:52.170 align:middle line:90%
Now, don't worry if
any of this stuff

49
01:52.170 --> 01:53.742 align:middle line:90%
seems like
gobbledygook right now.

50
01:53.742 --> 01:55.200 align:middle line:90%
We're actually
going to tackle this

51
01:55.200 --> 01:58.470 align:middle line:90%
in the upcoming few minutes
as we jump into what

52
01:58.470 --> 02:00.130 align:middle line:84%
this code is actually doing.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

52
01:58.470 --> 02:00.130 align:middle line:84%
this code is actually doing.

53
02:00.130 --> 02:02.940 align:middle line:90%
But I just wanted to let you
know that you can actually

54
02:02.940 --> 02:05.850 align:middle line:90%
follow along if you
have Python installed

55
02:05.850 --> 02:09.580 align:middle line:90%
and you have all of the
correct libraries installed.

56
02:09.580 --> 02:11.220 align:middle line:90%
If you don't have
Python installed

57
02:11.220 --> 02:13.230 align:middle line:90%
and you don't have the
libraries installed,

58
02:13.230 --> 02:17.230 align:middle line:90%
we do have content like at CBT
Nuggets on DevNet Associate,

59
02:17.230 --> 02:19.740 align:middle line:90%
where we walk through how
to set these items up.

60
02:19.740 --> 02:22.470 align:middle line:90%
Beyond that, you can follow
along with this exact code

61
02:22.470 --> 02:25.230 align:middle line:90%
by pulling this down from
my GitHub repository.

62
02:25.230 --> 02:27.150 align:middle line:90%
This is publicly
accessible code,

63
02:27.150 --> 02:29.040 align:middle line:90%
and the link is popping
up on the screen

64
02:29.040 --> 02:31.040 align:middle line:90%
so that you can just
browse through this website
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

64
02:29.040 --> 02:31.040 align:middle line:90%
so that you can just
browse through this website

65
02:31.040 --> 02:33.450 align:middle line:90%
and at least look at it,
follow along, copy and paste it

66
02:33.450 --> 02:35.310 align:middle line:90%
into your own VS
Code environment

67
02:35.310 --> 02:37.240 align:middle line:90%
or whatever iEditor
you want to use,

68
02:37.240 --> 02:39.370 align:middle line:90%
and you can follow
along that way.

69
02:39.370 --> 02:41.010 align:middle line:90%
Let's start interpreting
this script.

70
02:41.010 --> 02:42.960 align:middle line:90%
Like we already
said, the purpose

71
02:42.960 --> 02:47.310 align:middle line:90%
of this script, which is
called fmc get apps.py

72
02:47.310 --> 02:50.520 align:middle line:90%
is to give a list
of applications

73
02:50.520 --> 02:54.237 align:middle line:90%
that FirePOWER Management
Center is monitoring.

74
02:54.237 --> 02:56.070 align:middle line:90%
Now, what we're going
to focus on real quick

75
02:56.070 --> 02:58.800 align:middle line:84%
is lines 1 through lines 11.

76
02:58.800 --> 03:00.480 align:middle line:84%
That's this section right here.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

76
02:58.800 --> 03:00.480 align:middle line:84%
That's this section right here.

77
03:00.480 --> 03:02.280 align:middle line:90%
Don't worry about any
of this stuff that's

78
03:02.280 --> 03:03.700 align:middle line:84%
coming up after the fact.

79
03:03.700 --> 03:06.820 align:middle line:90%
We're going to tackle the
script a little bit at a time.

80
03:06.820 --> 03:08.430 align:middle line:90%
And the first thing
you're immediately

81
03:08.430 --> 03:11.170 align:middle line:90%
seeing at the top of the list
are these Import statements.

82
03:11.170 --> 03:12.600 align:middle line:84%
What's that all about?

83
03:12.600 --> 03:15.240 align:middle line:90%
You see, Python
out of the box, it

84
03:15.240 --> 03:17.370 align:middle line:84%
can do a lot of amazing stuff.

85
03:17.370 --> 03:20.860 align:middle line:90%
You just install Python, and
it can do a lot of stuff,

86
03:20.860 --> 03:23.340 align:middle line:84%
but it can't do everything.

87
03:23.340 --> 03:25.440 align:middle line:90%
What we have to do is,
we have to add what's

88
03:25.440 --> 03:27.810 align:middle line:84%
called libraries into Python.

89
03:27.810 --> 03:29.970 align:middle line:90%
These are basically
like plug-ins

90
03:29.970 --> 03:33.360 align:middle line:90%
that extend the
capability of Python.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

90
03:29.970 --> 03:33.360 align:middle line:90%
that extend the
capability of Python.

91
03:33.360 --> 03:36.885 align:middle line:90%
That's why they call Python
an extensible languages.

92
03:36.885 --> 03:39.940 align:middle line:90%
It's because we can add
functionality to it.

93
03:39.940 --> 03:43.020 align:middle line:90%
So when we see
import json, this is

94
03:43.020 --> 03:47.070 align:middle line:90%
taking our default
installation of Python

95
03:47.070 --> 03:51.270 align:middle line:90%
and adding the ability
to work with JSON data

96
03:51.270 --> 03:53.250 align:middle line:84%
in this particular script.

97
03:53.250 --> 03:57.870 align:middle line:90%
When we see import sys, this
is taking our default Python

98
03:57.870 --> 04:00.840 align:middle line:90%
functionality and
adding the ability
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

98
03:57.870 --> 04:00.840 align:middle line:90%
functionality and
adding the ability

99
04:00.840 --> 04:04.410 align:middle line:90%
to work with the actual
system, the actual operating

100
04:04.410 --> 04:05.890 align:middle line:84%
system itself.

101
04:05.890 --> 04:09.420 align:middle line:90%
And when we import requests
here, what request does

102
04:09.420 --> 04:13.050 align:middle line:90%
is this takes the default
Python functionality and adds

103
04:13.050 --> 04:17.910 align:middle line:90%
the ability to
perform HTTP requests.

104
04:17.910 --> 04:21.570 align:middle line:90%
Recall for a moment that a
REST API, the entire point

105
04:21.570 --> 04:25.110 align:middle line:90%
of the REST API is so that
we can work and leverage

106
04:25.110 --> 04:29.940 align:middle line:90%
all of the functionality of the
HTTP protocol to gather data.

107
04:29.940 --> 04:32.940 align:middle line:90%
Remember, way back when we were
talking about how you browse
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

107
04:29.940 --> 04:32.940 align:middle line:90%
Remember, way back when we were
talking about how you browse

108
04:32.940 --> 04:35.430 align:middle line:90%
to a website, and what
a web browser is doing

109
04:35.430 --> 04:38.670 align:middle line:90%
is downloading HTML
documents and CSS documents

110
04:38.670 --> 04:40.710 align:middle line:90%
and JavaScript documents
and turning them

111
04:40.710 --> 04:42.060 align:middle line:84%
into a pretty website.

112
04:42.060 --> 04:44.100 align:middle line:90%
Whereas, an
application will also

113
04:44.100 --> 04:46.500 align:middle line:90%
use HTTP, but instead
of downloading

114
04:46.500 --> 04:49.590 align:middle line:90%
HTML documents, what it
does is it downloads things

115
04:49.590 --> 04:51.060 align:middle line:84%
like JSON documents.

116
04:51.060 --> 04:55.560 align:middle line:90%
Here, you've now seen how
Python adds the ability

117
04:55.560 --> 05:00.490 align:middle line:90%
to work with HTTP and adds the
ability to work with JSON data.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

117
04:55.560 --> 05:00.490 align:middle line:90%
to work with HTTP and adds the
ability to work with JSON data.

118
05:00.490 --> 05:03.640 align:middle line:90%
These import statements
really only exist

119
05:03.640 --> 05:05.560 align:middle line:84%
for this specific script.

120
05:05.560 --> 05:09.520 align:middle line:90%
If I create a new script that
also needs to work with HTTP

121
05:09.520 --> 05:10.970 align:middle line:90%
and also needs to
work with JSON,

122
05:10.970 --> 05:14.133 align:middle line:90%
I've got to specify these
import statements again.

123
05:14.133 --> 05:15.550 align:middle line:90%
So the first thing
you should know

124
05:15.550 --> 05:18.040 align:middle line:90%
when interpreting a
basic Python script

125
05:18.040 --> 05:20.530 align:middle line:90%
is you should look at these
import statements and think,

126
05:20.530 --> 05:24.970 align:middle line:90%
what functionality
am I adding to Python

127
05:24.970 --> 05:26.860 align:middle line:84%
for this particular script?

128
05:26.860 --> 05:28.660 align:middle line:84%
JSON is going to be a big one.

129
05:28.660 --> 05:30.730 align:middle line:90%
Request is going
to be a big one.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

129
05:28.660 --> 05:30.730 align:middle line:90%
Request is going
to be a big one.

130
05:30.730 --> 05:32.890 align:middle line:90%
Some other ones that are
worth pointing out just

131
05:32.890 --> 05:36.730 align:middle line:84%
for the sake of it is ncclient.

132
05:36.730 --> 05:39.100 align:middle line:90%
This is so that you can
write a script that works

133
05:39.100 --> 05:41.260 align:middle line:84%
with the NETCONF protocol.

134
05:41.260 --> 05:43.930 align:middle line:84%
There is also lxml.

135
05:43.930 --> 05:46.780 align:middle line:90%
This is so that you
can work with xml data.

136
05:46.780 --> 05:49.360 align:middle line:90%
If you are an overachiever
and you really

137
05:49.360 --> 05:52.490 align:middle line:90%
want to explore some fun
stuff that Python can do,

138
05:52.490 --> 05:56.980 align:middle line:90%
you can use a library
like openpyxl.

139
05:56.980 --> 05:59.330 align:middle line:90%
This is for working
with Excel files

140
05:59.330 --> 06:02.540 align:middle line:90%
so that you can actually
import data from an Excel file.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

140
05:59.330 --> 06:02.540 align:middle line:90%
so that you can actually
import data from an Excel file.

141
06:02.540 --> 06:05.290 align:middle line:90%
This is a really popular
thing for network engineers

142
06:05.290 --> 06:07.330 align:middle line:90%
because they may have
an Excel file that

143
06:07.330 --> 06:10.420 align:middle line:90%
contains all of their network
devices, IP addresses,

144
06:10.420 --> 06:12.220 align:middle line:84%
usernames, and passwords.

145
06:12.220 --> 06:14.320 align:middle line:90%
So they can import
the Excel file

146
06:14.320 --> 06:16.570 align:middle line:90%
and then log into each
one of those devices

147
06:16.570 --> 06:18.070 align:middle line:84%
and perform some sort of action.

148
06:18.070 --> 06:19.780 align:middle line:90%
It's a really, really
cool thing to do.

149
06:19.780 --> 06:23.170 align:middle line:90%
Lastly, you may want to check
out a library like selenium.

150
06:23.170 --> 06:28.080 align:middle line:90%
Selenium is used to emulate
a web browser like Firefox.

151
06:28.080 --> 06:32.500 align:middle line:90%
So you can have Python launch
a web browser, go to some page,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

151
06:28.080 --> 06:32.500 align:middle line:90%
So you can have Python launch
a web browser, go to some page,

152
06:32.500 --> 06:35.770 align:middle line:90%
parse out the information
using something like selenium,

153
06:35.770 --> 06:39.280 align:middle line:90%
and they would all show up
here on the import statements.

154
06:39.280 --> 06:41.200 align:middle line:90%
The key thing that we're
trying to set up with

155
06:41.200 --> 06:45.250 align:middle line:90%
is if you just install Python
and you don't import something

156
06:45.250 --> 06:48.520 align:middle line:90%
like openpyxl, you can't
work with Excel files.

157
06:48.520 --> 06:51.070 align:middle line:90%
But as soon as you put the
import statements there

158
06:51.070 --> 06:53.560 align:middle line:90%
and you've installed
openpyxl, there you go.

159
06:53.560 --> 06:56.290 align:middle line:90%
You can now work with
Excel files within Python,

160
06:56.290 --> 06:59.510 align:middle line:90%
and that's extending
Python's functionality.

161
06:59.510 --> 07:01.420 align:middle line:90%
So in this particular
script, we now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

161
06:59.510 --> 07:01.420 align:middle line:90%
So in this particular
script, we now

162
07:01.420 --> 07:05.140 align:middle line:90%
see that we're importing the
ability to work with JSON data.

163
07:05.140 --> 07:09.130 align:middle line:90%
We're importing the ability
to work with HTTP endpoints,

164
07:09.130 --> 07:11.320 align:middle line:90%
and we're importing
the ability to perform

165
07:11.320 --> 07:15.580 align:middle line:90%
operating system-style tasks
using those sys libraries.

166
07:15.580 --> 07:19.360 align:middle line:90%
Now, what we need to talk
about is the actual variables

167
07:19.360 --> 07:19.900 align:middle line:84%
themselves.

168
07:19.900 --> 07:22.900 align:middle line:90%
This is a crucial part
to working with Python.

169
07:22.900 --> 07:24.080 align:middle line:84%
Let's talk about that.

170
07:24.080 --> 07:26.770 align:middle line:90%
So the remaining lines that we
have here, or we can see I've

171
07:26.770 --> 07:30.520 align:middle line:90%
got a little comment with
this little pound symbol here
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

171
07:26.770 --> 07:30.520 align:middle line:90%
got a little comment with
this little pound symbol here

172
07:30.520 --> 07:32.170 align:middle line:84%
that says, set up variables.

173
07:32.170 --> 07:35.590 align:middle line:90%
Whenever you see a pound
symbol followed by any text,

174
07:35.590 --> 07:38.290 align:middle line:90%
that's just a comment
in the line of code

175
07:38.290 --> 07:40.420 align:middle line:84%
that Python absolutely ignores.

176
07:40.420 --> 07:43.300 align:middle line:90%
That way, anybody who's
following along or reading

177
07:43.300 --> 07:45.610 align:middle line:90%
your scripts after
the fact can see

178
07:45.610 --> 07:48.370 align:middle line:90%
what's happening in the code
underneath because you've

179
07:48.370 --> 07:50.210 align:middle line:84%
written a little comment here.

180
07:50.210 --> 07:54.310 align:middle line:90%
So let's focus here
on line 6 and line 7.

181
07:54.310 --> 07:58.510 align:middle line:90%
I have this thing called
URL, and then I see a URL.

182
07:58.510 --> 08:02.440 align:middle line:90%
What I can do in Python is
called creating variables.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

182
07:58.510 --> 08:02.440 align:middle line:90%
What I can do in Python is
called creating variables.

183
08:02.440 --> 08:06.340 align:middle line:90%
Rather than typing this
whole URL out multiple times

184
08:06.340 --> 08:09.550 align:middle line:90%
throughout the code,
I can just store it

185
08:09.550 --> 08:12.010 align:middle line:84%
in a little object called URL.

186
08:12.010 --> 08:14.860 align:middle line:90%
So this we can see
is the base URL.

187
08:14.860 --> 08:18.400 align:middle line:90%
It's
fmcrestapisandbox.cisco.com,

188
08:18.400 --> 08:22.270 align:middle line:90%
and then the endpoint
is the login your URL.

189
08:22.270 --> 08:24.850 align:middle line:90%
This is what gets tacked
on to the end of it.

190
08:24.850 --> 08:29.590 align:middle line:90%
The key thing here is that I
can have a base URL called URL,

191
08:29.590 --> 08:31.690 align:middle line:90%
and then I can
change the endpoint
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

191
08:29.590 --> 08:31.690 align:middle line:90%
and then I can
change the endpoint

192
08:31.690 --> 08:34.909 align:middle line:90%
by specifying a different
endpoint after the fact.

193
08:34.909 --> 08:38.200 align:middle line:90%
If we skip ahead, you can see
exactly where I've done this.

194
08:38.200 --> 08:40.780 align:middle line:90%
You can see I've got
your URL, and then we

195
08:40.780 --> 08:44.290 align:middle line:90%
concatenate login URL
right to the end of it.

196
08:44.290 --> 08:45.700 align:middle line:90%
The beautiful
thing about this is

197
08:45.700 --> 08:48.220 align:middle line:90%
I don't have to type
all of this long text

198
08:48.220 --> 08:50.620 align:middle line:90%
over and over and over
again throughout my code.

199
08:50.620 --> 08:54.802 align:middle line:90%
I can just specify it by
using URL or login your URL.

200
08:54.802 --> 08:56.260 align:middle line:90%
And in the next
Nugget, we're going

201
08:56.260 --> 08:59.208 align:middle line:90%
to talk about getting
logged in to the API.

202
08:59.208 --> 09:01.000 align:middle line:90%
That's actually what
we're setting up here,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

202
08:59.208 --> 09:01.000 align:middle line:90%
That's actually what
we're setting up here,

203
09:01.000 --> 09:02.560 align:middle line:90%
and that's what
we're doing first.

204
09:02.560 --> 09:06.640 align:middle line:90%
We're trying to set up how
we get logged in to the API.

205
09:06.640 --> 09:10.270 align:middle line:90%
You see, an API is no different
from any other secure website

206
09:10.270 --> 09:13.120 align:middle line:90%
where you have to log in
before you can do stuff.

207
09:13.120 --> 09:16.060 align:middle line:90%
Wouldn't it be terrible if our
FirePOWER Management Center

208
09:16.060 --> 09:19.520 align:middle line:90%
device was open to the public
and anybody could get data out

209
09:19.520 --> 09:20.020 align:middle line:84%
of it?

210
09:20.020 --> 09:21.250 align:middle line:84%
That would be bad.

211
09:21.250 --> 09:25.180 align:middle line:90%
That's why we have to secure
our API by getting logged in.

212
09:25.180 --> 09:28.660 align:middle line:90%
So to help me build this
request so that I get logged in,

213
09:28.660 --> 09:30.970 align:middle line:90%
I've created two
little variables here,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

213
09:28.660 --> 09:30.970 align:middle line:90%
I've created two
little variables here,

214
09:30.970 --> 09:34.150 align:middle line:90%
one that specifies the base
URL that I can reuse over

215
09:34.150 --> 09:38.710 align:middle line:90%
and over again and then the
specific login URL that says,

216
09:38.710 --> 09:42.400 align:middle line:90%
we're going to be logging
in and generating a token.

217
09:42.400 --> 09:43.900 align:middle line:90%
Now, I'm not going
to jump ahead too

218
09:43.900 --> 09:46.750 align:middle line:90%
much because the next Nugget
is all about getting logged in

219
09:46.750 --> 09:48.400 align:middle line:84%
and handling that login request.

220
09:48.400 --> 09:50.680 align:middle line:90%
But just know that for
now, what we're doing is

221
09:50.680 --> 09:53.440 align:middle line:90%
we're setting up variables
that hold the URL as well

222
09:53.440 --> 09:54.970 align:middle line:84%
as a couple other things.

223
09:54.970 --> 09:57.340 align:middle line:90%
Headers are another
very important part

224
09:57.340 --> 09:59.480 align:middle line:84%
to the HTTP protocol.

225
09:59.480 --> 10:01.760 align:middle line:90%
The headers tell our
endpoint that we're
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

225
09:59.480 --> 10:01.760 align:middle line:90%
The headers tell our
endpoint that we're

226
10:01.760 --> 10:04.760 align:middle line:90%
trying to connect
to what kind of data

227
10:04.760 --> 10:08.150 align:middle line:90%
are we trying to send in,
what kind of data are we

228
10:08.150 --> 10:09.650 align:middle line:84%
trying to retrieve.

229
10:09.650 --> 10:12.020 align:middle line:90%
When you see content
type, this is

230
10:12.020 --> 10:17.330 align:middle line:90%
saying we are sending
in content of JSON data.

231
10:17.330 --> 10:18.830 align:middle line:90%
And again, we're
going to talk more

232
10:18.830 --> 10:20.840 align:middle line:90%
about that in the next
Nugget when we're talking

233
10:20.840 --> 10:21.950 align:middle line:84%
about getting logged in.

234
10:21.950 --> 10:23.840 align:middle line:90%
This is, again, just
setting up that we're

235
10:23.840 --> 10:27.950 align:middle line:90%
specifying our headers in
a variable that specifies

236
10:27.950 --> 10:29.850 align:middle line:84%
all of this information.

237
10:29.850 --> 10:32.880 align:middle line:90%
Lastly, we have a
username and a password.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

237
10:29.850 --> 10:32.880 align:middle line:90%
Lastly, we have a
username and a password.

238
10:32.880 --> 10:35.640 align:middle line:90%
Now, these are hard coded
into the code itself,

239
10:35.640 --> 10:37.853 align:middle line:90%
and that's a big no-no
in security world.

240
10:37.853 --> 10:39.770 align:middle line:90%
We've already talked
about that when we talked

241
10:39.770 --> 10:41.550 align:middle line:84%
about how to secure our code.

242
10:41.550 --> 10:43.800 align:middle line:90%
This is just for
demonstration purposes,

243
10:43.800 --> 10:46.190 align:middle line:90%
and this is, again,
using something

244
10:46.190 --> 10:47.420 align:middle line:84%
in the DevNet sandbox.

245
10:47.420 --> 10:50.210 align:middle line:90%
If you are following along and
you're reserving the FirePOWER

246
10:50.210 --> 10:52.160 align:middle line:90%
Management Center
in DevNet sandbox,

247
10:52.160 --> 10:54.770 align:middle line:90%
you'll receive an email
that has your user name

248
10:54.770 --> 10:56.820 align:middle line:90%
and a randomly
generated password.

249
10:56.820 --> 11:00.530 align:middle line:90%
This password changes every time
you reserve the DevNet sandbox.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

249
10:56.820 --> 11:00.530 align:middle line:90%
This password changes every time
you reserve the DevNet sandbox.

250
11:00.530 --> 11:02.330 align:middle line:90%
So to recap what's
happening here,

251
11:02.330 --> 11:04.843 align:middle line:90%
we're focusing on just these
first few lines of code,

252
11:04.843 --> 11:06.260 align:middle line:90%
and what we see
here is that we've

253
11:06.260 --> 11:09.770 align:middle line:90%
got our import statements, which
are adding the functionality

254
11:09.770 --> 11:14.360 align:middle line:90%
to work with HTTP, to work with
JSON in this particular script.

255
11:14.360 --> 11:17.360 align:middle line:90%
Then we're setting up
variables throughout the code.

256
11:17.360 --> 11:20.390 align:middle line:90%
That way we don't have to
retype all of these things

257
11:20.390 --> 11:21.740 align:middle line:84%
over and over again.

258
11:21.740 --> 11:24.020 align:middle line:84%
I can just type the word URL.

259
11:24.020 --> 11:26.060 align:middle line:90%
I can just type
the word headers,

260
11:26.060 --> 11:28.670 align:middle line:90%
and it refers back
to all of this stuff

261
11:28.670 --> 11:30.950 align:middle line:90%
that we're storing
in the variable.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

261
11:28.670 --> 11:30.950 align:middle line:90%
that we're storing
in the variable.

262
11:30.950 --> 11:33.200 align:middle line:90%
So that's been setting up
the first batch of our code.

263
11:33.200 --> 11:34.825 align:middle line:90%
In the next Nugget,
we're going to dive

264
11:34.825 --> 11:37.580 align:middle line:90%
deep into how we get
logged in to this API.

265
11:37.580 --> 11:39.500 align:middle line:90%
I hope this has been
informative for you,

266
11:39.500 --> 11:42.220 align:middle line:90%
and I'd like to thank
you for viewing.
