Skip to content

Commit 76fbcba

Browse files
authored
Merge pull request #77 from CiscoDevNet/replace-apic-em
Replace APIC-EM and provide consistency edits on all labs
2 parents b9e7752 + 8f99303 commit 76fbcba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+513
-373
lines changed

labs/coding-101-rest-basics-ga/1.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Coding 101 - REST API Basics
32

43
This Learning Lab explains the basics of using a REST API. It also shows how to use Postman to explore a REST API.
@@ -18,7 +17,7 @@ This Learning Lab explains the basics of using a REST API. It also shows how to
1817
* **username:** devnetuser
1918
* **password:** Cisco123!
2019

21-
## Step 1. Find the DNA Center API Resources and Documentation
20+
## Step 1: Find the DNA Center API Reference documentation
2221

2322
A good starting point to understand any API is to look at the documentation for the API. Now, find documentation for the DNA Center API.
2423

@@ -27,11 +26,13 @@ A good starting point to understand any API is to look at the documentation for
2726
* Click the **Technologies** link to see the submenu.
2827
* Click **Networking**.
2928
* From the list of technologies, click **DNA Center Platform**.
30-
![](/posts/files/coding-101-rest-basics-ga/assets/images/Menu.png)
29+
![](assets/images/Menu.png)
3130

3231
1. On the DNA Center Platform page, click the `Docs` link.
3332
1. Click `API Reference`.
3433
1. Select the latest API version.
3534
1. Keep the DNA Center API Reference documentation open in a separate tab. This page provides a useful reference while you work on this lab.
3635

37-
### Next Step: Learn about the REST web service
36+
### Next step
37+
38+
Proceed to Step 2: So what is a REST web service?

labs/coding-101-rest-basics-ga/2.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Step 2: So what is a REST web service?
22

3-
### What is a Web Service?
3+
### What is a web service?
44

55
A web service is a way for two systems to communicate through a defined interface.
66
There are two major types of web services – **REST** and **SOAP**.
77

8-
### What is a *REST* Web Service?
8+
### What is a REST web service?
99

1010
REST is an architecture style for designing networked applications.
1111
A REST web service is as easy to call as making an HTTP request.
@@ -14,9 +14,9 @@ To know more about REST in general, this is a great [REST definition](https://en
1414

1515
### What are the benefits of REST?
1616

17-
***REST is easy to use on any platform***
17+
***REST is easy to use on any platform.***
1818

19-
![](/posts/files/coding-101-rest-basics-ga/assets/images/RESTisGreat.jpg)
19+
![](assets/images/RESTisGreat.jpg)
2020

2121
### DNA Center API is a REST API
2222

@@ -30,7 +30,7 @@ Look at the [DNA Center documentation](https://developer.cisco.com/site/dna-cent
3030

3131
### How does this work?
3232

33-
![](/posts/files/coding-101-rest-basics-ga/assets/images/howitworks.jpg "How it Works")
33+
![](assets/images/howitworks.jpg)
3434

3535
REST is centered around the HTTP request and response model. Consuming an API is as simple as making an HTTP request.
3636

@@ -40,4 +40,6 @@ In this example, you request the list of hosts, and that information is returned
4040

4141
* [XML](https://www.w3schools.com/xml/xml_whatis.asp) - XML, or eXtensible Markup Language, a language designed to store and transport data.
4242

43-
### Next Step: HTTP response and request facts
43+
### Next step
44+
45+
Proceed to Step 3: What do I need to know to make a request?

labs/coding-101-rest-basics-ga/3.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Choose one of the following http methods:
2424
- **Request Body**
2525
* If required, include a JSON- or XML-formatted request body that contains any data that is needed.
2626

27-
### About Authentication
27+
### About authentication
2828

2929
Authentication controls whether a user user can access a specific API endpoint and how they can access it. For example, one user might have read-only privileges, which they can only make API calls that read data. Another user might have read and change (add, edit, delete) privileges to every endpoint, which means they can make any API call. These access rights are typically-based upon assigned user roles such as *Administrator*, which grants a user full rights to change data, and *User*, which grants read-only access.
3030

@@ -34,7 +34,7 @@ REST APIs have three common methods to authenticate users:
3434
* **OAuth:** Open standard for HTTP authentication and session management. Creates an access token associated with a specific user that also specifies the user rights. The token identifies the user and rights when making API calls to verify access and control. See [OAuth](https://en.wikipedia.org/wiki/OAuth) for more information.
3535
3. **Token:** As with OAuth, a token is created and passed with each API call, but there is no session management and tracking of clients. This simplifies interaction between the server and client. See [Token Based Authentication](https://scotch.io/tutorials/the-ins-and-outs-of-token-based-authentication) for more information.
3636

37-
APIC-EM uses token-based authentication. So the first request you need to make creates a token. In DNA Center, this string is called a *token*. The controller uses the token to determine which endpoints you can access. The token must be included in every API call.
37+
DNA Center uses token-based authentication. So the first request you need to make creates a token. In DNA Center, this string is called a *token*. The controller uses the token to determine which endpoints you can access. The token must be included in every API call.
3838

3939
The steps for using the DNA Center authentication token are:
4040

@@ -46,11 +46,11 @@ The steps for using the DNA Center authentication token are:
4646

4747
The API Reference Documentation is where you can find the list of the API methods and the details for information on how to make each request. When you are starting to work with a new API, the API Reference is one of the most important sources of information.
4848

49-
Study the Ticket API in APIC-EM:
49+
Study the Ticket API in DNA Center:
5050

5151
* Open the [DNA Center API reference docs](https://developer.cisco.com/site/dna-center-rest-api/). Pick the proper version of API. The entire API is presented in scrollable format.
5252

53-
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide1.png)
53+
![](assets/images/refguide1.png)
5454

5555
* The API Reference includes attributes to be sent and returned. The Response portion defines the returned data, including HTTP status codes.
5656

@@ -63,10 +63,12 @@ Study the Ticket API in APIC-EM:
6363

6464
* Review the content to see what data is expected to be sent to the server and returned to your application. In the example response for the network devices request, you can see that the response string contains a `hostName` attribute with a value of type Array[string].
6565

66-
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide4.png)
66+
![](assets/images/refguide4.png)
6767

6868
### Things to try
6969

7070
* Look at the other network devices endpoints in the API Reference Guide. How do they differ from one another?
7171

72-
### Next Step: Make HTTP calls using REST
72+
### Next step
73+
74+
Proceed to Step 4: Construct a REST call.

labs/coding-101-rest-basics-ga/4.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Step 4. Construct a REST Call
1+
## Step 4: Construct a REST call
22

3-
### DNA Center Example: POST Create a Token
3+
### DNA Center example: Create a token
44

55
Now, look at how to use the API to create a token for authentication.
66

@@ -36,4 +36,6 @@ To get the token your request will look like this:
3636
* Provide the username and password for logging into the DNA Center in JSON format.
3737

3838

39-
### Next Step: Making a REST API call
39+
### Next step
40+
41+
Proceed to Step 5: Make a REST API call.

labs/coding-101-rest-basics-ga/5.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Step 5. Make a REST API Call
1+
## Step 5: Make a REST API call
22

33
There are HTTP clients you can use to quickly test web services. They provide a way to construct/send requests to REST APIs and view the responses:
44

@@ -30,7 +30,7 @@ On OS X, to use Python 3.4, you may need to accept the SSL certificate before ca
3030

3131
2. Set up your request to retrieve a token. In the Postman fields, enter the following information:
3232

33-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman1.png)
33+
![](assets/images/postman1.png)
3434

3535
* **Method**
3636
* ``A.`` Select **POST**.
@@ -54,4 +54,6 @@ On OS X, to use Python 3.4, you may need to accept the SSL certificate before ca
5454

5555
#### Congratulations! You made a first REST API call to DNA Center!
5656

57-
### Next Step: Hosts API URL
57+
### Next step
58+
59+
Proceed to Step 6: Use a token to make REST API calls.

labs/coding-101-rest-basics-ga/6.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
## Step 6. Use a token to make REST API calls
1+
## Step 6: Use a token to make REST API calls
22

3-
### Example: Get Hosts
3+
### DNA Center GET Example: Get hosts
44

5-
Now, look at the Get Hosts endpoint. A host is an end device attached to the network, such as a computer connected to a wireless device. Your goal is to find the hosts and display information about them.
5+
Now, look at the GET HOSTS API. A host is an end device attached to the network, such as a computer connected to a wireless device. Your goal is to find the hosts and display information about them.
66

7-
To construct a request that retrieves a list of hosts, refer to the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/). Click on Inventory under Services to find Get /host. These provide the following information:
7+
To construct a request that retrieves a list of hosts, refer to the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/). Click on Inventory under Services to find GET /host. These provide the following information:
88

99
* Method
1010
* URL
@@ -18,7 +18,7 @@ As specified earlier, you can see that the base URL for DNA Center is:
1818
https://{DNA-Center-Server}/api/v1
1919
```
2020

21-
The following call retrieves all of hosts on the specified server
21+
The following call retrieves all of hosts on the specified server:
2222

2323
```
2424
GET https://{DNA-Center-Server}/api/v1/host
@@ -42,6 +42,8 @@ To get the entire list of hosts, your request contains these items:
4242
* **Body**
4343
* Not required for this request.
4444

45-
![](assets/images/apic-emHostRequest.png)
45+
![](assets/images/HostRequest.png)
4646

47-
### Next Step: Get Network Hosts
47+
### Next step
48+
49+
Proceed to Step 7: Get the network hosts.

labs/coding-101-rest-basics-ga/7.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## Step 7. Getting the Network Hosts
1+
## Step 7: Get the network hosts
22

33
1. Set up the API call in Postman.
44
* Now, use the token to authorize a request to GET the hosts from the controller.
5-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman4.png)
5+
![](assets/images/postman4.png)
66

77
2. Enter the following information:
88
* **Method**
@@ -14,21 +14,23 @@
1414
* `C.` Enter the 'Content-Type' and value 'application/json'.
1515
* `C.` Enter the 'X-Auth-Token' and the token created earlier. The 'X-Auth-Token' is required for all DNA Center API calls.
1616
* **Authentication**
17-
* Handled in the Headers
17+
* Handled in the header.
1818
* **Body**
19-
* not required for this request
19+
* Not required for this request.
2020
3. Click **Send**. Postman sends the request to the server.
2121

2222
4. Review the response.
2323
* The **Response Code** in the **Status** field should be `200 OK`.
2424
* The **JSON** should display a list of hosts.
2525

26-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman5.png "Response")
26+
![](assets/images/postman5.png "Response")
2727

28-
## Things to Try
28+
## Things to try
2929
1. In Postman, append '?limit=1&offset=1' to the URL https://sandboxdnac/api/v1/host so reads as 'https://sandboxdnac/api/v1/host?limit=1&offset=1'. Click the **Send** button. How does the return data differ? Check the API Reference Guide for more information about the Get Host API call.
3030
<br/><br/>
3131

32-
#### Congratulations! You made your first REST API call using the APIC-EM Service Ticket!
32+
#### Congratulations! You made your first REST API call using the DNA Center Service Ticket!
3333

34-
### Next Step: Get Network Devices
34+
### Next step
35+
36+
Proceed to Step 8: Get the network devices.

labs/coding-101-rest-basics-ga/8.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
## Step 8. Getting the Network Devices
1+
## Step 8: Get the network devices
22

3-
Now, look at the Get Network Devices endpoint. A Network Device transports data to/from host devices or other network devices. A network device is typically a hub, switch, or router. It can be connected to the network by an Ethernet cable or wireless connection. Your goal is to find the network devices and display information about them.
3+
Now, look at the GET Network Devices API. A network device transports data to and from host devices or other network devices. A network device is typically a hub, switch, or router. It can be connected to the network by an Ethernet cable or wireless connection. Your goal is to find the network devices and display information about them.
44

5-
For details about the Get Network Device API, consult the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api//).
5+
For details about the GET Network Devices API, consult the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/).
66

77
1. Set up the API Call in Postman. Use the token to authorize a request to GET the network devices from the controller.
88

9-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman6.png)<br/><br/>
9+
![](assets/images/postman6.png)<br/><br/>
1010

1111
2. To retrieve the list of network devices, enter the information in the appropriate Postman fields, as shown here:
1212
* **Method**
@@ -25,9 +25,9 @@ For details about the Get Network Device API, consult the [DNA Center API Docs](
2525

2626
The output should look similar to the example in this screenshot. For display purposes, some records have been removed.
2727

28-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman7.png "Response")
28+
![](assets/images/postman7.png "Response")
2929

30-
### Things to Try
30+
### Things to try
3131
* In Postman, append `/1/2` so the call becomes `https://sandboxdnac/api/v1/network-device/1/2` and click **Send**. How does the output differ?
3232
* Compare the change you made in *Get Network Devices API* call with the change you made in the *Get Hosts* call in the previous exercise (Step 7). How are they different and why? Hint: Check the API Reference Guide for each of these API calls.
3333
* In Postman, change the API call `https://sandboxdnac/api/v1/network-device/1/2` to `https://sandboxdnac/api/v1/user` and click **Send**. How is the returned data different and what does it represent? Hint: Check the API Reference Guide

labs/coding-101-rest-basics-ga/coding-101-rest-basics-ga.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,28 @@
55
"time": 20,
66
"byod": true,
77
"files": [
8-
{"title": "Coding 101 - REST API Basics",
8+
{"title": "Step 1: Find the DNA Center API Reference documentation",
99
"file": "1.md"},
10-
{"title": "Step 2. So what is a REST web service?",
10+
{"title": "Step 2: So what is a REST web service",
1111
"file": "2.md"},
12-
{"title": "Step 3. What do I need to know to make a Request?",
12+
{"title": "Step 3: What do I need to know to make a request?",
1313
"file": "3.md"},
14-
{"title": "Step 4. Constructing a REST Call",
14+
{"title": "Step 4: Construct a REST call",
1515
"file": "4.md"},
16-
{"title": "Step 5. Make a REST API Call",
16+
{"title": "Step 5: Make a REST API call",
1717
"file": "5.md"},
18-
{"title": "Step 6. Using the Service Ticket to Make APIC-EM REST API Calls",
18+
{"title": "Step 6: Use a token to make REST API calls",
1919
"file": "6.md"},
20-
{"title": "Step 7. Getting the Network Hosts",
20+
{"title": "Step 7: Get the network hosts",
2121
"file": "7.md"},
22-
{"title": "Step 8. Getting the Network Devices",
22+
{"title": "Step 8: Get the network devices",
2323
"file": "8.md"}
2424
],
2525
"tags": [
2626
{"title": "Coding"},
2727
{"title": "REST"},
2828
{"title": "Postman"},
29+
{"title": "DNA Center"},
2930
{"title": "JSON"},
3031
{"title": "Sandbox"}
3132
],

labs/coding-102-rest-python-ga/1.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# Coding 102: Calling REST APIs from Python #
1+
# Coding 102: Calling REST APIs from Python
22

33
In this Learning Lab, you learn the basics of how to call a REST API in Python.
44

55

6-
## Objective ##
7-
8-
Completion Time: 35 minutes
6+
## Objectives
97

108
* Understand how to call a REST API from Python.
119
* Explore ways to parse and use the JSON returned from the REST API.
@@ -42,31 +40,31 @@ For more information, click the "How to Set Up Your Computer" link at the top of
4240
* **If you are working on a DevNet Learning Lab computer at a DevNet event**,
4341
* Open the Git Command window by clicking the *Git CMD* icon on the Task Bar or click the Start button. Then, in the Run bar, enter: `git cmd`.
4442
* **If you are working from your computer**, on your computer open a command terminal.
45-
![](/posts/files/coding-102-rest-python-ga/assets/images/create_directory.png)<br/><br/>
43+
![](assets/images/create_directory.png)<br/><br/>
4644
* Clone the coding skills sample code from GitHub. Enter the following command. This will copy Cisco DevNet's coding samples directory down to your computer so you may work with it locally.
4745
```
4846
git clone https://github.com/CiscoDevNet/coding-skills-sample-code
4947
```
50-
![](/posts/files/coding-102-rest-python-ga/assets/images/github-clone.png)<br/><br/>
48+
![](assets/images/github-clone.png)<br/><br/>
5149
Inside the directory you created, , you should see a new directory, 'coding-skills-sample-code'.<br/><br/>
52-
![](/posts/files/coding-102-rest-python-ga/assets/images/github-clone-listing.png)<br/><br/>
50+
![](assets/images/github-clone-listing.png)<br/><br/>
51+
52+
## Step 1: Find the DNA Center API Reference documentation
5353

54+
A good starting point to understand any API is to look at the documentation for the API. Now, find documentation for the DNA Center API.
5455

55-
## Step 1. Find the DNA Center API Resources
56+
1. In a browser, navigate to the [DevNet](https://developer.cisco.com/) home page.
57+
1. Use the menu at the top to navigate to the DNA Center Platform page.
58+
* Click the **Technologies** link to see the submenu.
59+
* Click **Networking**.
60+
* From the list of technologies, click **DNA Center Platform**.
61+
![](assets/images/Menu.png)
5662

57-
You are going to use the DNA Center API as an example of a REST API in this lab. So before you begin, locate the APIC-EM resources on DevNet.
63+
1. On the DNA Center Platform page, click the `Docs` link.
64+
1. Click `API Reference`.
65+
1. Select the latest API version.
66+
1. Keep the DNA Center API Reference documentation open in a separate tab. This page provides a useful reference while you work on this lab.
5867

59-
1. In the browser, navigate to <a href="https://developer.cisco.com" target="_blank">DevNet</a>
60-
* Click the **Login** link located at the top right of the webpage.
61-
![](/posts/files/coding-102-rest-python-ga/assets/images/login.png)<br/><br/>
62-
* On the Log In webpage, enter your log in credentials (CCO ID) and click the **Log In** button
63-
![](/posts/files/coding-102-rest-python-ga/assets/images/register.png)<br/>
64-
* If you do not have a Cisco Connection Online ID (CCO ID), click the **Register Now** button and follow the instructions. When done, return to the Log In webpage and enter your credentials.
65-
<br/><br/>
66-
2. Use the menu at the top to navigate directly to the APIC-EM developer resources.
67-
* Click the **Technologies** link to access the Technology menu. Inside the menu, click **Networking** followed by **APIC-EM**<br/>
68-
![](/posts/files/coding-102-rest-python-ga/assets/images/Menu.png)
69-
<br/><br/>
68+
### Next step
7069

71-
3. You are now at the DNA Center Platform. Open the API reference doc in a separate tab while you are working on this lab.<br/>
72-
![](/posts/files/coding-102-rest-python-ga/assets/images/Ref.png)
70+
Proceed to Step 2: Make your first REST call from Python.

0 commit comments

Comments
 (0)