Skip to content

Commit 7dc14ca

Browse files
authored
Merge pull request #75 from CiscoDevNet/fix-errors
Replace APIC-EM with DNA Center - partial
2 parents 5a0d134 + 39d9633 commit 7dc14ca

File tree

37 files changed

+208
-246
lines changed

37 files changed

+208
-246
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

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

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11

2-
# Coding 101 - REST API Basics with APIC-EM
2+
# Coding 101 - REST API Basics
33

44
This Learning Lab explains the basics of using a REST API. It also shows how to use Postman to explore a REST API.
55

6-
## Objective
6+
## Objectives
77

88
* Understand REST APIs
99
* Learn how to use the Postman application to make API calls
1010

1111
## Prerequisites
1212

13-
- <a href="https://www.getpostman.com" target="_blank">Postman</a> installed.
14-
If you are on a DevNet Zone station, <a href="https://www.getpostman.com" target="_blank">Postman</a> is already installed. You can start it from the Google App Launcher or Chrome by clicking <a href="https://www.getpostman.com" target="_blank">here</a> and clicking **Launch App**.
13+
- [Postman](https://www.getpostman.com) installed.
14+
If you are on a DevNet Zone station, Postman is already installed.
1515

16-
- Access to an APIC-EM Controller. To run the code samples, you need access to an APIC-EM controller. If you are not using your APIC-EM controller, you can use the APIC-EM Lab:
17-
* https://sandboxapicem.cisco.com
16+
- Access to DNA Center. To run the code samples, you need access to DNA Center. You can use the DNA Center DevNet Sandbox:
17+
* https://sandboxdnac.cisco.com
1818
* **username:** devnetuser
1919
* **password:** Cisco123!
2020

21-
## Step 1. Find the APIC-EM API Resources and Documentation
21+
## Step 1. Find the DNA Center API Resources and Documentation
2222

23-
A good starting point to understand any API is to look at the documentation for the API. Now, find documentation for the APIC-EM API.
23+
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.
2424

25-
1. In a browser, navigate to the <a href="https://developer.cisco.com" target="_blank">DevNet</a> home page.
26-
2. Click the **Login** link located at the top right of the webpage.
27-
![](/posts/files/coding-101-rest-basics-ga/assets/images/login.png)<br/><br/>
28-
3. On the Log In page, enter your credentials.
29-
To log in with a Cisco ID but do not have a Cisco Connection Online ID (CCO ID) click the **Register Now** button and follow the instructions. Then, return to the Log In webpage and enter your credentials.
30-
<br/><br/>
31-
4. Use the menu at the top to navigate to the APIC-EM web portal.
25+
1. In a browser, navigate to the [DevNet](https://developer.cisco.com/) home page.
26+
1. Use the menu at the top to navigate to the DNA Center Platform page.
3227
* Click the **Technologies** link to see the submenu.
33-
* Click **Networking**
34-
* From the list of technologies, click **APIC Enterprise Module (APIC-EM)**<br/>The APIC-EM webpage appears.
28+
* Click **Networking**.
29+
* From the list of technologies, click **DNA Center Platform**.
3530
![](/posts/files/coding-101-rest-basics-ga/assets/images/Menu.png)
36-
<br/>
37-
5. On the APIC-EM webpage. Click the `Docs` link.<br/>
38-
![](/posts/files/coding-101-rest-basics-ga/assets/images/apic-em-main.png)
39-
6. Click on `API Reference`.
40-
7. Select the latest API version.
41-
8. Keep the APIC-EM API Reference documentation open in a separate tab. This will be a useful reference while you work on this lab.
42-
![](/posts/files/coding-101-rest-basics-ga/assets/images/Ref.png)
43-
<br/>
44-
<br/>
45-
46-
### Next Step: Learn about the REST Web Service
31+
32+
1. On the DNA Center Platform page, click the `Docs` link.
33+
1. Click `API Reference`.
34+
1. Select the latest API version.
35+
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.
36+
37+
### Next Step: Learn about the REST web service

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

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

33
### What is a Web Service?
44

@@ -10,25 +10,23 @@ There are two major types of web services – **REST** and **SOAP**.
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.
1212
RESTful interfaces usually offer the CRUD (Create, Read, Update, Delete) operations.
13-
To know more about REST in general, this is a great <a href="https://en.m.wikipedia.org/wiki/Representational_state_transfer" target="_blank">REST definition</a>.
14-
13+
To know more about REST in general, this is a great [REST definition](https://en.m.wikipedia.org/wiki/Representational_state_transfer).
1514

1615
### What are the benefits of REST?
1716

1817
***REST is easy to use on any platform***
1918

2019
![](/posts/files/coding-101-rest-basics-ga/assets/images/RESTisGreat.jpg)
2120

22-
### APIC-EM API is a REST API
23-
24-
For this lab, you are going to use the <a href="https://developer.cisco.com/site/apic-em/" target="_blank">APIC-EM APIs</a>.
21+
### DNA Center API is a REST API
2522

26-
The Application Policy Infrastructure Control (APIC) Enterprise Module (EM), Application Programming Interface (API), <a href="https://developer.cisco.com/site/apic-em/" target="_blank">APIC-EM APIs</a>, enables deploying and running application policies across your networking infrastructure.
23+
For this lab, you are going to use the [DNA Center APIs](https://developer.cisco.com/site/dna-center-rest-api/).
2724

28-
Using the APIC-EM APIs, you can retrieve information about devices on your network including a list of hosts, network devices, or users. You are going to use these features as examples to learn how to make REST calls from Python.
25+
DNA Center APIs enable deploying and running application policies across your networking infrastructure.
2926

30-
Look at the <a href="https://developer.cisco.com/site/apic-em-rest-api//" target="_blank">APIC-EM Reference Docs</a> to see the details of the APIC-EM functions.
27+
Using the DNA Center APIs, you can retrieve information about devices on your network including a list of hosts, network devices, or users. You are going to use these features as examples to learn how to make REST calls from Python.
3128

29+
Look at the [DNA Center documentation](https://developer.cisco.com/site/dna-center-rest-api/) to see the details of the functions.
3230

3331
### How does this work?
3432

@@ -38,8 +36,8 @@ REST is centered around the HTTP request and response model. Consuming an API is
3836

3937
In this example, you request the list of hosts, and that information is returned to you in the response. The data returned in the response is usually formatted as JSON or XML.
4038

41-
(<a href="https://www.json.org/" target="_blank">JSON</a> -- JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange.)
39+
* [JSON](https://www.json.org/) - JSON, or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange.
4240

43-
(<a href="https://www.w3schools.com/xml/xml_whatis.asp" target="_blank">XML</a> -- eXtensible Markup Language, a language designed to store and transport data.)
41+
* [XML](https://www.w3schools.com/xml/xml_whatis.asp) - XML, or eXtensible Markup Language, a language designed to store and transport data.
4442

45-
### Next Step: HTTP Response Request Facts
43+
### Next Step: HTTP response and request facts

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Step 3. What do I need to know to make a Request?
1+
## Step 3: What do I need to know to make a request?
22

33
To construct a request, determine the following information for the API that you are calling. You can find this information in the API reference documentation.
44

@@ -11,9 +11,9 @@ Choose one of the following http methods:
1111

1212
- **URL**
1313
* Determine the URL of the endpoint you want to call.
14-
* Example: `https://{APIC-EMController}/api/v1/ticket`
15-
* Where `{APIC-EMController}` is the controller IP or hostname.
16-
* Use the Cisco DevNet Learning Lab's APIC-EM controller, at https://sandboxapicem.cisco.com/, or enter the URL/IP address of an APIC-EM controller on your network.
14+
* Example: `https://sandboxdnac.cisco.com/api/system/v1/auth/token`
15+
* Where `sandboxdnac.cisco.com` is the controller IP or hostname.
16+
* Use the Cisco DevNet Learning Lab's DNA Center, at https://sandboxdnac.cisco.com/, or enter the URL/IP address of an DNA Center on your network.
1717
- **URL Parameters**
1818
* If the endpoint requires URL parameters, pass them as part of the URL. To get this information, refer to the reference documentation for the particular endpoint.
1919
- **Authentication**
@@ -32,31 +32,26 @@ REST APIs have three common methods to authenticate users:
3232

3333
* **Basic HTTP:** The username and password are passed to the server as an encoded string. For more information, see [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication).
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.
35-
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. APIC-EM uses this design for authentication management. See [Token Based Authentication](https://scotch.io/tutorials/the-ins-and-outs-of-token-based-authentication) for more information.
35+
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 APIC-EM, this token is called a *service ticket*. The controller uses the service ticket to determine which endpoints you can access. The service ticket must be included in every API call except the one that creates the ticket.
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.
3838

39-
The steps for using the APIC-EM authentication token are:
39+
The steps for using the DNA Center authentication token are:
4040

41-
1. Create a ticket
41+
1. Send a POST to the token endpoint.
4242
2. A ticket (token) is returned in response body.
4343
3. Include this token in the 'X-Auth-Token' header on all subsequent requests.
4444

4545
### Using the API Reference Documentation
4646

47-
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,
48-
the API Reference is one of the most important sources of information.
47+
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.
4948

5049
Study the Ticket API in APIC-EM:
5150

52-
* Open the <a href="https://developer.cisco.com/site/apic-em/docs/api.html?version=1.6" target="_blank">APIC-EM Reference Docs</a>. Pick the proper version of API. The entire API is presented in scrollable format.
51+
* 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.
5352

5453
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide1.png)
5554

56-
* Click **Roll Based Access Control**, then scroll down to **ticket**.
57-
58-
* Click **'POST' /ticket**. This endpoint provides functionality to create a ticket.
59-
6055
* The API Reference includes attributes to be sent and returned. The Response portion defines the returned data, including HTTP status codes.
6156

6257
* HTTP status codes indicate success, error, or other conditions. For more information, see [https://www.w3.org/Protocols/HTTP/HTRESP.html](https://www.w3.org/Protocols/HTTP/HTRESP.html)
@@ -66,15 +61,12 @@ Study the Ticket API in APIC-EM:
6661
* 401 Not Authorized
6762

6863

69-
* Review the content to see what data is expected to be sent to the server and returned to your application. Both are circled here. In the example response for the Create Ticket request, you can see that the response string contains a `serviceTicket` attribute with a value of type string. This value is the authentication token you will need to make calls to all of the other API endpoints.
64+
* 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].
7065

7166
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide4.png)
7267

73-
* In the Parameters section, click **Example Value**. Double-clicking the box moves the parameters to an editable box on the left to try out the function.
74-
75-
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide5.png)
68+
### Things to try
7669

77-
### Things to Try
78-
* Look at the other ticket endpoints in the API Reference Guide. How do they differ from one another?
70+
* Look at the other network devices endpoints in the API Reference Guide. How do they differ from one another?
7971

80-
### Next Step: Make HTTP calls Using REST
72+
### Next Step: Make HTTP calls using REST

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

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,39 @@
1-
## Step 4. Constructing a REST Call
1+
## Step 4. Construct a REST Call
22

3-
### APIC-EM Example: POST Create a Ticket
3+
### DNA Center Example: POST Create a Token
44

5-
Now, look at how to use the API to create a service ticket for authentication.
5+
Now, look at how to use the API to create a token for authentication.
66

7-
You need to know how to construct the request to retrieve the service ticket. Use the API docs to determine the:
7+
You need to know how to construct the request to retrieve the token. Use the API docs to determine the:
88

99
* Method
1010
* URL
1111
* Headers
1212
* Authentication
1313
* Body
1414

15-
All of the URLs for APIC-EM begin with:
15+
Get the description of the token API call from the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/). Choose the proper API version.
1616

17-
```http
18-
19-
https://{APIC-EM-Server}/api/v1
17+
`POST /api/v1/token`: This method creates a new user token.
2018

19+
The HTTP call to a create a token is easy.
2120
```
2221
23-
Get the description of the ticket API call from the -- <a href="https://developer.cisco.com/site/apic-em/docs/api.html?version=1.6" target="_blank">APIC-EM API Docs</a>. Choose the proper API version.
24-
25-
`POST /api/v1/ticket`: This method creates a new user ticket
26-
27-
28-
The HTTP call to a create a service ticket is easy.
29-
```http
30-
31-
https://{APIC-EM-Server}/api/v1/ticket
22+
POST https://{DNA-Center-Server}/api/system/v1/auth/token
3223
3324
```
3425

35-
To get the service ticket your request will look like this:
26+
To get the token your request will look like this:
3627

3728
* **Method** - `POST`
38-
* **URL** - `https://{APIC-EM-Server}/api/v1/ticket`
39-
* Substitute `{APIC-EM-Server}` with the IP address or hostname of the APIC-EM controller you are using. For example, the Cisco DevNet Learning Labs APIC-EM controller is `https://sandboxapicem.cisco.com/`.
29+
* **URL** - `https://{DNA-Center-Server}/api/system/v1/auth/token`
30+
* Substitute `{DNA-Center-Server}` with the IP address or hostname of the DNA Center you are using. For example, the Cisco DevNet Learning Labs DNA Center is `https://sandboxdnac.cisco.com/`.
4031
* **Headers**
4132
* Specify the 'Content-Type' as 'application/json'. It's typical to include this header with all HTTP methods (GET, POST, PUT, DELETE) calls.
4233
* **Authentication**
4334
* In this API call, the authentication data is passed in the body.
4435
* **Body**
45-
* Provide the username and password for logging into the APIC-EM Controller in JSON format.
46-
47-
![](/posts/files/coding-101-rest-basics-ga/assets/images/apic-em-request.png)
36+
* Provide the username and password for logging into the DNA Center in JSON format.
4837

4938

50-
### Next Step: Making a REST API Call
39+
### Next Step: Making a REST API call

0 commit comments

Comments
 (0)