cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5847
Views
26
Helpful
0
Comments
Mohamed Alhenawy
Spotlight
Spotlight
 
get-to-work.gif

Today, I going to write a brief summary of the Cisco DNA Center Platform API, The main Major of the DNAC platform to access your network devices through API and integrate with other systems and add support for multi-vendors and help you to data analyze. 

 

-- Cisco Make amazing documentation about API, you can get form Developer toolkit ( Access to DNAC-->Platform -->Developer Toolkit--> APIs)

 

1.JPG

 

You must have a python 3.x with the requests library Use PIP 3 to install the requests library as shown below the Summary of steps :

1- root@PlatformAPI:~# apt-get update

2.JPG

 

2- root@PlatformAPI:~# apt-get install python3-pip3

3.JPG

 

- You must import the basic authentication from requests.auth as per ( Cisco ) following this script

 

def get_token():
    token = requests.post(
       ‘https://<cluster IP>/dna/system/api/v1/auth/token’,
       auth=HTTPBasicAuth(
           username=<username>,
           password=<password>
       ),
      headers={'content-type': 'application/json'},
      verify=False,
    )
    data = token.json()
    return data[‘Token’]<code></code>

 

 

Let's try some parameters but before we start should be you understand the HTTP message :

 

HTTP  message has two types (Request, Response )
HTTP request message (ASCII) code and you can get more information through this link:https://en.wikipedia.org/wiki/ASCII
Method types are ( GET, POST, Head, Put, Delete)

- POST >>> To create resources objects.

- GET  >>> To retrieve a resources.

- PUT  >>> To create or replace the resources.

- Head >>> To leave the request object out of response.

- Delete >>> To delete a resources.

{{ Create sites, assign devices to them and get site health}}
 
POST /DNA/intent/API/v1/site Create Site
{
  "type": "area",
  "site": {
    "area": {
      "name": "string",
      "parentName": "string"
    },
    "building": {
      "name": "string",
      "address": "string",
      "parentName": "string",
      "latitude": 0,
      "longitude": 0
    },
    "floor": {
      "name": "string",
      "parentName": "string",
      "rfModel": "Cubes And Walled Offices",
      "width": 0,
      "length": 0,
      "height": 0
    }
  }
}

POST /dna/system/api/v1/site/{siteId}/device Assign Device To Site

 

{
  "device": [
    {
      "ip": "string"
    }
  ]
}

and you can read more about these through this amazing link: https://developer.cisco.com/docs/dna-center/api/1-3-3-x/

 

*** I hope that has been informative for you and thank you ***
Mohamed Alhenawy
CCIE#60453

 

 

 

 

 

 

 

 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking for a $25 gift card