├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── course.png ├── demo.gif ├── readme.md ├── requirements.txt └── src ├── aci └── aci-get-tenants.py ├── ansible ├── ansible.cfg ├── checklocalinfo.yml ├── hosts ├── servers └── writefile.yml ├── coding-basics ├── circleClass.py ├── data_structures.py ├── devfun.py ├── feedme.py ├── hands_on_lab.py ├── looping.py ├── random_quote.py ├── slide.py ├── structure.py └── variable_scope.py ├── deployment └── testscript.sh ├── dna-center ├── dna-center-authenticate.py ├── get_client_health.py ├── get_network_devices.py └── get_network_devices_list.py ├── meraki ├── devices-list.py ├── merakiapis.py ├── networks-list.py ├── networks-loop.py ├── organization-list.py ├── organization-loop.py ├── pagination-next.py ├── pagination.py └── serial-list.py ├── nso ├── get-devices.py ├── get-services.py └── loopbackdevnet.py ├── parsing ├── myfile.json ├── myfile.xml ├── myfile.yaml ├── parsejson.py ├── parsexml.py └── parseyaml.py ├── sample-app ├── sample-app.sh ├── sample_app.py ├── static │ └── style.css └── templates │ └── index.html ├── sd-wan └── sd-wan-get-devices.py ├── security └── password-evolution.py ├── unittest ├── best_json_search.py ├── improved_json_search.py ├── recursive_json_search.py ├── test_best_json_search.py ├── test_data.py ├── test_improved_json_search.py └── test_json_search.py └── webex-teams ├── authentication.py ├── create-markdown-message.py ├── create-membership.py ├── create-rooms.py ├── get-room-details.py ├── list-memberships.py ├── list-people.py ├── list-rooms.py ├── pagination-next.py └── pagination.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at devnet-github-owners@cisco.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Guidance on how to contribute 2 | 3 | Contributions to this code are welcome and appreciated. 4 | Please adhere to our [Code of Conduct](./CODE_OF_CONDUCT.md) at all times. 5 | 6 | > All contributions to this code will be released under the terms of the [LICENSE](./LICENSE) of this code. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest. Details can be found in our [LICENSE](./LICENSE). 7 | 8 | There are two primary ways to contribute: 9 | 10 | 1. Using the issue tracker 11 | 2. Changing the codebase 12 | 13 | 14 | ## Using the issue tracker 15 | 16 | Use the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution. 17 | 18 | Use the issue tracker to find ways to contribute. Find a bug or a feature, mention in the issue that you will take on that effort, then follow the _Changing the codebase_ guidance below. 19 | 20 | 21 | ## Changing the codebase 22 | 23 | Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All new code should have associated unit tests (if applicable) that validate implemented features and the presence or lack of defects. 24 | 25 | Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing codebase. 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Cisco Systems, Inc. and/or its affiliates 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | devasc-code-examples 2 | 3 | Copyright (c) 2020, Cisco Systems, Inc. and/or its affiliates 4 | 5 | This project includes software developed at Cisco Systems, Inc. and/or its affiliates. 6 | -------------------------------------------------------------------------------- /course.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/course.png -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/demo.gif -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Cisco DevNet Associate Fundamentals Course code examples 2 | 3 | The DevNet Associate Fundaments course has been retired from the DevNet site. This repo will be archived and then removed in a month. 4 | 5 | One of the best ways to study for the [Cisco DevNet Associate Certification](https://developer.cisco.com/certification/) is through hands-on practice using worked examples. 6 | 7 | ## Requirements 8 | 9 | Python 3.7 or higher 10 | 11 | ## Instructions 12 | 13 | You can clone this repo locally to work within your own development environment. To set up a developer environment, you can refer to the [DevNet Learning Labs](https://developer.cisco.com/learning-labs/setup/?utm_campaign=github21&utm_source=website&utm_medium=github-devasc-code-examples). 14 | 15 | The `master` branch contains the blank files that you can fill in during the course. 16 | 17 | The `solutions` branch contains the working code. 18 | 19 | The `src` folder contains code examples for all the hands-on exercises so you can try them in your own development environment. 20 | 21 | This code requires Python3. The [requirements.txt](./requirements.txt) file lists all the dependencies required by the code used in the course. Follow the instructions below to setup a local developerment environment that matches the in-browser development environment used in the course. Here's a quick walkthrough. 22 | 23 | ![asciicast demo](demo.gif) 24 | 25 | ## Get a local copy of the code 26 | 27 | 1. Clone the repository. For example, `git clone https://github.com/CiscoDevNet/devasc-code-examples.git`. 28 | 2. Change to the directory that contains the code files: `cd devasc-code-examples/`. 29 | 30 | ## Set up a Python Virtual Environment 31 | 32 | You want to work in a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html) so that you can be certainly only the required dependencies are installed and used for this project. 33 | 34 | > Note: This repository does not contain the source code for the Library REST API example included with the course development environment. You cannot run the `main.py` file and make calls successfully without the service available in the course. 35 | 36 | ### MacOS or Linux 37 | 38 | 1. `python3 -m venv venv` 39 | 2. `source venv/bin/activate` 40 | 3. `pip install -r requirements.txt` 41 | 42 | ### Windows - recommendation to use git-bash terminal 43 | 44 | 1. `py -3 -m venv venv` 45 | 2. `source venv/Scripts/activate` 46 | 3. `pip install -r requirements.txt` 47 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyYAML 2 | ansible==2.9.2 3 | requests 4 | flask 5 | pyotp==2.3.0 6 | pysqlite3==0.4.1 7 | -------------------------------------------------------------------------------- /src/aci/aci-get-tenants.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with code from the ACI hands-on lab 2 | -------------------------------------------------------------------------------- /src/ansible/ansible.cfg: -------------------------------------------------------------------------------- 1 | # Add to this file for the Read Information Ansible lab 2 | -------------------------------------------------------------------------------- /src/ansible/checklocalinfo.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/src/ansible/checklocalinfo.yml -------------------------------------------------------------------------------- /src/ansible/hosts: -------------------------------------------------------------------------------- 1 | # Enter the hosts or devices for Ansible playbooks 2 | -------------------------------------------------------------------------------- /src/ansible/servers: -------------------------------------------------------------------------------- 1 | # Enter the hosts or devices for Ansible playbooks 2 | -------------------------------------------------------------------------------- /src/ansible/writefile.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/src/ansible/writefile.yml -------------------------------------------------------------------------------- /src/coding-basics/circleClass.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the Coding Basics - Classes exercise 2 | -------------------------------------------------------------------------------- /src/coding-basics/data_structures.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code for Python practice with data structures 2 | -------------------------------------------------------------------------------- /src/coding-basics/devfun.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the course introduction 2 | -------------------------------------------------------------------------------- /src/coding-basics/feedme.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the introduction to Python 2 | -------------------------------------------------------------------------------- /src/coding-basics/hands_on_lab.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the introduction to Python 2 | 3 | # TRYIT: Write a print statement that displays both the type and value of Pi 4 | 5 | # TRYIT: Write a conditional to print out if `i` is less than or greater than 50 6 | 7 | # TRYIT: Write a conditional that prints the color of the picked fruit 8 | 9 | # TRYIT: Write a function that multiplies two numbers and returns the result 10 | 11 | # TRYIT: Write a function that multiplies two numbers and returns the result 12 | 13 | # TRYIT: Now call the function a few times to calculate the following answers 14 | -------------------------------------------------------------------------------- /src/coding-basics/looping.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code for Python looping exercise 2 | -------------------------------------------------------------------------------- /src/coding-basics/random_quote.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """Script flow and debugging. Print your own quote!""" 4 | 5 | 6 | import random 7 | 8 | 9 | QUOTES = [ 10 | "I see a DevNet Certification coming soon.", 11 | "All promises are either broken or kept. Or rejected.", 12 | "If you lose your temper, don't go looking for it.", 13 | ] 14 | 15 | 16 | def generate_quote() -> str: 17 | """Use a random selection to choose a random quote from the list.""" 18 | return random.choice(QUOTES) 19 | 20 | 21 | def generate_lucky_numbers(how_many: int) -> list: 22 | """Returns a list of (random) 'lucky' numbers.""" 23 | lucky_numbers = [] 24 | for _ in range(how_many): 25 | lucky_numbers.append(random.randint(0, 99)) 26 | return lucky_numbers 27 | 28 | 29 | def create_random_quote(how_many_lucky_numbers: int) -> str: 30 | """Create and return a random quote. 31 | 32 | The message should include the user's quote and lucky numbers. 33 | """ 34 | # TRYIT: Create a random quote by calling generate_quote() and 35 | # generate_lucky_numbers() and then composing and returning the quote. 36 | 37 | 38 | return "{quote}\nLucky Numbers: {lucky_numbers}".format( 39 | quote = quote, 40 | lucky_numbers = lucky_numbers, 41 | ) 42 | 43 | 44 | def main(): 45 | """Create and print a quote.""" 46 | print("Get your quote!") 47 | 48 | # Prompt the user for how many lucky numbers they would like 49 | qty_lucky_numbers = input("Also, how many lucky numbers would you like? ") 50 | qty_lucky_numbers = int(qty_lucky_numbers.strip()) 51 | 52 | # Create and display the response 53 | random_quote = create_random_quote(qty_lucky_numbers) 54 | print("\nHere is your quote:\n") 55 | print(random_quote) 56 | 57 | 58 | if __name__ == '__main__': 59 | main() 60 | -------------------------------------------------------------------------------- /src/coding-basics/slide.py: -------------------------------------------------------------------------------- 1 | ## TRYIT: Import the required math functions 2 | 3 | # TRYIT: Create variables to store the triangle sides input by the user 4 | 5 | # TRYIT: Use the int() function to convert the input string values to integers 6 | 7 | # TRYIT: Calculate the values 8 | 9 | # TRYIT: Create a Boolean variable to store true or false if the slide length meets safety standards 10 | 11 | # TRYIT: Create an if...elif...else statement to test the measurements of the slide 12 | 13 | # TRYIT Use an if...else statement to test whether the Boolean variable is True or False, and print the results 14 | -------------------------------------------------------------------------------- /src/coding-basics/structure.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/src/coding-basics/structure.py -------------------------------------------------------------------------------- /src/coding-basics/variable_scope.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code for Python practice with script structures 2 | -------------------------------------------------------------------------------- /src/deployment/testscript.sh: -------------------------------------------------------------------------------- 1 | # You can add to this file in the editor 2 | -------------------------------------------------------------------------------- /src/dna-center/dna-center-authenticate.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the DNA Center authenticate exercise 2 | -------------------------------------------------------------------------------- /src/dna-center/get_client_health.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the DNA Center Get Client Health exercise 2 | -------------------------------------------------------------------------------- /src/dna-center/get_network_devices.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from the DNA Center Get Network Devices exercise 2 | -------------------------------------------------------------------------------- /src/dna-center/get_network_devices_list.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from DNA Center Get Network Devices List exercise 2 | -------------------------------------------------------------------------------- /src/meraki/devices-list.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/meraki/merakiapis.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | -------------------------------------------------------------------------------- /src/meraki/networks-list.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/meraki/networks-loop.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/meraki/organization-list.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/meraki/organization-loop.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/meraki/pagination-next.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | -------------------------------------------------------------------------------- /src/meraki/pagination.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | -------------------------------------------------------------------------------- /src/meraki/serial-list.py: -------------------------------------------------------------------------------- 1 | # Add code for the Meraki hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/nso/get-devices.py: -------------------------------------------------------------------------------- 1 | # Add code from the NSO hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/nso/get-services.py: -------------------------------------------------------------------------------- 1 | # Add code from the NSO hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/nso/loopbackdevnet.py: -------------------------------------------------------------------------------- 1 | # Add code from the NSO hands-on lab here 2 | 3 | -------------------------------------------------------------------------------- /src/parsing/myfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "access_token":"ZDI3MGEyYzQtNmFlNS00NDNhLWFlNzAtZGVjNjE0MGU1OGZmZWNmZDEwN2ItYTU3", 3 | "expires_in":1209600, 4 | "refresh_token":"MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTEyMzQ1Njc4", 5 | "refreshtokenexpires_in":7776000 6 | } 7 | -------------------------------------------------------------------------------- /src/parsing/myfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | merge 9 | set 10 | 11 | 9 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/parsing/myfile.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | access_token: ZDI3MGEyYzQtNmFlNS00NDNhLWFlNzAtZGVjNjE0MGU1OGZmZWNmZDEwN2ItYTU3 3 | expires_in: 1209600 4 | refresh_token: MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTEyMzQ1Njc4 5 | refreshtokenexpires_in: 7776000 6 | -------------------------------------------------------------------------------- /src/parsing/parsejson.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from parsing JSON exercise 2 | -------------------------------------------------------------------------------- /src/parsing/parsexml.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from parsing XML exercise 2 | -------------------------------------------------------------------------------- /src/parsing/parseyaml.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from parsing YAML exercise 2 | -------------------------------------------------------------------------------- /src/sample-app/sample-app.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/devasc-code-examples/9d7332f496abdfd8ba55675728427b8c15aaca23/src/sample-app/sample-app.sh -------------------------------------------------------------------------------- /src/sample-app/sample_app.py: -------------------------------------------------------------------------------- 1 | # Add to this file for the sample app lab 2 | -------------------------------------------------------------------------------- /src/sample-app/static/style.css: -------------------------------------------------------------------------------- 1 | body {background: lightsteelblue;} 2 | -------------------------------------------------------------------------------- /src/sample-app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sample app 4 | 5 | 6 | 7 |

You are calling me from {{request.remote_addr}}

8 | 9 | 10 | -------------------------------------------------------------------------------- /src/sd-wan/sd-wan-get-devices.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code from Cisco SD-WAN get devices exercise 2 | -------------------------------------------------------------------------------- /src/security/password-evolution.py: -------------------------------------------------------------------------------- 1 | # You can add to this file in the editor 2 | -------------------------------------------------------------------------------- /src/unittest/best_json_search.py: -------------------------------------------------------------------------------- 1 | # Further improvement for the json_search function 2 | -------------------------------------------------------------------------------- /src/unittest/improved_json_search.py: -------------------------------------------------------------------------------- 1 | # Improved recursive JSON search function 2 | -------------------------------------------------------------------------------- /src/unittest/recursive_json_search.py: -------------------------------------------------------------------------------- 1 | # Fill the Python code in this file 2 | -------------------------------------------------------------------------------- /src/unittest/test_best_json_search.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | 4 | from best_json_search import * 5 | from test_data import * 6 | 7 | class json_search_test(unittest.TestCase): 8 | """test module to test search function in `best_json_search.py` """ 9 | 10 | def test_search_found(self): 11 | """key should be found, return list should not be empty""" 12 | self.assertTrue([]!=json_search(key1,data)) 13 | def test_search_not_found(self): 14 | """key should not be found, should return an empty list""" 15 | self.assertTrue([]==json_search(key2,data)) 16 | def test_is_a_list(self): 17 | """Should return a list""" 18 | self.assertIsInstance(json_search(key1,data),list) 19 | 20 | if __name__ == '__main__': 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /src/unittest/test_data.py: -------------------------------------------------------------------------------- 1 | key1 = "issueSummary" 2 | key2 = "XY&^$#*@!1234%^&" 3 | 4 | data = { 5 | "id": "AWcvsjx864kVeDHDi2gB", 6 | "instanceId": "E-NETWORK-EVENT-AWcvsjx864kVeDHDi2gB-1542693469197", 7 | "category": "Warn", 8 | "status": "NEW", 9 | "timestamp": 1542693469197, 10 | "severity": "P1", 11 | "domain": "Availability", 12 | "source": "DNAC", 13 | "priority": "P1", 14 | "type": "Network", 15 | "title": "Device unreachable", 16 | "description": "This network device leaf2.abc.inc is unreachable from controller. The device role is ACCESS.", 17 | "actualServiceId": "10.10.20.82", 18 | "assignedTo": "", 19 | "enrichmentInfo": { 20 | "issueDetails": { 21 | "issue": [ 22 | { 23 | "issueId": "AWcvsjx864kVeDHDi2gB", 24 | "issueSource": "Cisco DNA", 25 | "issueCategory": "Availability", 26 | "issueName": "snmp_device_down", 27 | "issueDescription": "This network device leaf2.abc.inc is unreachable from controller. The device role is ACCESS.", 28 | "issueEntity": "network_device", 29 | "issueEntityValue": "10.10.20.82", 30 | "issueSeverity": "HIGH", 31 | "issuePriority": "", 32 | "issueSummary": "Network Device 10.10.20.82 Is Unreachable From Controller", 33 | "issueTimestamp": 1542693469197, 34 | "suggestedActions": [ 35 | { 36 | "message": "From the controller, verify whether the last hop is reachable.", 37 | "steps": [] 38 | }, 39 | { 40 | "message": "Verify that the physical port(s) on the network device associated with the network device discovery(IP) is UP.", 41 | "steps": [] 42 | }, 43 | { 44 | "message": "Verify access to the device.", 45 | "steps": [] 46 | } 47 | ], 48 | "impactedHosts": [ 49 | { 50 | "hostName": "DUT", 51 | "hostOs": "Windows", 52 | "ssid": "Unknown", 53 | "connectedInterface": "Unknown", 54 | "failedAttempts": 3, 55 | "location": { 56 | "siteId": "SanJose", 57 | "siteType": "BUILDING", 58 | "area": "Global", 59 | "building": "ABC", 60 | "apsImpacted": [] 61 | }, 62 | "timestamp": 1542693469197 63 | } 64 | ] 65 | } 66 | ] 67 | }, 68 | "connectedDevice": [ 69 | { 70 | "deviceDetails": { 71 | "family": "Switches and Hubs", 72 | "type": "Cisco Catalyst 9300 Switch", 73 | "errorCode": "SNMP-TIMEOUT", 74 | "macAddress": "50:60:ab:cd:70:80", 75 | "role": "ACCESS", 76 | "apManagerInterfaceIp": "", 77 | "associatedWlcIp": "", 78 | "bootDateTime": "2020-01-01 00:00:01", 79 | "collectionStatus": "Partial Collection Failure", 80 | "interfaceCount": "66", 81 | "lineCardCount": "1", 82 | "lineCardId": "022daaff-2a4a-4eb6-9050-91aab668fdf2", 83 | "managementIpAddress": "10.10.20.21", 84 | "memorySize": "888963920", 85 | "platformId": "C9300-48U", 86 | "reachabilityFailureReason": "Collection Failure", 87 | "reachabilityStatus": "Unreachable", 88 | "snmpContact": "", 89 | "snmpLocation": "", 90 | "series": "Cisco Catalyst 9300 Series Switches", 91 | "inventoryStatusDetail": "", 92 | "collectionInterval": "Global Default", 93 | "serialNumber": "FCW1234L0UZ", 94 | "softwareVersion": "16.6.3", 95 | "roleSource": "AUTO", 96 | "hostname": "leaf2.abc.inc", 97 | "upTime": "01:08:43.96", 98 | "lastUpdateTime": 1542693255158, 99 | "errorDescription": "SNMP timeouts are occurring with this device. Either the SNMP credentials are not correctly provided to controller or the device is responding slow and snmp timeout is low. If its a timeout issue, controller will attempt to progressively adjust the timeout in subsequent collection cycles to get device to managed state. User can also run discovery again only for this device using the discovery feature after adjusting the timeout and snmp credentials as required. Or user can update the timeout and snmp credentials as required using update credentials.", 100 | "tagCount": "0", 101 | "lastUpdated": "2018-11-20 05:54:15", 102 | "instanceUuid": "a7633ae5-d3c9-4aea-837d-c3ad5b19c802", 103 | "id": "a7633ae5-d3c9-4aea-837d-c3ad5b19c802", 104 | "neighborTopology": [ 105 | { 106 | "errorCode": 5000, 107 | "message": "An internal has error occurred while processing this request.", 108 | "detail": "An internal has error occurred while processing this request." 109 | } 110 | ], 111 | "cisco360view": "https://10.10.20.22/dna/assurance/home#networkDevice/a7633ae5-d3c9-4aea-837d-c3ad5b19c802" 112 | } 113 | } 114 | ] 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/unittest/test_improved_json_search.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | 4 | from improved_json_search import * 5 | from test_data import * 6 | 7 | class json_search_test(unittest.TestCase): 8 | """test module to test search function in `improved_json_search.py` """ 9 | 10 | def test_search_found(self): 11 | """key should be found, return list should not be empty""" 12 | self.assertTrue([]!=json_search(key1,data)) 13 | def test_search_not_found(self): 14 | """key should not be found, should return an empty list""" 15 | self.assertTrue([]==json_search(key2,data)) 16 | def test_is_a_list(self): 17 | """Should return a list""" 18 | self.assertIsInstance(json_search(key1,data),list) 19 | 20 | if __name__ == '__main__': 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /src/unittest/test_json_search.py: -------------------------------------------------------------------------------- 1 | # Fill the Python unittest code in this file 2 | -------------------------------------------------------------------------------- /src/webex-teams/authentication.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the authentication code from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/create-markdown-message.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the messages code from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/create-membership.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code to create a room membership from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/create-rooms.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code to create a new room from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/get-room-details.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code to get room details from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/list-memberships.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the membership code from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/list-people.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the people listing code from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/list-rooms.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the rooms/spaces listing code from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/pagination-next.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the code to get the next page of data from the Webex Teams exercise 2 | -------------------------------------------------------------------------------- /src/webex-teams/pagination.py: -------------------------------------------------------------------------------- 1 | # Fill in this file with the pagination code from the Webex Teams exercise 2 | --------------------------------------------------------------------------------