Skip to main content

Cisco DNA Center Platform SDK

Project description

Work with the DNA Center APIs in native Python!


dnacentersdk is a community developed Python library for working with the DNA Center APIs. Our goal is to make working with DNA Center in Python a native and natural experience!

from dnacentersdk import api

# Create a DNACenterAPI connection object;
# it uses DNA Center sandbox URL, username and password, with DNA Center API version 2.3.3.0.
# 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.3.0',
                        verify=True)

# Find all devices that have 'Switches and Hubs' in their family
devices = dnac.devices.get_device_list(family='Switches and Hubs')

# Print all of demo devices
for device in devices.response:
    print('{:20s}{}'.format(device.hostname, device.upTime))

# Find all tags
all_tags = dnac.tag.get_tag(sort_by='name', order='des')
demo_tags = [tag for tag in all_tags.response if 'Demo' in tag.name ]

#  Delete all of the demo tags
for tag in demo_tags:
    dnac.tag.delete_tag(tag.id)

# Create a new demo tag
demo_tag = dnac.tag.create_tag(name='dna Demo')
task_demo_tag = dnac.task.get_task_by_id(task_id=demo_tag.response.taskId)

if not task_demo_tag.response.isError:
    # Retrieve created tag
    created_tag = dnac.tag.get_tag(name='dna Demo')

    # Update tag
    update_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 updated
    updated_tag = dnac.tag.get_tag(name='Updated dna Demo')
    print(updated_tag)
else:
    # Get task error details
    print('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')
def setup_custom():
    dnac.custom_caller.add_api('get_global_credentials',
                            lambda credential_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',
                            lambda port:
                                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 wrapper
setup_custom()
# Call the newly added functions
dnac.custom_caller.create_netconf_credentials('65533')
print(dnac.custom_caller.get_global_credentials('NETCONF'))

Introduction

Installation

Installing and upgrading dnacentersdk is easy:

Install via PIP

$ pip install dnacentersdk

Upgrading to the latest Version

$ pip install dnacentersdk --upgrade

Documentation

Excellent documentation is now available at: https://dnacentersdk.readthedocs.io

Check out the Quickstart to dive in and begin using dnacentersdk.

Release Notes

Please see the releases page for release notes on the incremental functionality and bug fixes incorporated into the published releases.

Questions, Support & Discussion

dnacentersdk is a community developed and community supported project. If you experience any issues using this package, please report them using the issues page.

Contribution

dnacentersdk is a community development projects. Feedback, thoughts, ideas, and code contributions are welcome! Please see the Contributing guide for more information.

Inspiration

This library is inspired by the webexteamssdk library

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

The development team may make additional name changes as the library evolves with the Cisco DNA Center APIs.

Copyright (c) 2019-2021 Cisco Systems.

Project details


Release history Release notifications | RSS feed

This version

2.5.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dnacentersdk-2.5.3.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnacentersdk-2.5.3-py3-none-any.whl (2.8 MB view details)

Uploaded Python 3

File details

Details for the file dnacentersdk-2.5.3.tar.gz.

File metadata

  • Download URL: dnacentersdk-2.5.3.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.2.0

File hashes

Hashes for dnacentersdk-2.5.3.tar.gz
Algorithm Hash digest
SHA256 982b29b8dca2b3f5155b81249f4ab55bf97eb9ecceb44baeb606fc6b6e8caf18
MD5 fb8e6c83bdea40df8452dfaa830918cb
BLAKE2b-256 4f87d72f872ddeae5a95dc6869b14c3bf34e59844d5ae19064f878a02943ef5b

See more details on using hashes here.

File details

Details for the file dnacentersdk-2.5.3-py3-none-any.whl.

File metadata

  • Download URL: dnacentersdk-2.5.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.2.0

File hashes

Hashes for dnacentersdk-2.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 87937ce86aa9345e8f224d5a667ea268abf625ec6642c1eafd1268670af9a705
MD5 316c5d0f870fc7932d902834def8d5ff
BLAKE2b-256 26d08bd40b37012ec6fb9df62cf9b13fba64ed52786dcee4629ddb91fb9ce792

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page