From 012db9fc2c25f086eb3fcfce63a043179001b13b Mon Sep 17 00:00:00 2001 From: Bryan Vargas Date: Thu, 11 Aug 2022 14:20:22 -0600 Subject: [PATCH 1/2] - New function on `fabric_wireless` for v2_3_3_0. + `add_ssid_to_ip_pool_mapping` --- CHANGELOG.md | 9 +- dnacentersdk/api/v2_3_3_0/fabric_wireless.py | 84 +++++++++++++++++++ .../jsd_ad96e712f4525a128368b1bfe3afc21c.py | 69 +++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 dnacentersdk/models/validators/v2_3_3_0/jsd_ad96e712f4525a128368b1bfe3afc21c.py diff --git a/CHANGELOG.md b/CHANGELOG.md index de13a8ee..63dedd2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.5.4] - 2022-08-11 + +### Added +- New function on `fabric_wireless` for v2_3_3_0. + + `add_ssid_to_ip_pool_mapping` + ## [2.5.3] - 2022-08-09 ### Fixed @@ -345,4 +351,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [2.5.1]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.0...v2.5.1 [2.5.2]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.1...v2.5.2 [2.5.3]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.2...v2.5.3 -[Unreleased]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.3...master +[2.5.4]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.3...v2.5.4 +[Unreleased]: https://github.com/cisco-en-programmability/dnacentersdk/compare/v2.5.4...master diff --git a/dnacentersdk/api/v2_3_3_0/fabric_wireless.py b/dnacentersdk/api/v2_3_3_0/fabric_wireless.py index 5a4c5ea7..d61ad3d8 100644 --- a/dnacentersdk/api/v2_3_3_0/fabric_wireless.py +++ b/dnacentersdk/api/v2_3_3_0/fabric_wireless.py @@ -66,6 +66,90 @@ def __init__(self, session, object_factory, request_validator): self._object_factory = object_factory self._request_validator = request_validator + def add_ssid_to_ip_pool_mapping(self, + scalableGroupName=None, + siteNameHierarchy=None, + ssidNames=None, + vlanName=None, + headers=None, + payload=None, + active_validation=True, + **request_parameters): + """Add SSID to IP Pool Mapping. . + + Args: + scalableGroupName(string): Fabric Wireless's Scalable Group Name . + siteNameHierarchy(string): Fabric Wireless's Site Name Hierarchy . + ssidNames(list): Fabric Wireless's List of SSIDs (list of strings). + vlanName(string): Fabric Wireless's VLAN Name . + headers(dict): Dictionary of HTTP Headers to send with the Request + . + 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. + **request_parameters: Additional request parameters (provides + support for parameters that may be added in the future). + + Returns: + list: JSON response. A list of MyDict objects. + Access the object's properties by using the dot notation + or the bracket notation. + + Raises: + TypeError: If the parameter types are incorrect. + MalformedRequest: If the request body created is invalid. + ApiError: If the DNA Center cloud returns an error. + """ + check_type(headers, dict) + check_type(payload, dict) + if headers is not None: + if 'X-Auth-Token' in headers: + check_type(headers.get('X-Auth-Token'), + basestring, may_be_none=False) + + _params = { + } + _params.update(request_parameters) + _params = dict_from_items_with_values(_params) + + path_params = { + } + _payload = { + 'vlanName': + vlanName, + 'scalableGroupName': + scalableGroupName, + 'ssidNames': + ssidNames, + 'siteNameHierarchy': + siteNameHierarchy, + } + _payload.update(payload or {}) + _payload = dict_from_items_with_values(_payload) + if active_validation: + self._request_validator('jsd_ad96e712f4525a128368b1bfe3afc21c_v2_3_3_0')\ + .validate(_payload) + + with_custom_headers = False + _headers = self._session.headers or {} + if headers: + _headers.update(dict_of_str(headers)) + with_custom_headers = True + + e_url = ('/dna/intent/api/v1/business/sda/hostonboarding/ssid-' + + 'ippool') + endpoint_full_url = apply_path_params(e_url, path_params) + if with_custom_headers: + json_data = self._session.post(endpoint_full_url, params=_params, + json=_payload, + headers=_headers) + else: + json_data = self._session.post(endpoint_full_url, params=_params, + json=_payload) + + return self._object_factory('bpm_ad96e712f4525a128368b1bfe3afc21c_v2_3_3_0', json_data) + def update_ssid_to_ip_pool_mapping2(self, scalableGroupName=None, siteNameHierarchy=None, diff --git a/dnacentersdk/models/validators/v2_3_3_0/jsd_ad96e712f4525a128368b1bfe3afc21c.py b/dnacentersdk/models/validators/v2_3_3_0/jsd_ad96e712f4525a128368b1bfe3afc21c.py new file mode 100644 index 00000000..256382f1 --- /dev/null +++ b/dnacentersdk/models/validators/v2_3_3_0/jsd_ad96e712f4525a128368b1bfe3afc21c.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +"""Cisco DNA Center AddSSIDToIPPoolMapping data model. + +Copyright (c) 2019-2021 Cisco Systems. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from __future__ import absolute_import, division, print_function, unicode_literals + +import json +from builtins import * + +import fastjsonschema + +from dnacentersdk.exceptions import MalformedRequest + + +class JSONSchemaValidatorAd96E712F4525A128368B1Bfe3Afc21C(object): + """AddSSIDToIPPoolMapping request schema definition.""" + def __init__(self): + super(JSONSchemaValidatorAd96E712F4525A128368B1Bfe3Afc21C, self).__init__() + self._validator = fastjsonschema.compile(json.loads( + '''{ + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "scalableGroupName": { + "type": "string" + }, + "siteNameHierarchy": { + "type": "string" + }, + "ssidNames": { + "items": { + "type": "string" + }, + "type": "array" + }, + "vlanName": { + "type": "string" + } + }, + "type": "object" + }'''.replace("\n" + ' ' * 16, '') + )) + + def validate(self, request): + try: + self._validator(request) + except fastjsonschema.exceptions.JsonSchemaException as e: + raise MalformedRequest( + '{} is invalid. Reason: {}'.format(request, e.message) + ) From 96877a004572f9c2f882795743b04982c458c5bc Mon Sep 17 00:00:00 2001 From: Bryan Vargas Date: Thu, 11 Aug 2022 14:20:41 -0600 Subject: [PATCH 2/2] v2.5.4 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 36a98cfb..98e8c7fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dnacentersdk" -version = "2.5.3" +version = "2.5.4" description = "Cisco DNA Center Platform SDK" authors = ["Jose Bogarin Solano ", "William Astorga "] license = "MIT"