[DEPRECATED] - REST API of OpenWhisk can be used directly from Python

Clone this repo:
  1. 74f34db Add Apache 2 License badge to README. (#9) by Matt Rutkowski · 7 years ago master
  2. 1a06a39 Update README.md (#8) by Matt Rutkowski · 7 years ago
  3. 1ec57d9 Explain how OpenWhisk API can be used from Python (#7) by Alex Glikson · 7 years ago
  4. 475487c update Travis to include scancode utility. (#6) by Matt Rutkowski · 7 years ago
  5. 4fb68ef Update README.md (#5) by cclauss · 7 years ago

OpenWhisk Client for Python

License Build Status

There is no official Python client for Apache OpenWhisk at the moment. However, the REST API of OpenWhisk can be used directly from Python. Here is an example of Python code using the requests library to invoke echo action in OpenWhisk (using IBM's Bluemix as a target host):

import subprocess
import requests

APIHOST = 'https://openwhisk.ng.bluemix.net'
AUTH_KEY = subprocess.check_output("wsk property get --auth", shell=True).split()[2]
NAMESPACE = 'whisk.system'
ACTION = 'utils/echo'
PARAMS = {'myKey':'myValue'}
BLOCKING = 'true'
RESULT = 'true'

url = APIHOST + '/api/v1/namespaces/' + NAMESPACE + '/actions/' + ACTION
user_pass = AUTH_KEY.split(':')
response = requests.post(url, json=PARAMS, params={'blocking': BLOCKING, 'result': RESULT}, auth=(user_pass[0], user_pass[1]))
print(response.text)

Swagger documentation for full API is available here.

There is an open issue to create a Python client library to make this easier.

NOTE: This repository used to comprise an OpenWhisk CLI written in Python. The CLI has been superseded by a version written in Go.