API AND API DESIGN WITH PYTHON - PYTHON02 Course Outline

(5 Days)

Overview

Application Programming Interfaces (APIs) have become increasingly important as they provide developers with connectivity to everything from rich datasets in an array of formats (such as JSON) to exposing the configurability of software applications and network appliances. Lessons and labs focus on using Python to interact, design, and build APIs for the purposes of scripting automated solutions to complex tasks. Class is a combination of live demonstrations and hands-on labs.

Audience Profile

     System Administrators

     Network Engineers

     Software Developers

     Python Enthusiasts

Prerequisites

     Python Basics

     Coding experience in another language

At Course Completion

     Client side Python Scripting to RESTful (and non-RESTful) APIs

     Design RESTful API interfaces with Flask Web Framework

     Overview of Django

     Deploy your Python web apps as Docker containers

     Open SSH sessions and pass commands to remote servers

     Move files via SFTP

     Parse and manipulate popular data structures (JSON, CSV, Excel, and YAML) as pandas dataframes

     Best practice techniques

Course Outline

  1. Python Review

     Version Control with Git

     Lists

     Dictionaries

     Conditionals (if, elif, else)

     Loops (for and when)

     Functions

     Classes and Methods

     Using pip

 

  1. Working with Data – JSON, YAML, CSV and Excel

     JSON RFC 7159

     JSON Formatting

     YAML intro

     YAML Formatting

     Python Libraries for decoding JSON, YAML and CSV

     Reading and Writing to Excel

     Dataframes and pandas

 

  1. SSH Communication and SFTP

     Python and SSH

     Building an SFTP Client & Server

     Python and SFTP limitations

     Paramiko for SSH

     Netmiko and Major Network Vendors (Cisco, Juniper, Arista)

 

  1. Web and RESTful APIs

     Creating an HTTP Client & Server with Python

     Introduction to REST

     RESTful API on Etcd keystore (Kubernetes distributed DB)

     Creating a Python client to interact with API endpoints

     API dev keys

     Secure password retrieval

     Tokens and APIs

     OAuth v2.0

 

  1. API Design Practices

     RESTful Architecture

     Stubbing code with Swagger

     Describing Resource functionality (GET, POST, PUT, DELETE, etc.)

     Collections, resources, and URLs

     Using nouns, not verbs

     Understanding HTTP status codes

     Returning data

 

  1. Building APIs with Flask

     Flask Overview

     Decorators

     Building APIs with Python and Flask

     APIs returning Jinja2 templating

     Returning a ‘cookie’

     Building Sessions

     Redirecting from URIs

     Build an API to accept a file upload

     Overview of Django

 

  1. Deploying APIs

     Docker containers

     Docker build

     Constructing Docker images

     Dockerfile

     Deploying a Flask App on Docker

     Automating build processes

 

  1. Database Integration

     Overview

     Connecting to Python

     Read / Write operations

     Other useful instructions

     Connecting APIs and SQLite

     Python and PostgreSQL

     Python and MongoDB

     Reading and Writing to Databases with APIs

 

  1. Processes and Threads

     Threading

     Context change

     Deadlock errors

     Thread starvation

     Racing conditions and racing specifics

     Working with Locks

 

Labs

 

     Lab 1 – Using vim

     Lab 2 – Making a GitHub account

     Lab 3 – Getting dir(obj) help() and pydoc

     Lab 4 – Lists

     Lab 5 – Dictionaries

     Lab 6 – List and Dict Modeling

     Lab 7 – try and except

     Lab 8 – Python Data to JSON file

     Lab 9 – Python Data to YAML file

     Lab 10 – pandas dataframes – MS Excel, csv, json, HTML and beyond

     Lab 11 – CSV data – Standard Library and pandas dataframes

     Lab 12 – Introducing Paramiko

     Lab 13 – Paramiko SFTP with UN and PW

     Lab 14 – Paramiko SSH with RSA

     Lab 15 – Scripting Commands over SSH

     Lab 16 – RESTful Open APIs

     Lab 17 – RESTful Open APIs with requests

     Lab 18 – requests library – Open APIs

     Lab 19 – APIs and Dev Keys

     Lab 20 – RESTful APIs and Dev Keys

     Lab 21 – Logging API Behavior

     Lab 22 – requests library – GET vs POST to REST APIs

     Lab 23 – requests library – RESTful GET and JSON parsing

     Lab 24 – etcd and RESTful Client-side Design

     Lab 25 – Construct a SimpleHTTPServer and HTTP Client

     Lab 26 – Python to Cisco NX-OS API

     Lab 27 – Swagger for API Design

     Lab 28 – Building APIs with Python

     Lab 29 – Flask APIs and Jinja2

     Lab 30 – Flask APIs and Cookies

     Lab 31 – Flask Sessions

     Lab 32 – Flask Redirection, Errors, and API Limiting

     Lab 33 – Flask Uploading and Downloading Files

     Lab 34 – Learning sqlite3

     Lab 35 – Tracking API Data with sqlite3

     Lab 36 – Tracking Inventory with sqlite

     Lab 37 – Running Flask in a Docker Container

     Lab 38 – OAuth

     Lab 39 – Started with Django

     Lab 40 – Working With Threads

     Lab 41 – The Multiprocessing Module

     Lab 42 – Queues and Pipes

     Lab 43 – Introduction to Async IO

     Glossary