openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mrutkow...@apache.org
Subject [incubator-openwhisk-client-python] branch master updated: Explain how OpenWhisk API can be used from Python (#7)
Date Mon, 19 Jun 2017 15:30:07 GMT
This is an automated email from the ASF dual-hosted git repository.

mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-python.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ec57d9  Explain how OpenWhisk API can be used from Python (#7)
1ec57d9 is described below

commit 1ec57d9750c875848c530dea3bd6434380dba753
Author: Alex Glikson <alex.glikson@gmail.com>
AuthorDate: Mon Jun 19 18:30:05 2017 +0300

    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
---
 README.md | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 4381174..04b77e5 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,27 @@
-# openwhisk-python-cli
-## OpenWhisk Command Line Interface (CLI) written in Python.
-[![Build Status](https://travis-ci.org/openwhisk/openwhisk-client-python.svg?branch=master)](https://travis-ci.org/openwhisk/openwhisk-client-python)
+# incubator-openwhisk-client-python
+[![Build Status](https://api.travis-ci.org/apache/incubator-openwhisk-client-python.svg?branch=master)](https://api.travis-ci.org/apache/incubator-openwhisk-client-python)
 
-NOTE: This CLI is no longer used in production as it has been [superseded by a version written
in Go](https://github.com/openwhisk/openwhisk/tree/master/tools/cli).
+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):
+
+``` python
+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](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/apache/incubator-openwhisk/master/core/controller/src/main/resources/apiv1swagger.json).
+
+There is an [open issue](apache/incubator-openwhisk#450) 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](https://github.com/apache/incubator-openwhisk-cli).

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Mime
View raw message