dnacentersdk


Namednacentersdk JSON
Version 2.6.11 PyPI version JSON
download
home_pagehttps://dnacentersdk.readthedocs.io/en/latest/
SummaryCisco DNA Center Platform SDK
upload_time2024-01-10 19:52:15
maintainer
docs_urlNone
authorJose Bogarin Solano
requires_python>=3.6,<4.0
licenseMIT
keywords cisco dna center sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============
dnacentersdk
=============

*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!

.. code-block:: python

    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.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 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
------------
Check out the complete Introduction_

**dnacentersdk 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 methods

+ If your Python IDE supports **auto-completion** (like `PyCharm_`), you can
  navigate the available methods and object attributes right within your IDE

+ Represents all returned JSON objects as native Python objects - you can
  access all of the object's attributes using native *dot.syntax*

+ **Automatic Rate-Limit Handling**  Sending 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 token** Each time the token becomes invalid, the SDK will generate a new valid token for you.

Installation
------------

Installing and upgrading dnacentersdk is easy:

**Install via PIP**

.. code-block:: bash

    $ pip install dnacentersdk

**Upgrading to the latest Version**

.. code-block:: bash

    $ pip install dnacentersdk --upgrade


Compatibility matrix
--------------------
The following table shows the supported versions.

.. list-table::
   :widths: 50 50
   :header-rows: 1

   * - Cisco DNA Center version
     - Python "dnacentersdk" version
   * - 2.1.1
     - 2.2.5
   * - 2.2.2.3
     - 2.3.3
   * - 2.2.3.3
     - 2.4.11
   * - 2.3.3.0
     - 2.5.6
   * - 2.3.5.3
     - 2.6.10
   

If your SDK is older please consider updating it first.

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.*

.. _Introduction: https://dnacentersdk.readthedocs.io/en/latest/api/intro.html
.. _dnacentersdk.readthedocs.io: https://dnacentersdk.readthedocs.io
.. _Quickstart: https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html
.. _dnacentersdk: https://github.com/cisco-en-programmability/dnacentersdk
.. _issues: https://github.com/cisco-en-programmability/dnacentersdk/issues
.. _pull requests: https://github.com/cisco-en-programmability/dnacentersdk/pulls
.. _releases: https://github.com/cisco-en-programmability/dnacentersdk/releases
.. _the repository: dnacentersdk_
.. _pull request: `pull requests`_
.. _Contributing: https://github.com/cisco-en-programmability/dnacentersdk/blob/master/docs/contributing.rst
.. _webexteamssdk: https://github.com/CiscoDevNet/webexteamssdk
.. _CHANGELOG: https://github.com/cisco-en-programmability/dnacentersdk/blob/main/CHANGELOG.md

            

Raw data

            {
    "_id": null,
    "home_page": "https://dnacentersdk.readthedocs.io/en/latest/",
    "name": "dnacentersdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "Cisco,DNA Center,SDK",
    "author": "Jose Bogarin Solano",
    "author_email": "jbogarin@altus.cr",
    "download_url": "https://files.pythonhosted.org/packages/17/79/70dba35c393882fddff888f794da1cd8d46eb8a6f4fdca4c8832fee6eb5c/dnacentersdk-2.6.11.tar.gz",
    "platform": null,
    "description": "=============\ndnacentersdk\n=============\n\n*Work with the DNA Center APIs in native Python!*\n\n-------------------------------------------------------------------------------\n\n**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!\n\n.. code-block:: python\n\n    from dnacentersdk import api\n\n    # Create a DNACenterAPI connection object;\n    # it uses DNA Center sandbox URL, username and password, with DNA Center API version 2.3.5.3.\n    # and requests to verify the server's TLS certificate with verify=True.\n    dnac = api.DNACenterAPI(username=\"devnetuser\",\n                            password=\"Cisco123!\",\n                            base_url=\"https://sandboxdnac.cisco.com:443\",\n                            version='2.3.5.3',\n                            verify=True)\n\n    # Find all devices that have 'Switches and Hubs' in their family\n    devices = dnac.devices.get_device_list(family='Switches and Hubs')\n\n    # Print all of demo devices\n    for device in devices.response:\n        print('{:20s}{}'.format(device.hostname, device.upTime))\n\n    # Find all tags\n    all_tags = dnac.tag.get_tag(sort_by='name', order='des')\n    demo_tags = [tag for tag in all_tags.response if 'Demo' in tag.name ]\n\n    #  Delete all of the demo tags\n    for tag in demo_tags:\n        dnac.tag.delete_tag(tag.id)\n    \n    # Create a new demo tag\n    demo_tag = dnac.tag.create_tag(name='dna Demo')\n    task_demo_tag = dnac.task.get_task_by_id(task_id=demo_tag.response.taskId)\n\n    if not task_demo_tag.response.isError:\n        # Retrieve created tag\n        created_tag = dnac.tag.get_tag(name='dna Demo')\n\n        # Update tag\n        update_tag = dnac.tag.update_tag(id=created_tag.response[0].id, \n                                         name='Updated ' + created_tag.response[0].name,\n                                         description='DNA demo tag')\n        \n        print(dnac.task.get_task_by_id(task_id=update_tag.response.taskId).response.progress)\n        \n        # Retrieved updated\n        updated_tag = dnac.tag.get_tag(name='Updated dna Demo')\n        print(updated_tag)\n    else:\n        # Get task error details \n        print('Unfortunately ', task_demo_tag.response.progress)\n        print('Reason: ', task_demo_tag.response.failureReason)\n\n    # Advance usage example using Custom Caller functions\n    # Define the get_global_credentials and create_netconf_credentials functions\n    # under the custom_caller wrapper.\n    # Call them with:\n    #     dnac.custom_caller.get_global_credentials('NETCONF')\n    #     dnac.custom_caller.create_netconf_credentials('65533')\n    def setup_custom():\n        dnac.custom_caller.add_api('get_global_credentials',\n                                lambda credential_type:\n                                    dnac.custom_caller.call_api(\n                                        'GET',\n                                        '/dna/intent/api/v1/global-credential',\n                                        params={\n                                            'credentialSubType': credential_type\n                                        }).response\n                                )\n        dnac.custom_caller.add_api('create_netconf_credentials',\n                                lambda port:\n                                    dnac.custom_caller.call_api(\n                                        'POST',\n                                        '/dna/intent/api/v1/global-credential/netconf',\n                                        json=[{\n                                            \"netconfPort\": port\n                                        }])\n                                )\n\n    # Add the custom API calls to the connection object under the custom_caller wrapper\n    setup_custom()\n    # Call the newly added functions\n    dnac.custom_caller.create_netconf_credentials('65533')\n    print(dnac.custom_caller.get_global_credentials('NETCONF'))\n\n\nIntroduction\n------------\nCheck out the complete Introduction_\n\n**dnacentersdk handles all of this for you:**\n\n+ Reads your DNA Center credentials from environment variables.\n\n+ Reads your DNA Center API version from environment variable DNA_CENTER_VERSION.\n\n+ Controls whether to verify the server's TLS certificate or not according to the verify parameter.\n\n+ Reads your DNA Center debug from environment variable DNA_CENTER_DEBUG. Boolean.\n\n+ Wraps and represents all DNA Center API calls as a simple hierarchical tree of\n  native-Python methods\n\n+ If your Python IDE supports **auto-completion** (like `PyCharm_`), you can\n  navigate the available methods and object attributes right within your IDE\n\n+ Represents all returned JSON objects as native Python objects - you can\n  access all of the object's attributes using native *dot.syntax*\n\n+ **Automatic Rate-Limit Handling**  Sending a lot of requests to DNA Center?\n  Don't worry; we have you covered.  DNA Center will respond with a rate-limit\n  response, which will automatically be caught and \"handled\" for you.\n\n+ **Refresh token** Each time the token becomes invalid, the SDK will generate a new valid token for you.\n\nInstallation\n------------\n\nInstalling and upgrading dnacentersdk is easy:\n\n**Install via PIP**\n\n.. code-block:: bash\n\n    $ pip install dnacentersdk\n\n**Upgrading to the latest Version**\n\n.. code-block:: bash\n\n    $ pip install dnacentersdk --upgrade\n\n\nCompatibility matrix\n--------------------\nThe following table shows the supported versions.\n\n.. list-table::\n   :widths: 50 50\n   :header-rows: 1\n\n   * - Cisco DNA Center version\n     - Python \"dnacentersdk\" version\n   * - 2.1.1\n     - 2.2.5\n   * - 2.2.2.3\n     - 2.3.3\n   * - 2.2.3.3\n     - 2.4.11\n   * - 2.3.3.0\n     - 2.5.6\n   * - 2.3.5.3\n     - 2.6.10\n   \n\nIf your SDK is older please consider updating it first.\n\nDocumentation\n-------------\n\n**Excellent documentation is now available at:**\nhttps://dnacentersdk.readthedocs.io\n\nCheck out the Quickstart_ to dive in and begin using dnacentersdk.\n\n\nRelease Notes\n-------------\n\nPlease see the releases_ page for release notes on the incremental functionality and bug fixes incorporated into the published releases.\n\n\nQuestions, Support & Discussion\n-------------------------------\n\ndnacentersdk is a *community developed* and *community supported* project.  If you experience any issues using this package, please report them using the issues_ page.\n\n\nContribution\n------------\n\ndnacentersdk_ is a community development projects.  Feedback, thoughts, ideas, and code contributions are welcome!  Please see the `Contributing`_ guide for more information.\n\n\nInspiration\n------------\n\nThis library is inspired by the webexteamssdk_  library\n\n\nChangelog\n---------\n\nAll notable changes to this project will be documented in the CHANGELOG_ file.\n\nThe development team may make additional name changes as the library evolves with the Cisco DNA Center APIs.\n\n\n*Copyright (c) 2019-2021 Cisco Systems.*\n\n.. _Introduction: https://dnacentersdk.readthedocs.io/en/latest/api/intro.html\n.. _dnacentersdk.readthedocs.io: https://dnacentersdk.readthedocs.io\n.. _Quickstart: https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html\n.. _dnacentersdk: https://github.com/cisco-en-programmability/dnacentersdk\n.. _issues: https://github.com/cisco-en-programmability/dnacentersdk/issues\n.. _pull requests: https://github.com/cisco-en-programmability/dnacentersdk/pulls\n.. _releases: https://github.com/cisco-en-programmability/dnacentersdk/releases\n.. _the repository: dnacentersdk_\n.. _pull request: `pull requests`_\n.. _Contributing: https://github.com/cisco-en-programmability/dnacentersdk/blob/master/docs/contributing.rst\n.. _webexteamssdk: https://github.com/CiscoDevNet/webexteamssdk\n.. _CHANGELOG: https://github.com/cisco-en-programmability/dnacentersdk/blob/main/CHANGELOG.md\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cisco DNA Center Platform SDK",
    "version": "2.6.11",
    "project_urls": {
        "Homepage": "https://dnacentersdk.readthedocs.io/en/latest/",
        "Repository": "https://github.com/cisco-en-programmability/dnacentersdk"
    },
    "split_keywords": [
        "cisco",
        "dna center",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d93e46784393e9c34df86dff664dfe026a4474fc6e0edec694180a653b54b47",
                "md5": "79bc21fb34309415400187c23151a6e6",
                "sha256": "b66cee835cb804047a31faee372be219711f784216a977bec0d5e7d80b78e516"
            },
            "downloads": -1,
            "filename": "dnacentersdk-2.6.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79bc21fb34309415400187c23151a6e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 3253442,
            "upload_time": "2024-01-10T19:52:12",
            "upload_time_iso_8601": "2024-01-10T19:52:12.733099Z",
            "url": "https://files.pythonhosted.org/packages/8d/93/e46784393e9c34df86dff664dfe026a4474fc6e0edec694180a653b54b47/dnacentersdk-2.6.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "177970dba35c393882fddff888f794da1cd8d46eb8a6f4fdca4c8832fee6eb5c",
                "md5": "47f463d34b25cdd419c49f71d4c517ab",
                "sha256": "81ca926e3fab1c7c0a721a87c2480cdf5b7a48da0bc1b7dc3829f89b9cef659a"
            },
            "downloads": -1,
            "filename": "dnacentersdk-2.6.11.tar.gz",
            "has_sig": false,
            "md5_digest": "47f463d34b25cdd419c49f71d4c517ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 1192759,
            "upload_time": "2024-01-10T19:52:15",
            "upload_time_iso_8601": "2024-01-10T19:52:15.896093Z",
            "url": "https://files.pythonhosted.org/packages/17/79/70dba35c393882fddff888f794da1cd8d46eb8a6f4fdca4c8832fee6eb5c/dnacentersdk-2.6.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 19:52:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cisco-en-programmability",
    "github_project": "dnacentersdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "dnacentersdk"
}
        
Elapsed time: 0.16317s