Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python for Systems Engineers - Part 3

Python for Systems Engineers - Part 3

Python is one of the most popular programming languages of our time and the powerhouse behind most of Cisco’s API efforts. If there is a Cisco API chances are high that there will be a software development kit for that API in python. In this 3-part webinar series we will get our hands dirty with python.

In Part 3 we will get our hands dirty building a chat bot in Webex Teams.

Marcel Neidinger

November 21, 2019
Tweet

More Decks by Marcel Neidinger

Other Decks in Technology

Transcript

  1. Marcel Neidinger
    Associate Solutions Engineer, Programmability
    21/11/2019
    Part 3
    Python for Systems Engineers

    View Slide

  2. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    REST API – A Request
    Webex
    API
    GET /api/v1/people/me
    HTTP/1.1 200 OK
    Date: Thu, 10 Oct 2019 03:59:02 GMT
    Content-Type: application/json
    {
    “id”: “Y2lzY29zcGFyazovL3VzLA”,
    ”emails”: [
    [email protected]
    }
    }
    Header
    Body
    Location
    Method Identifier

    View Slide

  3. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    REST API – A Polling based approach
    Webex
    API

    View Slide

  4. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Webhooks
    Webex
    API
    POST 21ce:1ce:babe::8931/webhook
    Host: www.test01.com
    Accept: application/json
    Content-Length: 25
    {
    “id”: “Y2lzY29zcGFyazovL3VzLA”,
    ”event”: “created”,
    “resource”: “message”,
    [...]
    }

    View Slide

  5. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Webhooks
    Webex
    API
    POST 21ce:1ce:babe::8931/webhook
    Host: www.test01.com
    Accept: application/json
    Content-Length: 25
    {
    “id”: “Y2lzY29zcGFyazovL3VzLA”,
    ”event”: “created”,
    “resource”: “message”,
    [...]
    }
    Firewalls seriously dislike this
    (and InfoSec dislikes you if you try to do this)

    View Slide

  6. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Webhooks
    Webex
    API
    ngrok
    POST abcscor0ck5.ngrok.io
    HTTP/1.1 200 OK
    Date: Thu, 10 Oct 2019 03:59:02 GMT
    Content-Type: application/json
    {
    “success”: True
    }

    View Slide

  7. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Webhooks
    Webex
    API
    ngrok
    POST abcscor0ck5.ngrok.io
    HTTP/1.1 200 OK
    Date: Thu, 10 Oct 2019 03:59:02 GMT
    Content-Type: application/json
    {
    “success”: True
    }
    Hold on a minute
    You skipped the 43 hours spend setting up a webeserver

    View Slide

  8. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Meet Flask
    - Open Source
    - Micro-framework
    - Easy to Code
    - Easy to Configure
    - Well Documented
    - All in all awesome
    $ pip install flask

    View Slide

  9. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    Meet Flask
    - Open Source
    - Micro-framework
    - Easy to Code
    - Easy to Configure
    - Well Documented
    - All in all awesome
    $ pip install flask
    Lets build a webserver
    (In a tweet)

    View Slide

  10. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
    A simple webserver

    View Slide

  11. © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

    View Slide

  12. View Slide