You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/04/10 16:50:40 UTC

[GitHub] pritidesai closed pull request #861: Partial fix for issue #847

pritidesai closed pull request #861: Partial fix for issue #847
URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/861
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/examples/manifest_hello_world_apigateway_sequence.yml b/docs/examples/manifest_hello_world_apigateway_sequence.yml
new file mode 100644
index 00000000..6dab7da3
--- /dev/null
+++ b/docs/examples/manifest_hello_world_apigateway_sequence.yml
@@ -0,0 +1,35 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements.  See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.  The ASF licenses this file to you
+# under the Apache License, Version 2.0 (the # "License"); you may not use this
+# file except in compliance with the License.  You may obtain a copy of the License
+# at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed
+# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations under the License.
+#
+
+# Example: Basic Hello World action with API
+packages:
+  hello_world_package:
+    version: 1.0
+    license: Apache-2.0
+    actions:
+      hello_basic:
+        function: src/hello.js
+      hello_goodday:
+        function: src/hello_goodday.js
+    sequences:
+      hello_world:
+        actions: hello_basic, hello_goodday
+        web: true
+    apis:
+      hello-world:
+        hello:
+          world:
+            hello_world: GET
diff --git a/docs/examples/src/hello_goodday.js b/docs/examples/src/hello_goodday.js
new file mode 100644
index 00000000..737e9d30
--- /dev/null
+++ b/docs/examples/src/hello_goodday.js
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/*
+ * This action is meant to capture the output from the basic Hello, world
+ * action and improve the greeting. It expects params to contain a greeting
+ * and just adds more to it.
+ */
+function main(params) {
+    msg = params.greeting + ", have a good day!";
+    return { greeting:  msg };
+}
diff --git a/docs/programming_guide.md b/docs/programming_guide.md
index ed562566..59b05808 100644
--- a/docs/programming_guide.md
+++ b/docs/programming_guide.md
@@ -56,6 +56,7 @@ Each example shows the "code", that is the Package Manifest, Deployment file and
   - [Binding parameters in a Deployment file](wskdeploy_triggerrule_trigger_bindings.md#triggers-and-rules) - using a deployment file to bind values to a Trigger’s parameters and applying them to a compatible manifest file.
 - API Gateway examples
   - [The "Hello World" API Gateway](wskdeploy_apigateway_helloworld.md#api-gateway) - deploy a "hello world" JavaScript function with associated HTTP API.
+  - [API Gateway sequence](wskdeploy_apigateway_sequence.md#api-gateway-sequence) - deploy JavaScript sequence with associated HTTP API.
 
 ---
 <!--
diff --git a/docs/wskdeploy_apigateway_helloworld.md b/docs/wskdeploy_apigateway_helloworld.md
index 570e08dd..39bdb1b2 100644
--- a/docs/wskdeploy_apigateway_helloworld.md
+++ b/docs/wskdeploy_apigateway_helloworld.md
@@ -111,7 +111,7 @@ For convenience, the Packages and Actions grammar can be found here:
   <tr>
     <td><a href="wskdeploy_triggerrule_trigger_bindings.md#triggers-and-rules">&lt;&lt;&nbsp;previous</a></td>
     <td><a href="programming_guide.md#guided-examples">Example Index</a></td>
-    <!--<td><a href="">next&nbsp;&gt;&gt;</a></td>-->
+    <td><a href="wskdeploy_apigateway_sequence.md#api-gateway-sequence">next&nbsp;&gt;&gt;</a></td>
   </tr>
 </table>
 </div>
diff --git a/docs/wskdeploy_apigateway_sequence.md b/docs/wskdeploy_apigateway_sequence.md
new file mode 100644
index 00000000..8ee24c3e
--- /dev/null
+++ b/docs/wskdeploy_apigateway_sequence.md
@@ -0,0 +1,123 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements.  See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.  The ASF licenses this file to you
+# under the Apache License, Version 2.0 (the # "License"); you may not use this
+# file except in compliance with the License.  You may obtain a copy of the License
+# at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed
+# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations under the License.
+#
+-->
+
+# API Gateway sequence
+
+## Sequencing actions
+
+This example builds on the ["Hello World" API Gateway](wskdeploy_apigateway_helloworld.md#api-gateway) example by combining multiple actions in a sequence to create a complex result and making this sequence available through the API Gateway.
+
+It shows how to:
+- create a sequence that chains multiple actions.
+- export the sequence via the gateway.
+
+### Manifest file
+#### _Example: “Hello world” sequence with API_
+```yaml
+packages:
+  hello_world_package:
+    version: 1.0
+    license: Apache-2.0
+    actions:
+      hello_basic:
+        function: src/hello.js
+      hello_goodday:
+        function: src/hello_goodday.js
+    sequences:
+      hello_world:
+        actions: hello_basic, hello_goodday
+        web: true
+    apis:
+      hello-world:
+        hello:
+          world:
+            hello_world: GET
+```
+
+There are two key changes to this file:
+- we now have two actions define and neither of them is web available.
+- we have a new sequence that is web available.
+- the `apis` block now refers to the sequence rather than the action.
+
+### Deploying
+
+You can actually deploy the "API Gateway sequence" manifest from the incubator-openwhisk-wskdeploy project directory if you have downloaded it from GitHub:
+
+```sh
+$ wskdeploy -m docs/examples/manifest_hello_world_apigateway_sequence.yaml
+```
+
+### Invoking
+
+Check the full URL of your API first:
+```sh
+$ wsk api list
+```
+
+This will return some information on the API, including the full URL, which
+should end with `hello/world`. It can then be invoked:
+
+```sh
+$ curl <url>
+```
+
+### Result
+The invocation should return a JSON response that includes this result:
+
+```json
+{
+    "greeting": "Hello, undefined from undefined, have a good day!"
+}
+```
+
+The output parameter '```greeting```' contains "_undefined_" values for the '```name```' and '```place```' input parameters as they were not provided in the manifest or the HTTP call. You can provide them as query parameters:
+
+```sh
+$ curl <url>?name=World&place=Earth
+```
+
+### Discussion
+
+This example is very basic but it shows the power of OpenWhisk in creating complex processes by chaining together simple actions and making the resulting sequence available via the API Gateway. This allows you to build small modular actions rather than big bulky ones. And because OpenWhisk allows actions to be written with different programming languages, you can mix and match, for example chaining a combination of JavaScript and Python actions in the same sequence.
+
+### Source code
+The source code for the manifest and JavaScript files can be found here:
+- [manifest_hello_world_apigateway_sequence.yaml](examples/manifest_hello_world_apigateway_sequence.yaml)
+- [hello.js](examples/src/hello.js)
+- [hello_goodday.js](examples/src/hello_goodday.js)
+
+### Specification
+For convenience, the Packages and Actions grammar can be found here:
+- **[Packages](../specification/html/spec_packages.md#packages)**
+- **[Actions](../specification/html/spec_actions.md#actions)**
+
+---
+<!--
+ Bottom Navigation
+-->
+<html>
+<div align="center">
+<table align="center">
+  <tr>
+    <td><a href="wskdeploy_apigateway_helloworld.md#packages">&lt;&lt;&nbsp;previous</a></td>
+    <td><a href="programming_guide.md#guided-examples">Example Index</a></td>
+    <!--<td><a href="">next&nbsp;&gt;&gt;</a></td>-->
+  </tr>
+</table>
+</div>
+</html>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services