$ wsk property set --auth APIKEY --namespace "ORGNAME_SPACENAME"
# to test
$ wsk action invoke /whisk.system/samples/echo -p message hello --blocking --result
# to view credentials
$ wsk property get
# to view all assets
$ wsk list
$ # tail the activation logs
$ wsk activation poll
$ wsk package create math
$ wsk list
$ # write a function that squares a number, see below
$ touch square.js
$ # upload the function to the cloud
$ wsk action create math/square square.js
$ # invoke or call the function
$ wsk action invoke math/square --blocking -p x 3
$ # when invoked, it will give you an activation id
$ # let's view that id to see more details
$ wsk activation get ACTIVATION_ID
$ # make a change to square.js and update
$ wsk action update math/square square.js
// square.js
function main(params){
console.log('square.js being called with params:', params);
return {payload: Math.pow(params.x, 2)};
}
$ touch random.js # use the code below
$ # upload action
$ wsk action create math/random random.js
$ # view all your assets
$ wsk list
$ # call the function, no parameters are needed
$ wsk action invoke --blocking math/random
// random.js
/* global whisk */
var request = require('request');
function main(params){
console.log('square.js being called with params:', params);
var o = {url: 'https://qrng.anu.edu.au/API/jsonI.php?length=1&type=uint16', json: true};
request(o, function(err, res, body){
whisk.done({payload: body.data});
});
return whisk.async();
}
- Make primitive math services:
- Area
- Volume
- Sum
- Average
- StdDev
- Min
- Max