QuestionQ385

Understanding and Using APIs

Question Image

Refer to the exhibit. Drag the code options from the bottom into the boxes with missing code to return the number of interfaces on a network device by using the Cisco DNA Center SDK. Not all options are used.

Drag & Drop
router_id
device_id
DNACenterAPI
DNAC
port_list
routers
devices
from dnacentersdk import DNACenterAPI
base_url = 'https://10.9.11.226'
 = 'da4606c3-63ad-4ed4-8f35-6bfec7c2df04'

dnac = (username='cisco', password='secret',
    base_url=base_url, version='1.3', verify=False)

 = [item['portName'] for item in
    dnac..get_interface_info_by_id(device_id)['response']]

# Check the number of ports on the device
print(f'The list of interfaces contains {len(port_list)} items.')

# Output
# The list of interfaces contains 54 items.
Explanation

Cisco DNA Center SDK interface lookup is exposed through the devices API and requires a device ID. The method response contains interface records, whose portName values are collected in port_list before its length is printed.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!