社区为dna中心api开发的python sdk
dnacentersdk的Python项目详细描述
使用原生python中的dna中心api!
dnacentersdk是一个community开发的用于处理dna中心api的python库。我们的目标是让在python中使用dna中心成为一种native和natural体验!
fromdnacentersdkimportapi# Create a DNACenterAPI connection object;# it uses DNA Center sandbox URL, username and password, with DNA Center API version 1.2.10.dnac=api.DNACenterAPI(username="devnetuser",password="Cisco123!",base_url="https://sandboxdnac2.cisco.com:443",version='1.2.10')# 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)
安装
安装和升级dnacentersdk很容易:
通过pip安装
升级到最新版本$ pip install dnacentersdk
$ pip install dnacentersdk --upgrade
发行说明
请参阅releases页,以获取有关已发布版本中包含的增量功能和错误修复的发行说明。
问题、支持和讨论
dnacentersdk是一个社区开发的和社区支持的项目。如果使用此软件包时遇到任何问题,请使用issues页面报告。
贡献
dnacentersdk是一个社区开发项目。欢迎反馈、想法、想法和代码贡献!有关详细信息,请参阅Contributing指南。