DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

and extract the hostname, device model, device ID,
system IP address, and site ID for each device in the
fabric and then display that information to the console.
The code then prints a series of dashes for readability
purposes. Next, the same logic is applied to GET data
from the API but this time about all the device templates
that are configured on this instance of vManage. The
URL is built by concatenating the base URL with the
device template resource, dataservice/template/device.
The same session is reused once more to obtain the data
from the REST API. In the case of the device templates,
only the template name, the type of device the template
is intended for, the template ID, the number of attached
devices to each template, and the template version are
extracted and displayed to the console.


If you run this script in a Python 3.7.4 virtual
environment with the requests library version 2.22.0
installed, you get output similar to that shown in Figure
8-15.


Figure 8-15 Output of the Python Script from
Example 8-10


This chapter has explored several Cisco solutions and
their REST APIs. Authentication and authorization
methods have been explained, and basic information has
been obtained from the APIs. This chapter has provided
a basic introduction to these extensive APIs and the
features that they expose. We encourage you to continue
your exploration of these APIs and build your own use
cases, automation, and network programmability
projects.

Free download pdf