commit | 1ec57d9750c875848c530dea3bd6434380dba753 | [log] [tgz] |
---|---|---|
author | Alex Glikson <alex.glikson@gmail.com> | Mon Jun 19 18:30:05 2017 +0300 |
committer | Matt Rutkowski <mrutkows@us.ibm.com> | Mon Jun 19 10:30:05 2017 -0500 |
tree | e568b070a3469a39ecff43c6285e669216bc592b | |
parent | 475487c5090baac7d316492a65c6d390b87c89de [diff] |
Explain how OpenWhisk API can be used from Python (#7) * Explain how OpenWhisk API can be used from Python Inspired by https://stackoverflow.com/questions/44626886/invoking-openwhisk-actions-from-a-python-app by @jthomas * typo * fixed links and wording in README.md
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 (in Bluemix):
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.