3. 2016 @ibmamnt
Project OpenWhisk
IBM Thomas J. Watson Research Centerの Cloud
Programing Technology Groupで研究開発
イベントに基づくプログラミングサービス
whisk (v) :
to move nimbly and quickly.
Source: merriam-webster.com
16. 2016 @ibmamnt
外部API を呼び出す(パラメータ付き)
var request = require('request');
function main(msg) {
var location = msg.location || 'Tokyo';
var url = 'https://query.yahooapis.com/v1/public/yql?q=select item.condition from weather.forecast
where woeid in (select woeid from geo.places(1) where text="' + location + '")&format=json';
request.get(url, function(error, response, body) {
var condition = JSON.parse(body).query.results.channel.item.condition;
var text = condition.text;
var temperature = condition.temp;
temperature = 5*(temperature - 32)/9;
var output = 'It is ' + temperature + ' degrees in ' + location + ' and ' + text;
whisk.done({msg: output});
});
return whisk.async();
}
$ wsk action create weather weather.js
ok: created action weather
$ wsk action invoke weather -b -p location 'Tokyo' --result
{
"msg": "It is 10 degrees in Tokyo and Fair"
}
$ wsk action invoke weather -b -p location 'Sapporo' --result
{
"msg": "It is -2.2222222222222223 degrees in Sapporo and Light Snow
Shower"
}
パラメータ
パラメータ