This example shows the ‘Hello world’ example with typed input and output Parameters.
It shows how to:
hello_world
’ using a simple, single-line format.name
’ and ‘place
’, both of type ‘string
’ to the ‘hello_world
’ action.integer
’ parameter, ‘age
’, to the action.float
’ parameter, ‘height
’, to the action.greeting
’ and ‘details
’, both of type ‘string
’, to the action.packages: hello_world_package: ... # Package keys omitted for brevity actions: hello_world_typed_parms: function: src/hello_plus.js inputs: name: string place: string children: integer height: float 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:
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 }; }
$ wskdeploy -m docs/examples/manifest_hello_world_typed_parms.yaml
$ wsk action invoke hello_world_package/hello_world_typed_parms --blocking
The invocation should return an ‘ok’ with a response that includes this result:
"result": { "details": "You have 0 children and are 0 m. tall.", "greeting": "Hello, from " },
In this example:
string
’ type is the empty string (i.e., ""); it was assigned to the ‘name
’ and ‘place
’ input parameters.integer
’ type is zero (0); it was assigned to the ‘age
’ input parameter.float
’ type is zero (0.0f); it was assigned to the ‘height
’ input parameter.The manifest file for this example can be found here:
For convenience, the Actions and Parameters grammar can be found here: