This example builds on the previous Trigger and Rule example and will demonstrate how to use a Deployment File to bind values to a Trigger’s input parameters and apply them against a compatible Manifest File.
Let’s use a variant of the Manifest file from the previous example; however, we will leave the parameters on the ‘meetPerson
’ Trigger unbound and having only Type declarations for each.
packages: hello_world_package ... # Package keys omitted for brevity 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: string place: string children: integer height: float rules: meetPersonRule: trigger: meetPerson action: hello_world_triggerrule
Let’s create a Deployment file that is designed to be applied to the Manifest file (above) which will contain the parameter bindings (i.e., the values) for the ‘meetPerson
’ Trigger.
meetPerson
’ Triggerproject: packages: hello_world_package: triggers: meetPerson: inputs: name: Elrond place: Rivendell children: 3 height: 1.88
As you can see, the package name ‘hello_world_package
’ and the trigger name ‘meetPerson
’ both match the names in the corresponding Manifest file.
Provide the Manifest file and the Deployment file to the wskdeploy utility:
$ wskdeploy -m docs/examples/manifest_hello_world_triggerrule_unbound.yaml -d docs/examples/deployment_hello_world_triggerrule_bindings.yaml
Fire the ‘meetPerson
’ Trigger:
$ wsk trigger fire meetPerson
Find the activation ID for the “hello_world_triggerrule
’ Action that firing the Trigger initiated and get the results from the activation record:
$ wsk activation list 3a7c92468b4e4170bc92468b4eb170f1 hello_world_triggerrule afb2c02bb686484cb2c02bb686084cab meetPersonRule 9dc9324c601a4ebf89324c601a1ebf4b meetPerson $ wsk activation get 3a7c92468b4e4170bc92468b4eb170f1
"result": { "details": "You have 3 children and are 1.88 m. tall.", "greeting": "Hello, Elrond from Rivendell" }
hello_world_triggerrule
’ Action and the ‘meetPerson
’ Trigger in the Manifest file both had input parameter declarations that had no values assigned to them (only Types).meetPerson
’ Trigger in the Deployment file had values bound its parameters.wskdeploy
utility applied the parameter values (after checking for Type compatibility) from the Deployment file to the matching (by name) parameters within the Manifest file.For convenience, the Actions and Parameters grammar can be found here: