openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From houshen...@apache.org
Subject [incubator-openwhisk-wskdeploy] branch master updated: Update Programmin Guide - part8, add TriggerRule examples (#561)
Date Wed, 27 Sep 2017 20:59:01 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 46c3277  Update Programmin Guide - part8, add TriggerRule examples (#561)
46c3277 is described below

commit 46c3277ff928cf158231c499499d9cd5232bb577
Author: Matt Rutkowski <mrutkows@us.ibm.com>
AuthorDate: Wed Sep 27 15:58:59 2017 -0500

    Update Programmin Guide - part8, add TriggerRule examples (#561)
    
    * Tweak README links.
    
    * Advanced hello world action in JS.
    
    * More advaned action updates; hello_plus.js; sync with spec text.
    
    * More advaned action updates; hello_plus.js; sync with spec text.
    
    * More advaned action updates; hello_plus.js; sync with spec text.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
    
    * Update for template consistency and begin TriggerRule example.
---
 README.md                                          |  2 +-
 docs/examples/deployment_hello_world_2.yaml        |  9 ---
 .../deployment_hello_world_triggerrule.yaml        |  9 +++
 .../manifest_hello_world_advanced_parms.yaml       | 13 ++--
 .../examples/manifest_hello_world_triggerrule.yaml | 28 ++++++++
 .../examples/manifest_hello_world_typed_parms.yaml |  5 +-
 docs/examples/src/hello_plus.js                    | 12 ++++
 docs/programming_guide.md                          |  6 +-
 docs/wskdeploy_action_advanced_parms.md            | 31 ++++----
 docs/wskdeploy_action_fixed_parms.md               | 18 ++---
 docs/wskdeploy_action_helloworld.md                | 17 +++--
 docs/wskdeploy_action_typed_parms.md               | 45 +++++++-----
 docs/wskdeploy_triggerrule_basic.md                | 84 +++++++++++++++++++---
 13 files changed, 202 insertions(+), 77 deletions(-)

diff --git a/README.md b/README.md
index 315afc9..1612f40 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ You can use this in addition to the OpenWhisk CLI.  In fact, this utility
uses t
 - [Building the project](#building-the-project) - download and build the GoLang source code
 - [Running wskdeploy](#running-wskdeploy) - run wskdeploy as a binary or Go program
 - [Downloading released binaries](#downloading-released-binaries) - for Linux, Mac OS and
Windows
-- [Writing Package manifests](docs/programming_guide.md) - step-by-step guide on writing
Package Manifest and deployment files for ```wskdeploy```
+- [Writing Package manifests](docs/programming_guide.md#wskdeploy-utility-by-example) - step-by-step
guide on writing Package Manifest and deployment files for ```wskdeploy```
 - [Contributing to the project](#contributing-to-the-project) - join us!
 - [Debugging wskdeploy](docs/wskdeploy_debugging.md) - helpful tips for debugging the code
and your manifest files
 - [Troubleshooting](#troubleshooting) - known issues (e.g., Git)
diff --git a/docs/examples/deployment_hello_world_2.yaml b/docs/examples/deployment_hello_world_2.yaml
deleted file mode 100644
index 7e9acdc..0000000
--- a/docs/examples/deployment_hello_world_2.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-application:
-  name: foo
-  packages:
-    hello_world_package:
-      actions:
-        ello_world:
-          inputs:
-            name: Amy
-            place: Paris
diff --git a/docs/examples/deployment_hello_world_triggerrule.yaml b/docs/examples/deployment_hello_world_triggerrule.yaml
new file mode 100644
index 0000000..597eff8
--- /dev/null
+++ b/docs/examples/deployment_hello_world_triggerrule.yaml
@@ -0,0 +1,9 @@
+package:
+  hello_world:
+    triggers:
+      meetPerson:
+        inputs:
+          name: Sam
+          place: the Shire.
+          children: 13
+          height: 1.2
diff --git a/docs/examples/manifest_hello_world_advanced_parms.yaml b/docs/examples/manifest_hello_world_advanced_parms.yaml
index a727ff7..7db8356 100644
--- a/docs/examples/manifest_hello_world_advanced_parms.yaml
+++ b/docs/examples/manifest_hello_world_advanced_parms.yaml
@@ -1,20 +1,20 @@
 # Example: input and output parameters with advanced fields
 package:
   name: hello_world_package
-  ... # Package keys omitted for brevity
+  version: 1.0
+  license: Apache-2.0
   actions:
     hello_world_advanced_parms:
-      function: src/hello/hello.js
-      runtime: nodejs@6
+      function: src/hello_plus.js
       inputs:
         name:
           type: string
           description: name of person
-          value: Sam
+          default: unknown person
         place:
           type: string
           description: location of person
-          default: unknown
+          value: the Shire
         children:
           type: integer
           description: Number of children
@@ -27,3 +27,6 @@ package:
         greeting:
           type: string
           description: greeting string
+        details:
+          type: string
+          description: detailed information about the person
diff --git a/docs/examples/manifest_hello_world_triggerrule.yaml b/docs/examples/manifest_hello_world_triggerrule.yaml
new file mode 100644
index 0000000..4d41626
--- /dev/null
+++ b/docs/examples/manifest_hello_world_triggerrule.yaml
@@ -0,0 +1,28 @@
+package:
+  name: hello_world_package
+  version: 1.0
+  license: Apache-2.0
+  actions:
+    hello_world_triggerrule:
+      function: src/hello_plus.js
+      inputs:
+        name: string
+        place: string
+        children: integer
+        height: float
+      outputs:
+        greeting: string
+        details: string
+
+  triggers:
+    meetPerson:
+      inputs:
+        name: Sam
+        place: the Shire
+        children: 13
+        height: 1.2
+
+  rules:
+    meetPersonRule:
+      trigger: meetPerson
+      action: hello_world_triggerrule
diff --git a/docs/examples/manifest_hello_world_typed_parms.yaml b/docs/examples/manifest_hello_world_typed_parms.yaml
index 4b1a58d..0a4bd38 100644
--- a/docs/examples/manifest_hello_world_typed_parms.yaml
+++ b/docs/examples/manifest_hello_world_typed_parms.yaml
@@ -1,11 +1,11 @@
-# Example: “Hello world” with explicit input and output parameter declarations
+# Example: “Hello world” with typed input and output parameter declarations
 package:
   name: hello_world_package
   version: 1.0
   license: Apache-2.0
   actions:
     hello_world_typed_parms:
-      function: src/hello.js
+      function: src/hello_plus.js
       inputs:
         name: string
         place: string
@@ -13,3 +13,4 @@ package:
         height: float
       outputs:
         greeting: string
+        details: string
diff --git a/docs/examples/src/hello_plus.js b/docs/examples/src/hello_plus.js
new file mode 100644
index 0000000..ff9c93a
--- /dev/null
+++ b/docs/examples/src/hello_plus.js
@@ -0,0 +1,12 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/*
+ * Hello, world. Plus more
+ */
+function main(params) {
+    msg = "Hello, " + params.name + " from " + params.place;
+    family = "You have " + params.children + " children ";
+    stats = "and are " + params.height + " m. tall.";
+    return { greeting:  msg, details: family + stats };
+}
diff --git a/docs/programming_guide.md b/docs/programming_guide.md
index 0aa4489..77a48bd 100644
--- a/docs/programming_guide.md
+++ b/docs/programming_guide.md
@@ -26,10 +26,10 @@ Each example shows the "code", that is the Package Manifest, Deployment
file and
   - [Creating a minimal Package](wskdeploy_package_minimal.md#packages) - creating a basic
package manifest and deploying it.
 - Action examples
   - [The "Hello World" Action](wskdeploy_action_helloworld.md#actions) - deploy a "hello
world" JavaScript function using a manifest.
-  - [Adding fixed input parameters](wskdeploy_action_fixed_parms.md#actions) - bind fixed
values to input parameters.
+  - [Adding fixed input parameters](wskdeploy_action_fixed_parms.md#actions) - bind fixed
values to the input parameters of "hello world".
   - [Typed Parameters](wskdeploy_action_typed_parms.md#actions) - declare named input and
output parameters on an Action with their types.
-  - [Advanced Parameters](wskdeploy_action_advanced_parms.md#actions) - input and output
parameter declarations with more detailed information.
-- Trigger and Rule examples
+  - [Advanced Parameters](wskdeploy_action_advanced_parms.md#actions) - input and output
parameter declarations with types, descriptions, defaults and more.
+- Trigger and Rule examples.
   - [Basic Trigger and Rule](wskdeploy_triggerrule_basic.md#triggers-and-rules) - adding
a basic trigger and rule to the advanced Parameter "hello world".
 
 <!--     - [Declaring Runtime version]() - TBD -->
diff --git a/docs/wskdeploy_action_advanced_parms.md b/docs/wskdeploy_action_advanced_parms.md
index e166dcd..3ea12b5 100644
--- a/docs/wskdeploy_action_advanced_parms.md
+++ b/docs/wskdeploy_action_advanced_parms.md
@@ -6,11 +6,8 @@ This example builds on the previous [“Hello world" with typed input and
output
 
 This example:
 - shows how to declare input and output parameters on the action ‘```hello_world```’
using a multi-line grammar.
-- adds the ‘```name```’ and ‘```place```’ input parameters, both of type ‘```string```’,
to the ‘```hello_world``’ action each also includes an associated ‘```description```’
value.
-- adds the ‘```greeting```’ output parameter of explicit ‘```type```’ of ‘```string```’
to the ‘```hello_world```’ action with a ‘```description```’.
 
 ### Manifest File
-
 If we want to do more than declare the type (i.e., ‘string’, ‘integer’, ‘float’,
etc.) of the input parameter, we can use the multi-line grammar.
 
 #### _Example: input and output parameters with explicit types and descriptions_
@@ -20,17 +17,17 @@ package:
   ... # Package keys omitted for brevity
   actions:
     hello_world_advanced_parms:
-      function: src/hello/hello.js
+      function: src/hello_plus.js
       runtime: nodejs@6
       inputs:
         name:
           type: string
           description: name of person
-          value: Sam
+          default: unknown person
         place:
           type: string
           description: location of person
-          default: unknown
+          value: the Shire
         children:
           type: integer
           description: Number of children
@@ -43,6 +40,9 @@ package:
         greeting:
           type: string
           description: greeting string
+        details:
+          type: string
+          description: detailed information about the person
 ```
 
 ### Deploying
@@ -56,25 +56,30 @@ $ wsk action invoke hello_world_package/hello_world_advanced_parms --blocking
 ```
 
 ### Result
+The invocation should return an 'ok' with a response that includes this result:
 ```sh
 "result": {
-    "greeting": "Hello, Sam from unknown"
-},
+            "details": "You have 0 children and are 0 m. tall.",
+            "greeting": "Hello, unknown person from the Shire"
+        },
 ```
 
 ### Discussion
-Describing the input and output parameter types, descriptions, defaults and other data:
-- enables tooling to validate values users may input and prompt for missing values using
the descriptions provided.
-- allows verification that outputs of an Action are compatible with the expected inputs of
another Action so that they can be composed in a sequence.
+- Describing the input and output parameter types, descriptions, defaults and other data:
+  - enables tooling to validate values users may input and prompt for missing values using
the descriptions provided.
+  - allows verification that outputs of an Action are compatible with the expected inputs
of another Action so that they can be composed in a sequence.
+- The '```name```' input parameter was assigned the '```default```' key's value "```unknown
person```".
+- The '```place```' input parameter was assigned the '```value```' key's value "```the Shire```".
 
 ### Source code
 The manifest file for this example can be found here:
 - [manifest_hello_world_advanced_parms.yaml](examples/manifest_hello_world_advanced_parms.yaml)
+- [hello_plus.js](examples/src/hello_plus.js)
 
 ### Specification
 For convenience, the Actions and Parameters grammar can be found here:
-- **[Actions](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_actions.md#actions)**
-- **[Parameters](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_parameters.md#parameters)**
+- **[Actions](../specification/html/spec_actions.md#actions)**
+- **[Parameters](../specification/html/spec_parameters.md#parameters)**
 
 ---
 <!--
diff --git a/docs/wskdeploy_action_fixed_parms.md b/docs/wskdeploy_action_fixed_parms.md
index e4a1be5..506947f 100644
--- a/docs/wskdeploy_action_fixed_parms.md
+++ b/docs/wskdeploy_action_fixed_parms.md
@@ -1,15 +1,14 @@
 # Actions
 
-## Adding fixed input parameters
+## Adding fixed input values to an Action
 
 This example builds upon the previous “hello world” example and shows how fixed values
can be supplied to the input parameters of an Action.
 
 It shows how to:
-- Declare input parameters on the action ‘```hello_world```’ using a single-line grammar.
-- Add ‘```name```’ and ‘```place```’ as input parameters with the fixed values “```Sam```”
and “```the Shire```” respectively.
+- declare input parameters on the action ‘```hello_world```’ using a single-line grammar.
+- add ‘```name```’ and ‘```place```’ as input parameters with the fixed values “```Sam```”
and “```the Shire```” respectively.
 
 ### Manifest File
-
 #### _Example: “Hello world” with fixed input values for ‘name’ and ‘place’_
 ```yaml
 package:
@@ -35,6 +34,7 @@ $ wsk action invoke hello_world_package/hello_world_fixed_parms --blocking
 ```
 
 ### Result
+The invocation should return an 'ok' with a response that includes this result:
 ```sh
 "result": {
     "greeting": "Hello, Sam from the Shire"
@@ -44,9 +44,9 @@ $ wsk action invoke hello_world_package/hello_world_fixed_parms --blocking
 ### Discussion
 
 In this example:
-- The value for the ‘```name```’ input parameter would be set to “```Sam```” and
+- The value for the ‘```name```’ input parameter would be set to “```Sam```”.
 - The value for the ‘```place```’ input parameter would be set to “```the Shire```”.
-- The wskdeploy utility would infer both of their Types were '```string```'.
+- The wskdeploy utility would infer that both ‘```name```’ and ‘```place```’ input
parameters to be of type ‘```string```’.
 
 ### Source code
 The manifest file for this example can be found here:
@@ -54,8 +54,8 @@ The manifest file for this example can be found here:
 
 ### Specification
 For convenience, the Actions and Parameters grammar can be found here:
-- **[Actions](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_actions.md#actions)**
-- **[Parameters](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_parameters.md#parameters)**
+- **[Actions](../specification/html/spec_actions.md#actions)**
+- **[Parameters](../specification/html/spec_parameters.md#parameters)**
 
 ---
 <!--
@@ -65,7 +65,7 @@ For convenience, the Actions and Parameters grammar can be found here:
 <div align="center">
 <table align="center">
   <tr>
-    <td><a href="">&lt;&lt;&nbsp;previous</a></td>
+    <td><a href="wskdeploy_action_helloworld.md#actions">&lt;&lt;&nbsp;previous</a></td>
     <td><a href="programming_guide.md#guided-examples">Example Index</a></td>
     <td><a href="wskdeploy_action_typed_parms.md#actions">next&nbsp;&gt;&gt;</a></td>
   </tr>
diff --git a/docs/wskdeploy_action_helloworld.md b/docs/wskdeploy_action_helloworld.md
index 2bd2c9c..d27a365 100644
--- a/docs/wskdeploy_action_helloworld.md
+++ b/docs/wskdeploy_action_helloworld.md
@@ -2,10 +2,13 @@
 
 ## The "Hello World" Action
 
-As with most language introductions, here we show a simple "hello world" action as encoded
in an OpenWhisk Package Manifest YAML file:
+As with most language introductions, in this first example we encode a simple "hello world"
action, written in JavaScript, using an OpenWhisk Package Manifest YAML file.
 
-### Manifest file
+It shows how to:
+- declare a single Action named ‘hello_world’ within the ‘hello_world_package’ Package.
+- associate the JavaScript function’s source code, stored in the file ‘src/hello.js’,
to the ‘hello_world’ Action.
 
+### Manifest file
 #### _Example: “Hello world” using a NodeJS (JavaScript) action_
 ```yaml
 package:
@@ -17,7 +20,8 @@ package:
       function: src/hello.js
 ```
 
-where "hello.js" contains the following JavaScript code:
+where "hello.js", within the package-relative subdirectory named ‘src’, contains the
following JavaScript code:
+
 ```javascript
 function main(params) {
     msg = "Hello, " + params.name + " from " + params.place;
@@ -47,7 +51,7 @@ The invocation should return an 'ok' with a response that includes this
result:
 },
 ```
 
-The output parameter '```greeting```''s value included "_undefined_" values for the '```name```'
and '```place```' input parameters as they were not provided in the manifest.
+The output parameter '```greeting```' contains "_undefined_" values for the '```name```'
and '```place```' input parameters as they were not provided in the manifest.
 
 ### Discussion
 
@@ -58,7 +62,6 @@ In the above example,
   - ```/<default namespace>/hello_world_package/hello_world```
 - The NodeJS default runtime (i.e., ```runtime: nodejs```) was selected automatically based
upon the file extension '```.js```'' of the function's source file '```hello.js```'.
 
-
 ### Source code
 The source code for the manifest and JavaScript files can be found here:
 - [manifest_hello_world.yaml](examples/manifest_hello_world.yaml)
@@ -66,8 +69,8 @@ The source code for the manifest and JavaScript files can be found here:
 
 ### Specification
 For convenience, the Packages and Actions grammar can be found here:
-- **[Packages](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_packages.md#packages)**
-- **[Actions](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_actions.md#actions)**
+- **[Packages](../specification/html/spec_packages.md#packages)**
+- **[Actions](../specification/html/spec_actions.md#actions)**
 
 ---
 <!--
diff --git a/docs/wskdeploy_action_typed_parms.md b/docs/wskdeploy_action_typed_parms.md
index 49b6f07..0ea70e6 100644
--- a/docs/wskdeploy_action_typed_parms.md
+++ b/docs/wskdeploy_action_typed_parms.md
@@ -2,34 +2,41 @@
 
 ## Typed parameters
 
-This example extends the 'Hello world' example with typed input and output Parameters.
+This example shows the 'Hello world' example with typed input and output Parameters.
 
 It shows how to:
-- Declare input and output parameters on the action '```hello_world```' using a simple, single-line
format.
-- Add two input parameters, '```name```' and '```place```', both of type '```string```' to
the '```hello_world```' action.
-- Add an '```integer```' parameter, '```age```', to the action.
-- Add a '```float```' parameter, '```height```', to the action.
-- Add an output parameter, '```greeting```' of type string to the '```hello_world```' action.
+- declare input and output parameters on the action '```hello_world```' using a simple, single-line
format.
+- add two input parameters, '```name```' and '```place```', both of type '```string```' to
the '```hello_world```' action.
+- add an '```integer```' parameter, '```age```', to the action.
+- add a '```float```' parameter, '```height```', to the action.
+- add two output parameters, '```greeting```' and '```details```', both of type '```string```',
to the action.
 
 ### Manifest File
-
-#### Example 3: 'Hello world' with typed input and output parameter declarations
+#### _Example: 'Hello world' with typed input and output parameter declarations_
 ```yaml
 package:
   name: hello_world_package
   ... # Package keys omitted for brevity
   actions:
     hello_world_typed_parms:
-      function: src/hello.js
+      function: src/hello_plus.js
       inputs:
         name: string
         place: string
         children: integer
         height: float
       outputs:
-greeting: string
-      outputs:
         greeting: string
+        details: string
+```
+where the function '```hello_plus.js```', within the package-relative subdirectory named
‘```src```’, is updated to use the new parameters:
+```javascript
+function main(params) {
+    msg = "Hello, " + params.name + " from " + params.place;
+    family = "You have " + params.children + " children ";
+    stats = "and are " + params.height + " m. tall.";
+    return { greeting:  msg, details: family + stats };
+}
 ```
 
 ### Deploying
@@ -43,9 +50,11 @@ $ wsk action invoke hello_world_package/hello_world_typed_parms --blocking
 ```
 
 ### Result
+The invocation should return an 'ok' with a response that includes this result:
 ```sh
 "result": {
-    "greeting": "Hello,  from "
+  "details": "You have 0 children and are 0 m. tall.",
+  "greeting": "Hello,  from "
 },
 ```
 
@@ -53,19 +62,19 @@ $ wsk action invoke hello_world_package/hello_world_typed_parms --blocking
 
 In this example:
 
-- The default values for the '```name```' and '```place```' inputs would be set to empty
strings (i.e., \"\"), which is the default value for type '```string```', when passed to the
'hello.js' function; therefore 'greeting' will appear a follows:
-  - ```"greeting": "Hello, from "```
-- The default value for integer, zero (0), will be assigned to the 'age' parameter.
-- The default value for float, zero (0.0), will be assigned to the 'height' parameter.
+- The default value for the '```string```' type is the empty string (i.e., \"\"); it was
assigned to the '```name```' and '```place```' input parameters.
+- The default value for the '```integer```' type is zero (0); it was assigned to the '```age```'
input parameter.
+- The default value for the '```float```' type is zero (0.0f); it was assigned to the '```height```'
input parameter.
 
 ### Source code
 The manifest file for this example can be found here:
 - [manifest_hello_world_typed_parms.yaml](examples/manifest_hello_world_typed_parms.yaml)
+- [hello_plus.js](examples/src/hello_plus.js)
 
 ### Specification
 For convenience, the Actions and Parameters grammar can be found here:
-- **[Actions](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_actions.md#actions)**
-- **[Parameters](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_parameters.md#parameters)**
+- **[Actions](../specification/html/spec_actions.md#actions)**
+- **[Parameters](../specification/html/spec_parameters.md#parameters)**
 
 ---
 <!--
diff --git a/docs/wskdeploy_triggerrule_basic.md b/docs/wskdeploy_triggerrule_basic.md
index 68fbe63..1d0d628 100644
--- a/docs/wskdeploy_triggerrule_basic.md
+++ b/docs/wskdeploy_triggerrule_basic.md
@@ -1,42 +1,106 @@
 # Triggers and Rules
 
-## Adding fixed input parameters
-TODO
+## Creating a Trigger for an Action
+This example shows how to create a Trigger that is compatible with the previous, more advanced
"Hello world" Action, which has multiple input parameters of different types, and connect
them together using a Rule.
 
 ### Manifest File
-
-#### _Example: “Hello world” with fixed input values for ‘name’ and ‘place’_
+#### _Example: “Hello world” Action with a compatible Trigger and Rule_
 ```yaml
 package:
   name: hello_world_package
   version: 1.0
   license: Apache-2.0
   actions:
+    hello_world_triggerrule:
+      function: src/hello_plus.js
+      runtime: nodejs
+      inputs:
+        name: string
+        place: string
+        children: integer
+        height: float
+      outputs:
+        greeting: string
+        details: string
+
+  triggers:
+    meetPerson:
+      inputs:
+        name: Sam
+        place: the Shire
+        children: 13
+        height: 1.2
 
+  rules:
+    meetPersonRule:
+      trigger: meetPerson
+      action: hello_world_triggerrule
 ```
 
 ### Deploying
 ```sh
-$ wskdeploy -m
+$ wskdeploy -m docs/examples/manifest_hello_world_triggerrule.yaml
 ```
 
 ### Invoking
+First, let's try _"invoking"_ the hello_world_triggerrule' Action directly without the Trigger.
 ```sh
-$ wsk action invoke
+$ wsk action invoke hello_world_package/hello_world_triggerrule --blocking
 ```
 
-### Result
+#### Result
 ```sh
 "result": {
-
+  "details": "You have 0 children and are 0 m. tall.",
+  "greeting": "Hello,  from "
 },
 ```
+As you can see, the results verify that the default values (i.e., empty strings and zeros)
for the input parameters on the '```hello_world_triggerrule```' Action were used to compose
the '```greeting```' and '```details```' output parameters. This is as expected since we did
not bind any values or provide any defaults when we defined the '```hello_world_triggerrule```'
Action in the manifest file.
+
+### Triggering
+
+Instead of invoking the Action, here try _"firing"_ the '```meetPerson```' Trigger:
+```sh
+$ wsk trigger fire meetPerson
+```
+
+#### Result
+which results in an Activation ID:
+```sh
+ok: triggered /_/meetPerson with id a8e9246777a7499b85c4790280318404
+```
+
+The '```meetPerson```' Trigger is associated with '```hello_world_triggerrule```' Action
the via the '```meetPersonRule```' Rule. We can verify that firing the Trigger indeed cause
the Rule to be activated which in turn casues the Action to be invoked:
+```sh
+$ wsk activation list
+
+d03ee729428d4f31bd7f61d8d3ecc043 hello_world_triggerrule
+3e10a54cb6914b37a8abcab53596dcc9 meetPersonRule
+5ff4804336254bfba045ceaa1eeb4182 meetPerson
+```
+
+we can then use the '```hello_world_triggerrule```' Action's Activation ID to see the result:
+```sh
+$ wsk activation get d03ee729428d4f31bd7f61d8d3ecc043
+```
+
+```yaml
+"result": {
+   "details": "You have 13 children and are 1.2 m. tall.",
+   "greeting": "Hello, Sam from the Shire"
+}
+```
+
+which verifies that the paramters bindings of the values _"Sam"_ (name), _"the Shire"_ (place),
'13' (age) and '1.2' (height) on the Trigger were passed to the Action's corresponding input
parameters correctly.
 
 ### Discussion
-TODO
+- Firing the '```meetPerson```' Trigger correctly causes non-serialized "activations" of
the associated ```meetPersonRule```' Rule and subsequently the '```hello_world_triggerrule```'
Action.
+- The Trigger's parameter bindings were correctly passed to the corresponding input parameters
on the '```hello_world_triggerrule```' Action.
 
 ### Source code
-TODO
+- [manifest_hello_world_triggerrule.yaml](examples/manifest_hello_world_triggerrule.yaml)
+- [deployment_hello_world_triggerrule.yaml](examples/deployment_hello_world_triggerrule.yaml)
+- [hello_plus.js](examples/src/hello_plus.js)
 
 ### Specification
 For convenience, the Actions and Parameters grammar can be found here:

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

Mime
View raw message