classes and methods to make it easier for developers to
integrate with and expand the functionality of Cisco DNA
Center. Installing the SDK is as simple as issuing the
command pip install dnacentersdk from the
command prompt. At this writing, the current Cisco
DNA Center SDK version is 1.3.0. The code in Example
8-7 was developed using this version of the SDK and
Python 3.7.4. The code in Example 8-7 uses the SDK to
first authorize to the API and then retrieve a list of all the
network devices and client health statuses.
Example 8-7 Python Script That Exemplifies the Use of
the Cisco DNA Center Python SDK
Click here to view code image
#! /usr/bin/env python
from dnacentersdk import api
# Create a DNACenterAPI connection object;
# it uses DNA Center sandbox URL, username and
password
DNAC = api.DNACenterAPI(username="devnetuser",
password="Cisco123!",
base_url="https://sandboxdnac2.cisco.com")
# Find all devices
DEVICES = DNAC.devices.get_device_list()
# Print select information about the retrieved
devices
print('{0:25s}{1:1}{2:45s}{3:1}
{4:15s}'.format("Device Name", "|", \
"Device Type", "|", "Up Time"))
print('-'* 95 )
for DEVICE in DEVICES.response:
print('{0:25s}{1:1}{2:45s}{3:1}
{4:15s}'.format(DEVICE.hostname, \
"|", DEVICE.type, "|", DEVICE.upTime))
print('-'* 95 )
# Get the health of all clients on Thursday,
August 22, 2019 8:41:29 PM GMT
CLIENTS =
DNAC.clients.get_overall_client_health(timestamp="
1566506489000")
# Print select information about the retrieved