From 46dfc8ab8ad4015ea68fb0c9ed6f906cb1a83a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Wed, 10 Jan 2024 11:22:47 -0600 Subject: [PATCH 1/5] Configuration template import template - check_type error #142 - Fixing required schema. --- .../api/v2_3_5_3/configuration_templates.py | 115 +++++++++++++++++- .../jsd_db7b6c4f0542aab9fe7cf5c995f83.py | 3 - 2 files changed, 112 insertions(+), 6 deletions(-) diff --git a/dnacentersdk/api/v2_3_5_3/configuration_templates.py b/dnacentersdk/api/v2_3_5_3/configuration_templates.py index ed462ca7..c5c0f0ac 100644 --- a/dnacentersdk/api/v2_3_5_3/configuration_templates.py +++ b/dnacentersdk/api/v2_3_5_3/configuration_templates.py @@ -549,7 +549,33 @@ def export_projects(self, def imports_the_templates_provided(self, project_name, + author=None, + composite=None, + containingTemplates=None, + createTime=None, + customParamsOrder=None, + description=None, + deviceTypes=None, do_version=None, + failurePolicy=None, + id=None, + language=None, + lastUpdateTime=None, + latestVersionTime=None, + name=None, + parentTemplateId=None, + projectId=None, + projectName=None, + rollbackTemplateContent=None, + rollbackTemplateParams=None, + softwareType=None, + softwareVariant=None, + softwareVersion=None, + tags=None, + templateContent=None, + templateParams=None, + validationErrors=None, + version=None, headers=None, payload=None, active_validation=True, @@ -557,6 +583,34 @@ def imports_the_templates_provided(self, """Imports the templates provided in the DTO by project Name . Args: + author(string): Configuration Templates's Author of template . + composite(boolean): Configuration Templates's Is it composite template . + containingTemplates(list): Configuration Templates's containingTemplates (list of objects). + createTime(integer): Configuration Templates's Create time of template . + customParamsOrder(boolean): Configuration Templates's Custom Params Order . + description(string): Configuration Templates's Description of template . + deviceTypes(list): Configuration Templates's deviceTypes (list of objects). + failurePolicy(string): Configuration Templates's Define failure policy if template provisioning fails . + Available values are 'ABORT_ON_ERROR', 'CONTINUE_ON_ERROR', 'ROLLBACK_ON_ERROR', + 'ROLLBACK_TARGET_ON_ERROR' and 'ABORT_TARGET_ON_ERROR'. + id(string): Configuration Templates's UUID of template . + language(string): Configuration Templates's Template language (JINJA or VELOCITY) . + lastUpdateTime(integer): Configuration Templates's Update time of template . + latestVersionTime(integer): Configuration Templates's Latest versioned template time . + name(string): Configuration Templates's Name of template . + parentTemplateId(string): Configuration Templates's Parent templateID . + projectId(string): Configuration Templates's Project UUID . + projectName(string): Configuration Templates's Project name . + rollbackTemplateContent(string): Configuration Templates's Rollback template content . + rollbackTemplateParams(list): Configuration Templates's rollbackTemplateParams (list of objects). + softwareType(string): Configuration Templates's Applicable device software type . + softwareVariant(string): Configuration Templates's Applicable device software variant . + softwareVersion(string): Configuration Templates's Applicable device software version . + tags(list): Configuration Templates's tags (list of objects). + templateContent(string): Configuration Templates's Template content . + templateParams(list): Configuration Templates's templateParams (list of objects). + validationErrors(object): Configuration Templates's validationErrors. + version(string): Configuration Templates's Current version of template . project_name(basestring): projectName path parameter. Project name to create template under the project . do_version(bool): doVersion query parameter. If this flag is true then it creates a new version of the @@ -565,7 +619,7 @@ def imports_the_templates_provided(self, already exists' error . headers(dict): Dictionary of HTTP Headers to send with the Request . - payload(list): A JSON serializable Python object to send in the + payload(dict): A JSON serializable Python object to send in the body of the Request. active_validation(bool): Enable/Disable payload validation. Defaults to True. @@ -584,7 +638,7 @@ def imports_the_templates_provided(self, https://developer.cisco.com/docs/dna-center/#!imports-the-templates-provided """ check_type(headers, dict) - check_type(payload, list) + check_type(payload, dict) check_type(do_version, bool) check_type(project_name, basestring, may_be_none=False) @@ -606,7 +660,62 @@ def imports_the_templates_provided(self, path_params = { 'projectName': project_name, } - _payload = payload or [] + _payload = { + 'tags': + tags, + 'author': + author, + 'composite': + composite, + 'containingTemplates': + containingTemplates, + 'createTime': + createTime, + 'customParamsOrder': + customParamsOrder, + 'description': + description, + 'deviceTypes': + deviceTypes, + 'failurePolicy': + failurePolicy, + 'id': + id, + 'language': + language, + 'lastUpdateTime': + lastUpdateTime, + 'latestVersionTime': + latestVersionTime, + 'name': + name, + 'parentTemplateId': + parentTemplateId, + 'projectId': + projectId, + 'projectName': + projectName, + 'rollbackTemplateContent': + rollbackTemplateContent, + 'rollbackTemplateParams': + rollbackTemplateParams, + 'softwareType': + softwareType, + 'softwareVariant': + softwareVariant, + 'softwareVersion': + softwareVersion, + 'templateContent': + templateContent, + 'templateParams': + templateParams, + 'validationErrors': + validationErrors, + 'version': + version, + } + _payload.update(payload or {}) + _payload = dict_from_items_with_values(_payload) if active_validation: self._request_validator('jsd_db7b6c4f0542aab9fe7cf5c995f83_v2_3_5_3')\ .validate(_payload) diff --git a/dnacentersdk/models/validators/v2_3_5_3/jsd_db7b6c4f0542aab9fe7cf5c995f83.py b/dnacentersdk/models/validators/v2_3_5_3/jsd_db7b6c4f0542aab9fe7cf5c995f83.py index abb5c2df..68e25dce 100644 --- a/dnacentersdk/models/validators/v2_3_5_3/jsd_db7b6c4f0542aab9fe7cf5c995f83.py +++ b/dnacentersdk/models/validators/v2_3_5_3/jsd_db7b6c4f0542aab9fe7cf5c995f83.py @@ -39,7 +39,6 @@ def __init__(self): self._validator = fastjsonschema.compile(json.loads( '''{ "$schema": "http://json-schema.org/draft-04/schema#", - "items": { "properties": { "author": { "type": "string" @@ -643,8 +642,6 @@ def __init__(self): } }, "type": "object" - }, - "type": "array" }'''.replace("\n" + ' ' * 16, '') )) From e5bf45bb5ad7a02b7045852d2c37f796d138c0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Wed, 10 Jan 2024 13:16:38 -0600 Subject: [PATCH 2/5] Updating request version. --- Pipfile | 2 +- requirements.txt | 2 +- setup.py | 2 +- test_new.py | 23 +++++++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test_new.py diff --git a/Pipfile b/Pipfile index 7a0b77e7..1ac5d3d2 100644 --- a/Pipfile +++ b/Pipfile @@ -4,7 +4,7 @@ verify_ssl = true name = "pypi" [packages] # Here goes your package requirements for running the application and its versions (which packages you will use when running the application). -requests = ">=2.27.1, <=2.28" +requests = ">=2.27.1, <=2.40.0" requests-toolbelt = ">=1.0.0" future = ">=0.18.3" fastjsonschema = ">=2.16.2" diff --git a/requirements.txt b/requirements.txt index b11d2656..7b217c02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ idna==3.4 ; python_version >= "3.6" and python_version < "4.0" \ requests-toolbelt==1.0.0 ; python_version >= "3.6" and python_version < "4.0" \ --hash=sha256:7681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6 \ --hash=sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06 -requests==2.27.1 ; python_version >= "3.6" and python_version < "4.0" \ +requests==2.31.0 ; python_version >= "3.6" and python_version < "4.0" \ --hash=sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61 \ --hash=sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d urllib3==1.26.16 ; python_version >= "3.6" and python_version < "4.0" \ diff --git a/setup.py b/setup.py index 0c34e2d3..a3208eac 100755 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ INSTALLATION_REQUIREMENTS = [ 'future>=0.18.3', - 'requests>=2.27.1,<=2.28', + 'requests>=2.27.1,<=2.40.0', 'fastjsonschema>=2.16.2', 'requests-toolbelt>=1.0.0', ] diff --git a/test_new.py b/test_new.py new file mode 100644 index 00000000..3c67f493 --- /dev/null +++ b/test_new.py @@ -0,0 +1,23 @@ +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 ] + +print(all_tags) \ No newline at end of file From 36880889b35e2c971e93261901907c9ea74e9838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Wed, 10 Jan 2024 13:35:13 -0600 Subject: [PATCH 3/5] request library updated --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 784b009a..32983347 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ readme = "README.rst" [tool.poetry.dependencies] python = "^3.6" -requests = ">=2.27.1, <=2.28" +requests = ">=2.27.1, <=2.40.0" fastjsonschema = "^2.16.2" future = "^0.18.3" requests-toolbelt = "^1.0.0" From 0e31922c1ea77d149c36b96b9be6b2501da34561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Wed, 10 Jan 2024 13:38:09 -0600 Subject: [PATCH 4/5] ## [2.6.11] - 2023-01-10 ### Fixed - Configuration template import template - check_type error #142 - Fixing required schema. - Updating request version. Issue #132 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fc2d78..631e5648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.6.11] - 2023-01-10 +### Fixed +- Configuration template import template - check_type error #142 - Fixing required schema. +- Updating request version. Issue #132 + ## [2.6.10] - 2023-11-10 ### Fixed - Fixed params in 2.3.5.3 claim_a_device_to_a_site from interfaceName to ipInterfaceName From 892eabdcd748357f1f06009a052d7f70214aaac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Wed, 10 Jan 2024 13:38:44 -0600 Subject: [PATCH 5/5] Updating changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 631e5648..27a58ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -469,4 +469,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [2.6.8]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.7...v2.6.8 [2.6.9]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.8...v2.6.9 [2.6.10]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.9...v2.6.10 -[Unreleased]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.10...develop +[2.6.11]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.10...v2.6.11 +[Unreleased]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.6.11...develop