Package: dnacentersdk
Work with the DNA Center APIs in native Python!dnacentersdkis acommunity developedPython library for working with the DNA Center APIs.  Our goal is to make working with DNA Center in Python anativeandnaturalexperience!fromdnacentersdkimportapi# Create a DNACenterAPI connection object;# it uses DNA Center sandbox URL, username and password, with DNA Center API version 2.3.5.3.# and requests to verify the server's TLS certificate with verify=True.dnac=api.DNACenterAPI(username="devnetuser",password="Cisco123!",base_url="https://sandboxdnac.cisco.com:443",version='2.3.5.3',verify=True)# Find all devices that have 'Switches and Hubs' in their familydevices=dnac.devices.get_device_list(family='Switches and Hubs')# Print all of demo devicesfordeviceindevices.response:print('{:20s}{}'.format(device.hostname,device.upTime))# Find all tagsall_tags=dnac.tag.get_tag(sort_by='name',order='des')demo_tags=[tagfortaginall_tags.responseif'Demo'intag.name]#  Delete all of the demo tagsfortagindemo_tags:dnac.tag.delete_tag(tag.id)# Create a new demo tagdemo_tag=dnac.tag.create_tag(name='dna Demo')task_demo_tag=dnac.task.get_task_by_id(task_id=demo_tag.response.taskId)ifnottask_demo_tag.response.isError:# Retrieve created tagcreated_tag=dnac.tag.get_tag(name='dna Demo')# Update tagupdate_tag=dnac.tag.update_tag(id=created_tag.response[0].id,name='Updated '+created_tag.response[0].name,description='DNA demo tag')print(dnac.task.get_task_by_id(task_id=update_tag.response.taskId).response.progress)# Retrieved updatedupdated_tag=dnac.tag.get_tag(name='Updated dna Demo')print(updated_tag)else:# Get task error detailsprint('Unfortunately ',task_demo_tag.response.progress)print('Reason: ',task_demo_tag.response.failureReason)# Advance usage example using Custom Caller functions# Define the get_global_credentials and create_netconf_credentials functions# under the custom_caller wrapper.# Call them with:#     dnac.custom_caller.get_global_credentials('NETCONF')#     dnac.custom_caller.create_netconf_credentials('65533')defsetup_custom():dnac.custom_caller.add_api('get_global_credentials',lambdacredential_type:dnac.custom_caller.call_api('GET','/dna/intent/api/v1/global-credential',params={'credentialSubType':credential_type}).response)dnac.custom_caller.add_api('create_netconf_credentials',lambdaport:dnac.custom_caller.call_api('POST','/dna/intent/api/v1/global-credential/netconf',json=[{"netconfPort":port}]))# Add the custom API calls to the connection object under the custom_caller wrappersetup_custom()# Call the newly added functionsdnac.custom_caller.create_netconf_credentials('65533')print(dnac.custom_caller.get_global_credentials('NETCONF'))IntroductionCheck out the completeIntroductiondnacentersdk handles all of this for you:Reads your DNA Center credentials from environment variables.Reads your DNA Center API version from environment variable DNA_CENTER_VERSION.Controls whether to verify the server’s TLS certificate or not according to the verify parameter.Reads your DNA Center debug from environment variable DNA_CENTER_DEBUG. Boolean.Wraps and represents all DNA Center API calls as a simple hierarchical tree of
native-Python methodsIf your Python IDE supportsauto-completion(likePyCharm_), you can
navigate the available methods and object attributes right within your IDERepresents all returned JSON objects as native Python objects - you can
access all of the object’s attributes using nativedot.syntaxAutomatic Rate-Limit HandlingSending a lot of requests to DNA Center?
Don’t worry; we have you covered.  DNA Center will respond with a rate-limit
response, which will automatically be caught and “handled” for you.Refresh tokenEach time the token becomes invalid, the SDK will generate a new valid token for you.InstallationInstalling and upgrading dnacentersdk is easy:Install via PIP$pipinstalldnacentersdkUpgrading to the latest Version$pipinstalldnacentersdk--upgradeCompatibility matrixThe following table shows the supported versions.Cisco DNA Center versionPython “dnacentersdk” version2.1.12.2.52.2.2.32.3.32.2.3.32.4.112.3.3.02.5.62.3.5.32.6.10If your SDK is older please consider updating it first.DocumentationExcellent documentation is now available at:https://dnacentersdk.readthedocs.ioCheck out theQuickstartto dive in and begin using dnacentersdk.Release NotesPlease see thereleasespage for release notes on the incremental functionality and bug fixes incorporated into the published releases.Questions, Support & Discussiondnacentersdk is acommunity developedandcommunity supportedproject.  If you experience any issues using this package, please report them using theissuespage.Contributiondnacentersdkis a community development projects.  Feedback, thoughts, ideas, and code contributions are welcome!  Please see theContributingguide for more information.InspirationThis library is inspired by thewebexteamssdklibraryChangelogAll notable changes to this project will be documented in theCHANGELOGfile.The development team may make additional name changes as the library evolves with the Cisco DNA Center APIs.Copyright (c) 2019-2021 Cisco Systems.