Remove the catalog
Closes-Bug: #1165
diff --git a/catalog/github/webhook.js b/catalog/github/webhook.js
deleted file mode 100644
index 67d5b42..0000000
--- a/catalog/github/webhook.js
+++ /dev/null
@@ -1,95 +0,0 @@
-var request = require('request');
-
-/**
- * Feed to create a webhook on Github
- * @param {object} params - information about the trigger
- * @param {string} repository - repository to create webhook
- * @param {string} username - github username
- * @param {string} accessToken - github access token
- * @param {string} events - list of the events the webhook should fire on
- * @return {object} whisk async
- */
-function main(params) {
- var username = params.username;
- var repository = params.repository;
- var accessToken = params.accessToken;
-
- var organization,
- repository;
-
- if(params.repository) {
- var repoSegments = params.repository.split('/');
- if(repoSegments.length == 2) {
- organization = repoSegments[0];
- repository = repoSegments[1];
- } else {
- repository = params.repository;
- }
- }
-
- var endpoint = 'openwhisk.ng.bluemix.net';
- var lifecycleEvent = params.lifecycleEvent;
- var triggerName = params.triggerName.split("/");
-
- // URL of the whisk system. The calls of github will go here.
- var whiskCallbackUrl = 'https://' + whisk.getAuthKey() + "@" + endpoint + '/api/v1/namespaces/' + encodeURIComponent(triggerName[1]) + '/triggers/' + encodeURIComponent(triggerName[2]);
-
- // The URL to create the webhook on Github
- var registrationEndpoint = 'https://api.github.com/repos/' + (organization ? organization : username) + '/' + repository + '/hooks';
- console.log("Using endpoint: " + registrationEndpoint);
-
- var authorizationHeader = 'Basic ' + new Buffer(username + ':' +
- accessToken).toString('base64');
-
- if (lifecycleEvent === 'CREATE') {
- var events = params.events.split(',');
-
- var body = {
- name: 'web',
- active: true,
- events: events,
- config: {
- url: whiskCallbackUrl,
- content_type: 'json'
- }
- };
-
- var options = {
- method: 'POST',
- url: registrationEndpoint,
- body: JSON.stringify(body),
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': authorizationHeader,
- 'User-Agent': 'whisk'
- }
- };
-
- request(options, function(error, response, body) {
- if (error) {
- whisk.error({
- response: response,
- error: error,
- body: body
- });
- } else {
- console.log("Status code: " + response.statusCode);
-
- if(response.statusCode >= 400) {
- console.log("Response from Github: " + body);
- whisk.error({
- statusCode: response.statusCode,
- response: body
- });
- } else {
- whisk.done({response: body});
- }
- }
- });
-
- return whisk.async();
- }
-
- // some lifecycleEvent for which there is nothing to do here
- return whisk.done();
-}
diff --git a/catalog/installCatalog.sh b/catalog/installCatalog.sh
deleted file mode 100755
index 53ab04d..0000000
--- a/catalog/installCatalog.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install standard actions deployed
-# automatically
-#
-WHISK_SYSTEM_AUTH_FILE=$1
-: ${WHISK_SYSTEM_AUTH_FILE:?"WHISK_SYSTEM_AUTH_FILE must be set and non-empty"}
-
-export WHISK_SYSTEM_AUTH=`cat $WHISK_SYSTEM_AUTH_FILE`
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-source "$SCRIPTDIR/util.sh"
-
-echo Installing open catalog
-
-runPackageInstallScript "$SCRIPTDIR" installSystem.sh
-runPackageInstallScript "$SCRIPTDIR" installGit.sh
-runPackageInstallScript "$SCRIPTDIR" installSlack.sh
-runPackageInstallScript "$SCRIPTDIR" installWatson.sh
-runPackageInstallScript "$SCRIPTDIR" installWeather.sh
-runPackageInstallScript "$SCRIPTDIR" installWebSocket.sh
-
-waitForAll
-
-echo open catalog ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installGit.sh b/catalog/installGit.sh
deleted file mode 100755
index ce678fb..0000000
--- a/catalog/installGit.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install Git package.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing Git package.
-
-createPackage github \
- -a description "Package which contains actions and feeds to interact with Github"
-
-waitForAll
-
-install "$CATALOG_HOME/github/webhook.js" \
- github/webhook \
- -a feed true \
- -a description 'Creates a webhook on GitHub to be notified on selected changes' \
- -a parameters '[ {"name":"username", "required":true, "bindTime":true, "description": "Your GitHub username"}, {"name":"repository", "required":true, "bindTime":true, "description": "The name of a GitHub repository"}, {"name":"accessToken", "required":true, "bindTime":true, "description": "A webhook or personal token", "doclink": "https://github.com/settings/tokens/new"},{"name":"events", "required":true, "description": "A comma-separated list", "doclink": "https://developer.github.com/webhooks/#events"} ]' \
- -a sampleInput '{"username":"myUserName", "repository":"myRepository or myOrganization/myRepository", "accessToken":"123ABCXYZ", "events": "push,delete,pull-request"}'
-
-waitForAll
-
-echo Git package ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installSlack.sh b/catalog/installSlack.sh
deleted file mode 100755
index d0bde24..0000000
--- a/catalog/installSlack.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install Slack package.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing Slack package.
-
-createPackage slack \
- -a description "This package interacts with the Slack messaging service" \
- -a parameters '[ {"name":"username", "required":true, "bindTime":true, "description": "Your Slack username"}, {"name":"url", "required":true, "bindTime":true, "description": "Your webhook URL", "doclink": "https://api.slack.com/incoming-webhooks"},{"name":"channel", "required":true, "bindTime":true, "description": "The name of a Slack channel"}, {"name": "token", "description": "Your Slack oauth token", "doclink": "https://api.slack.com/docs/oauth"} ]'
-
-waitForAll
-
-install "$CATALOG_HOME/slack/post.js" \
- slack/post \
- -a description 'Post a message to Slack' \
- -a parameters '[ {"name":"text", "required":true, "description": "The message you wish to post"} ]' \
- -a sampleInput '{"username":"openwhisk", "text":"Hello OpenWhisk!", "channel":"myChannel", "url": "https://hooks.slack.com/services/XYZ/ABCDEFG/12345678"}'
-
-waitForAll
-
-echo Slack package ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installSystem.sh b/catalog/installSystem.sh
deleted file mode 100755
index 311f624..0000000
--- a/catalog/installSystem.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install standard actions deployed
-# automatically.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing whisk.system entities.
-
-createPackage system -a description "Low-level OpenWhisk utilities"
-createPackage util -a description "Building blocks that format and assemble data"
-createPackage samples -a description "A suite of simple actions to help you get started with OpenWhisk"
-
-waitForAll
-
-install "$CATALOG_HOME/utils/pipe.js" \
- system/pipe \
- -a system true
-
-install "$CATALOG_HOME/utils/cat.js" \
- util/cat \
- -a description 'Concatenates input into a string' \
- -a parameters '[ { "name": "lines", "required": true, "type": "array", "description": "An array of strings or numbers" } ]' \
- -a sampleInput '{ "lines": [4, 2, 3] }' \
- -a sampleOutput '{ "lines": [4, 2, 3] }'
-
-install "$CATALOG_HOME/utils/split.js" \
- util/split \
- -a description 'Split a string into an array' \
- -a parameters '[{"name": "payload", "required":true, "description":"A string"}, { "name": "separator", "required": false, "description": "The character, or the regular expression, to use for splitting the string" }]' \
- -a sampleInput '{ "payload": "one,two,three", "separator": "," }' \
- -a sampleOutput '{ "lines": ["one", "two", "three"], "payload": "one,two,three"}'
-
-install "$CATALOG_HOME/utils/sort.js" \
- util/sort \
- -a description 'Sorts an array' \
- -a parameters '[ { "name": "lines", "required": true, "type": "array", "description": "An array of strings" } ]' \
- -a sampleInput '{ "lines": [4, 2, 3] }' \
- -a sampleOutput '{ "lines": [2, 3, 4], "length": 3 }'
-
-install "$CATALOG_HOME/utils/head.js" \
- util/head \
- -a description 'Extract prefix of an array' \
- -a parameters '[ { "name": "lines", "required": true, "type": "array", "description": "An array of strings" }, { "name": "num", "required": false, "type": "integer", "description": "The length of the prefix" }]' \
- -a sampleInput '{ "lines": [4, 2, 3], "num": 2 }' \
- -a sampleOutput '{ "lines": [4, 2], "num": 2 }'
-
-install "$CATALOG_HOME/utils/date.js" \
- util/date \
- -a description 'Current date and time' \
- -a sampleOutput '{ "date": "2016-03-22T00:59:55.961Z" }'
-
-install "$CATALOG_HOME/samples/hello.js" \
- samples/helloWorld \
- -a description 'Demonstrates logging facilities' -a parameters '[{"name": "payload", "required":false, "description":"The string to be included in the log record"}]' \
- -a sampleInput '{ "payload": "Cat" }' \
- -a sampleOutput '{ }' \
- -a sampleLogOutput '2016-03-22T01:02:26.387624916Z stdout: hello Cat!'
-
-install "$CATALOG_HOME/samples/greeting.js" \
- samples/greeting \
- -a description 'Returns a friendly greeting' \
- -a parameters '[{"name": "name", "required":false}, {"name": "place", "required":false, "description":"The string to be included in the return value"}]' \
- -a sampleInput '{ "payload": "Cat", "place": "Narrowsburg" }' \
- -a sampleOutput '{ "payload": "Hello, Cat from Narrowsburg!" }' \
- -a sampleLogOutput "2016-03-22T01:07:08.384982272Z stdout: params: { place: 'Narrowsburg', payload: 'Cat' }"
-
-install "$CATALOG_HOME/samples/wc.js" \
- samples/wordCount \
- -a description 'Count words in a string' -a parameters '[{"name": "payload", "required":true, "description":"A string"}]' \
- -a sampleInput '{ "payload": "Five fuzzy felines"}' \
- -a sampleOutput '{ "count": 3 }' \
- -a sampleLogOutput "2016-03-22T01:10:07.361649586Z stdout: The message 'Five fuzzy felines' has 3 words"
-
-install "$CATALOG_HOME/samples/echo.js" \
- samples/echo \
- -a description 'Returns the input' -a parameters '[{"name": "payload", "required":false, "description": "Any JSON entity"}]' \
- -a sampleInput '{ "payload": "Five fuzzy felines"}' \
- -a sampleOutput '{ "payload": "Five fuzzy felines"}'
-
-waitForAll
-
-echo whisk.system entities ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installWatson.sh b/catalog/installWatson.sh
deleted file mode 100755
index 7daf690..0000000
--- a/catalog/installWatson.sh
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install Watson package.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing Watson package.
-
-createPackage watson \
- -a description "Actions for the Watson analytics APIs" \
- -a parameters '[ {"name":"username", "required":false}, {"name":"password", "required":false, "type":"password"} ]'
-
-waitForAll
-
-install "$CATALOG_HOME/watson/speechToText.js" \
- watson/speechToText \
- -a description 'Convert speech to text' \
- -a parameters '[
- {
- "name": "content_type",
- "required": true,
- "description": "The MIME type of the audio"
- },
- {
- "name": "model",
- "required": false,
- "description": "The identifier of the model to be used for the recognition request"
- },
- {
- "name": "continuous",
- "required": false,
- "description": "Indicates whether multiple final results that represent consecutive phrases separated by long pauses are returned"
- },
- {
- "name": "inactivity_timeout",
- "required": false,
- "description": "The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed"
- },
- {
- "name": "interim_results",
- "required": false,
- "description": "Indicates whether the service is to return interim results"
- },
- {
- "name": "keywords",
- "required": false,
- "description": "A list of keywords to spot in the audio"
- },
- {
- "name": "keywords_threshold",
- "required": false,
- "description": "A confidence value that is the lower bound for spotting a keyword"
- },
- {
- "name": "max_alternatives",
- "required": false,
- "description": "The maximum number of alternative transcripts to be returned"
- },
- {
- "name": "word_alternatives_threshold",
- "required": false,
- "description": "A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative"
- },
- {
- "name": "word_confidence",
- "required": false,
- "description": "Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word"
- },
- {
- "name": "timestamps",
- "required": false,
- "description": "Indicates whether time alignment is returned for each word"
- },
- {
- "name": "X-Watson-Learning-Opt-Out",
- "required": false,
- "description": "Indicates whether to opt out of data collection for the call"
- },
- {
- "name": "watson-token",
- "required": false,
- "description": "Provides an authentication token for the service as an alternative to providing service credentials"
- },
- {
- "name": "encoding",
- "required": true,
- "description": "The encoding of the speech binary data"
- },
- {
- "name": "payload",
- "required": true,
- "description": "The encoding of the speech binary data"
- },
- {
- "name": "username",
- "required": true,
- "bindTime": true,
- "description": "The Watson service username"
- },
- {
- "name": "password",
- "required": true,
- "type": "password",
- "bindTime": true,
- "description": "The Watson service password"
- }
-]' \
- -a sampleInput '{"payload":"<base64 encoding of a wav file>", "encoding":"base64", "content_type":"audio/wav", "username":"XXX", "password":"XXX"}' \
- -a sampleOutput '{"data":"Hello."}'
-
-install "$CATALOG_HOME/watson/translate.js" \
- watson/translate \
- -a description 'Translate text' \
- -a parameters '[ {"name":"translateFrom", "required":false}, {"name":"translateTo", "required":false}, {"name":"payload", "required":false}, {"name":"username", "required":true, "bindTime":true}, {"name":"password", "required":true, "type":"password", "bindTime":true} ]' \
- -a sampleInput '{"translateFrom":"en", "translateTo":"fr", "payload":"Hello", "username":"XXX", "password":"XXX"}' \
- -a sampleOutput '{"payload":"Bonjour"}'
-
-install "$CATALOG_HOME/watson/languageId.js" \
- watson/languageId \
- -a description 'Identify language' \
- -a parameters '[ {"name":"username", "required":true, "bindTime":true}, {"name":"password", "required":true, "type":"password", "bindTime":true}, {"name":"payload", "required":true} ]' \
- -a sampleInput '{"payload": "Bonjour", "username":"XXX", "password":"XXX"}' \
- -a sampleOutput '{"language": "French", "confidence": 1}'
-
-install "$CATALOG_HOME/watson/textToSpeech.js" \
- watson/textToSpeech \
- -a description 'Synthesize text to spoken audio' \
- -a parameters '[
- {"name":"username", "required":true, "bindTime":true, "description":"The Watson service username"},
- {"name":"password", "required":true, "type":"password", "bindTime":true, "description":"The Watson service password"},
- {"name":"payload", "required":true, "description":"The text to be synthesized"},
- {"name":"voice", "required":false, "description":"The voice to be used for synthesis"},
- {"name":"accept", "required":false, "description":"The requested MIME type of the audio"},
- {"name":"encoding", "required":false, "description":"The encoding of the speech binary data"}]' \
- -a sampleInput '{"payload":"Hello, world.", "encoding":"base64", "accept":"audio/wav", "voice":"en-US_MichaelVoice", "username":"XXX", "password":"XXX" }' \
- -a sampleOutput '{"payload":"<base64 encoding of a .wav file>", "encoding":"base64", "mimetype":"audio/wav"}'
-
-waitForAll
-
-echo Watson package ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installWeather.sh b/catalog/installWeather.sh
deleted file mode 100755
index 927f366..0000000
--- a/catalog/installWeather.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install Weather.com package.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing Weather package.
-
-createPackage weather \
- -p bluemixServiceName "weatherinsights" \
- -a description "Services from the Weather Company Data for IBM Bluemix" \
- -a parameters '[{"name":"username", "required":false,"bindTime":true}, {"name":"password", "required":false, "type":"password","bindTime":true}]'
-
-waitForAll
-
-install "$CATALOG_HOME/weather/forecast.js" \
- weather/forecast \
- -a description 'IBM Weather Insights 10-day forecast' \
- -a parameters '[ {"name":"latitude", "required":true}, {"name":"longitude", "required":true},{"name":"language", "required":false},{"name":"units", "required":false}, {"name":"timePeriod", "required":false}, {"name":"username", "required":true, "bindTime":true},{"name":"password", "required":true,"type":"password", "bindTime":true} ]' \
- -a sampleInput '{"latitude":"34.063", "longitude":"-84.217", "username":"XXX","password":"XXX"}' \
- -a sampleOutput '{"forecasts":[ {"dow":"Monday", "min_temp":30, "max_temp":38, "narrative":"Cloudy"} ]}'
-
-waitForAll
-
-echo Weather package ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/installWebSocket.sh b/catalog/installWebSocket.sh
deleted file mode 100755
index 5a9d27a..0000000
--- a/catalog/installWebSocket.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-#
-# use the command line interface to install websocket package.
-#
-: ${WHISK_SYSTEM_AUTH:?"WHISK_SYSTEM_AUTH must be set and non-empty"}
-AUTH_KEY=$WHISK_SYSTEM_AUTH
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-CATALOG_HOME=$SCRIPTDIR
-source "$CATALOG_HOME/util.sh"
-
-echo Installing WebSocket package.
-
-createPackage websocket \
- -a description "Utilities for communicating with WebSockets" \
- -a parameters '[ {"name":"uri", "required":true, "bindTime":true} ]'
-
-waitForAll
-
-install "$CATALOG_HOME/websocket/sendWebSocketMessageAction.js" \
- websocket/send \
- -a description 'Send a message to a WebSocket' \
- -a parameters '[
- {
- "name": "uri",
- "required": true,
- "description": "The URI of the websocket server."
- },
- {
- "name": "payload",
- "required": true,
- "description": "The data you wish to send to the websocket server."
- }
- ]' \
- -a sampleInput '{"uri":"ws://MyAwesomeService.com/sweet/websocket", "payload":"Hi there, WebSocket!"}' \
- -a sampleOutput '{"result":{"payload":"Hi there, WebSocket!"},"status":"success","success":true}'
-
-waitForAll
-
-echo WebSocket package ERRORS = $ERRORS
-exit $ERRORS
diff --git a/catalog/samples/countdown.js b/catalog/samples/countdown.js
deleted file mode 100644
index 6534d9b..0000000
--- a/catalog/samples/countdown.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * An action that invokes itself recursively, programmatically using the whisk
- * Javascript API.
- */
-function main(params) {
- var n = parseInt(params.n);
- console.log(n);
- if (n === 0) {
- console.log('Happy New Year!');
- } else if (n > 0) {
- whisk.invoke({
- name : 'countdown',
- parameters : {
- n : n - 1
- },
- next : function(error, activation) {
- if (!error) {
- whisk.done();
- } else {
- whisk.error(error);
- }
- }
- });
- return whisk.async();
- }
-}
diff --git a/catalog/samples/curl.js b/catalog/samples/curl.js
deleted file mode 100644
index 0f0b93a..0000000
--- a/catalog/samples/curl.js
+++ /dev/null
@@ -1,31 +0,0 @@
-function main(msg) {
- var hostToCurl = msg.payload;
- console.log('Curl to ' + hostToCurl);
-
- var spawn = require('child_process').exec;
- var child = spawn('curl --connect-timeout 3 ' + hostToCurl);
-
- var tmp = { stdout : "", stderr : "", code : "undefined" };
-
- child.stdout.on('data', function (data) {
- tmp.stdout = tmp.stdout + data;
- });
-
- child.stderr.on('data', function (data) {
- tmp.stderr = tmp.stderr + data;
- });
-
- child.on('close', function (code) {
- tmp.code = code;
- if (tmp.code == 0){
- console.log(tmp.stdout);
- whisk.done({ msg: tmp.stdout });
- } else {
- console.log(tmp.stderr);
- whisk.done({ msg: tmp.stderr})
- }
-
- });
-
- return whisk.async();
-}
diff --git a/catalog/samples/echo.js b/catalog/samples/echo.js
deleted file mode 100644
index 37df10b..0000000
--- a/catalog/samples/echo.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Returns params, or an empty string if no parameter values are provided
- */
-function main(params) {
- return params || {};
-}
diff --git a/catalog/samples/greeting.js b/catalog/samples/greeting.js
deleted file mode 100644
index e265f4a..0000000
--- a/catalog/samples/greeting.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Return a simple greeting message for someone.
- *
- * @param name A person's name.
- * @param place Where the person is from.
- */
-function main(params) {
- console.log('params:', params);
- var name = params.name || params.payload || 'stranger';
- var place = params.place || 'somewhere';
- return {payload: 'Hello, ' + name + ' from ' + place + '!'};
-}
diff --git a/catalog/samples/hello.js b/catalog/samples/hello.js
deleted file mode 100644
index d7d7f80..0000000
--- a/catalog/samples/hello.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Hello, world.
- */
-function main(params) {
- console.log('hello', params.payload+'!');
-}
diff --git a/catalog/samples/hello.py b/catalog/samples/hello.py
deleted file mode 100644
index bf4fd54..0000000
--- a/catalog/samples/hello.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import sys
-def main(dict):
- if 'name' in dict:
- name = dict['name']
- else:
- name = "stranger"
- greeting = "Hello " + name + "!"
- print(greeting)
- return {"greeting":greeting}
diff --git a/catalog/samples/hello.swift b/catalog/samples/hello.swift
deleted file mode 100644
index 7c903a5..0000000
--- a/catalog/samples/hello.swift
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Hello world as a Swift Whisk action.
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let name = args["name"] as? String {
- return [ "greeting" : "Hello \(name)!" ]
- } else {
- return [ "greeting" : "Hello stranger!" ]
- }
-}
diff --git a/catalog/samples/helloAsync.js b/catalog/samples/helloAsync.js
deleted file mode 100644
index 6828a03..0000000
--- a/catalog/samples/helloAsync.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * word count utility, coded as an asynchronous action for pedagogical
- * purposes
- */
-function wc(params) {
- var str = params.payload;
- var words = str.split(" ");
- var count = words.length;
- console.log("The message '"+str+"' has", count, 'words');
- whisk.done({count: count});
-}
-
-function main(params) {
- setTimeout(function() {
- wc(params);
- }, 100);
-
- return whisk.async();
-}
diff --git a/catalog/samples/helloJava/build.gradle b/catalog/samples/helloJava/build.gradle
deleted file mode 100644
index 37aae88..0000000
--- a/catalog/samples/helloJava/build.gradle
+++ /dev/null
@@ -1,9 +0,0 @@
-apply plugin: 'java'
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- compile 'com.google.code.gson:gson:2.6.2'
-}
diff --git a/catalog/samples/helloJava/build/libs/helloJava.jar b/catalog/samples/helloJava/build/libs/helloJava.jar
deleted file mode 100644
index a8f49ee..0000000
--- a/catalog/samples/helloJava/build/libs/helloJava.jar
+++ /dev/null
Binary files differ
diff --git a/catalog/samples/helloJava/src/main/java/hello/HelloJava.java b/catalog/samples/helloJava/src/main/java/hello/HelloJava.java
deleted file mode 100644
index a17d492..0000000
--- a/catalog/samples/helloJava/src/main/java/hello/HelloJava.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-2016 IBM Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hello;
-
-import com.google.gson.JsonObject;
-
-public class HelloJava {
- public static JsonObject main(JsonObject args) {
- String name;
-
- try {
- name = args.getAsJsonPrimitive("name").getAsString();
- } catch(Exception e) {
- name = "stranger";
- }
-
- JsonObject response = new JsonObject();
- response.addProperty("greeting", "Hello " + name + "!");
- return response;
- }
-}
diff --git a/catalog/samples/helloPromises.js b/catalog/samples/helloPromises.js
deleted file mode 100644
index 08c122c..0000000
--- a/catalog/samples/helloPromises.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Return a hello message as an array of strings. This demonstrates the use of returning
- * a Promise for asynchronous actions.
- *
- * @param name A person's name.
- * @param place Where the person is from.
- */
-function main(params) {
- return new Promise(function(resolve, reject) {
- whisk.invoke({
- name : '/whisk.system/samples/greeting',
- parameters : {
- name : params.name,
- place : params.place
- },
- blocking : true,
- next : function(error, activation) {
- console.log('activation:', activation);
- if (!error) {
- var payload = activation.result.payload.toString();
- var lines = payload.split(' ');
- resolve({ lines: lines });
- } else {
- console.log('error:', error);
- reject(error);
- }
- }
- });
- });
-}
diff --git a/catalog/samples/httpGet.swift b/catalog/samples/httpGet.swift
deleted file mode 100644
index d1ca609..0000000
--- a/catalog/samples/httpGet.swift
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * with links to KituraNet and GCD
- */
-
-import KituraNet
-import Dispatch
-import Foundation
-import SwiftyJSON
-
-func main(args:[String:Any]) -> [String:Any] {
-
- // Force KituraNet call to run synchronously on a global queue
- var str = "No response"
- dispatch_sync(dispatch_get_global_queue(0, 0)) {
-
- HTTP.get("https://httpbin.org/get") { response in
-
- do {
- str = try response!.readString()!
- } catch {
- print("Error \(error)")
- }
-
- }
- }
-
- // Assume string is JSON
- print("Got string \(str)")
- var result:[String:Any]?
-
- // Convert to NSData
- let data = str.data(using: NSUTF8StringEncoding, allowLossyConversion: true)!
-
- // test SwiftyJSON
- let json = JSON(data: data)
- if let jsonUrl = json["url"].string {
- print("Got json url \(jsonUrl)")
- } else {
- print("JSON DID NOT PARSE")
- }
-
- // create result object to return
- do {
- result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
- } catch {
- print("Error \(error)")
- }
-
- // return, which should be a dictionary
- print("Result is \(result!)")
- return result!
-}
diff --git a/catalog/samples/invoke.swift b/catalog/samples/invoke.swift
deleted file mode 100644
index 84657cc..0000000
--- a/catalog/samples/invoke.swift
+++ /dev/null
@@ -1,16 +0,0 @@
-import SwiftyJSON
-
-func main(args: [String:Any]) -> [String:Any] {
- let invokeResult = Whisk.invoke(actionNamed: "/whisk.system/util/date", withParameters: [:])
- let dateActivation = JSON(invokeResult)
-
- // the date we are looking for is the result inside the date activation
- if let dateString = dateActivation["response"]["result"]["date"].string {
- print("It is now \(dateString)")
- } else {
- print("Could not parse date of of the response.")
- }
-
- // return the entire invokeResult
- return invokeResult
-}
diff --git a/catalog/samples/printParams.js b/catalog/samples/printParams.js
deleted file mode 100644
index d150738..0000000
--- a/catalog/samples/printParams.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Print the parameters to the console, sorted alphabetically by key
- */
-function main(params) {
- var sep = '';
- var retn = {};
- var keys = [];
-
- for (var key in params) {
- if (params.hasOwnProperty(key)) {
- keys.push(key);
- }
- }
-
- keys.sort();
- for (var i in keys) {
- var key = keys[i];
- var value = params[key];
- console.log(sep + 'params.' + key + ':', value);
- sep = ' ';
- retn[key] = value;
- }
-
- return {params: retn};
-}
diff --git a/catalog/samples/trigger.swift b/catalog/samples/trigger.swift
deleted file mode 100644
index 2acf54e..0000000
--- a/catalog/samples/trigger.swift
+++ /dev/null
@@ -1,8 +0,0 @@
-func main(args: [String:Any]) -> [String:Any] {
- if let triggerName = args["triggerName"] as? String {
- print("Trigger Name: \(triggerName)")
- return Whisk.trigger(eventNamed: triggerName, withParameters: [:])
- } else {
- return ["error": "You must specify a triggerName parameter!"]
- }
-}
diff --git a/catalog/samples/wc.js b/catalog/samples/wc.js
deleted file mode 100644
index 842fc61..0000000
--- a/catalog/samples/wc.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * word count utility
- */
-function main(params) {
- var str = params.payload.toString();
- var words = str.split(" ");
- var count = words.length;
- console.log("The message '"+str+"' has", count, 'words');
- return { count: count };
-}
diff --git a/catalog/samples/wc.swift b/catalog/samples/wc.swift
deleted file mode 100644
index db5d7a9..0000000
--- a/catalog/samples/wc.swift
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * A word count utility
- * @param payload A string of words to count.
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let str = args["payload"] as? String {
- let words = str.components(separatedBy: " ")
- let count = words.count
- print("The message '\(str)' has \(count) words")
- return ["count": count]
- } else {
- return ["error": "You must specify a payload parameter!"]
- }
-}
diff --git a/catalog/samples/wcbin.js b/catalog/samples/wcbin.js
deleted file mode 100644
index 2f5fdc5..0000000
--- a/catalog/samples/wcbin.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Return word count as a binary number. This demonstrates the use of a blocking
- * invoke.
- */
-function main(params) {
- var str = params.payload;
- console.log("The payload is '" + str + "'");
- whisk.invoke({
- name : 'wc',
- parameters : {
- payload : str
- },
- blocking : true,
- next : function(error, activation) {
- console.log('activation:', activation);
- if (!error) {
- var wordsInDecimal = activation.result.count;
- var wordsInBinary = wordsInDecimal.toString(2) + ' (base 2)';
- whisk.done({
- binaryCount : wordsInBinary
- });
- } else {
- console.log('error:', error);
- whisk.error(error);
- }
- }
- });
- return whisk.async();
-}
diff --git a/catalog/slack/post.js b/catalog/slack/post.js
deleted file mode 100644
index 38f77c4..0000000
--- a/catalog/slack/post.js
+++ /dev/null
@@ -1,80 +0,0 @@
-var request = require('request');
-
-/**
- * Action to post to slack
- * @param {object} params - information about the trigger
- * @param {string} channel - repository to create webhook
- * @param {string} username - github username
- * @param {string} url - slack webhook url
- * @return {object} whisk async
- */
-function main(params) {
- checkParams(params);
-
- var body = {
- channel: params.channel,
- username: params.username || 'Simple Message Bot',
- text: params.text
- };
-
- if (params.icon_emoji) {
- // guard against sending icon_emoji: undefined
- body.icon_emoji = params.icon_emoji;
- }
-
- if (params.token) {
- //
- // this allows us to support /api/chat.postMessage
- // e.g. users can pass params.url = https://slack.com/api/chat.postMessage
- // and params.token = <their auth token>
- //
- body.token = params.token;
- } else {
- //
- // the webhook api expects a nested payload
- //
- // notice that we need to stringify; this is due to limitations
- // of the formData npm: it does not handle nested objects
- //
- console.log(body);
- console.log("to: " + params.url);
-
- body = {
- payload: JSON.stringify(body)
- };
- }
-
- if (params.attachments) {
- body.attachments = params.attachments;
- }
-
- request.post({
- url: params.url,
- formData: body
- }, function(err, res, body) {
- if (err) {
- console.log('error: ', err, body);
- whisk.error(err);
- } else {
- console.log('success: ', params.text, 'successfully sent');
- whisk.done();
- }
- });
-
- return whisk.async();
-}
-
-/**
-Checks if all required params are set
-*/
-function checkParams(params) {
- if (params.text === undefined) {
- whisk.error('No text provided');
- }
- if (params.url === undefined) {
- whisk.error('No Webhook URL provided');
- }
- if (params.channel === undefined) {
- whisk.error('No channel provided');
- }
-}
diff --git a/catalog/util.sh b/catalog/util.sh
deleted file mode 100755
index a821d5b..0000000
--- a/catalog/util.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-#
-# utility functions used when installing standard whisk assets during deployment
-#
-# Note use of --apihost, this is needed in case of a b/g swap since the router may not be
-# updated yet and there may be a breaking change in the API. All tests should go through edge.
-
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-OPENWHISK_HOME=${OPENWHISK_HOME:-$SCRIPTDIR/..}
-
-WHISKPROPS_FILE="$OPENWHISK_HOME/whisk.properties"
-if [ ! -f "$WHISKPROPS_FILE" ]; then
- echo "whisk properties file not found $WHISKPROPS_FILE"
- exit 1
-fi
-EDGE_HOST=`fgrep edge.host= "$WHISKPROPS_FILE" | cut -d'=' -f2`
-
-USE_PYTHON_CLI=false
-
-function createPackage() {
- PACKAGE_NAME=$1
- REST=("${@:2}")
- if [ "$USE_PYTHON_CLI" = true ]; then
- CMD_ARRAY=($PYTHON "$OPENWHISK_HOME/bin/wsk" -i --apihost "$EDGE_HOST" package update --auth "$AUTH_KEY" --shared yes "$PACKAGE_NAME" "${REST[@]}")
- else
- CMD_ARRAY=("$OPENWHISK_HOME/bin/go-cli/wsk" -i --apihost "$EDGE_HOST" package update --auth "$AUTH_KEY" --shared yes "$PACKAGE_NAME" "${REST[@]}")
- fi
- export WSK_CONFIG_FILE= # override local property file to avoid namespace clashes
- "${CMD_ARRAY[@]}" &
- PID=$!
- PIDS+=($PID)
- echo "Creating package $PACKAGE_NAME with pid $PID"
-}
-
-function install() {
- RELATIVE_PATH=$1
- ACTION_NAME=$2
- REST=("${@:3}")
- if [ "$USE_PYTHON_CLI" = true ]; then
- CMD_ARRAY=($PYTHON "$OPENWHISK_HOME/bin/wsk" -i --apihost "$EDGE_HOST" action update --auth "$AUTH_KEY" --shared yes "$ACTION_NAME" "$RELATIVE_PATH" "${REST[@]}")
- else
- CMD_ARRAY=("$OPENWHISK_HOME/bin/go-cli/wsk" -i --apihost "$EDGE_HOST" action update --auth "$AUTH_KEY" --shared yes "$ACTION_NAME" "$RELATIVE_PATH" "${REST[@]}")
- fi
- export WSK_CONFIG_FILE= # override local property file to avoid namespace clashes
- "${CMD_ARRAY[@]}" &
- PID=$!
- PIDS+=($PID)
- echo "Installing $ACTION_NAME with pid $PID"
-}
-
-function runPackageInstallScript() {
- "$1/$2" &
- PID=$!
- PIDS+=($PID)
- echo "Installing package $2 with pid $PID"
-}
-
-# PIDS is the list of ongoing processes and ERRORS the total number of processes that failed
-PIDS=()
-ERRORS=0
-
-# Waits for all processes in PIDS and clears it - updating ERRORS for each non-zero status code
-function waitForAll() {
- for pid in ${PIDS[@]}; do
- wait $pid
- STATUS=$?
- echo "$pid finished with status $STATUS"
- if [ $STATUS -ne 0 ]
- then
- let ERRORS=ERRORS+1
- fi
- done
- PIDS=()
-}
diff --git a/catalog/utils/cat.js b/catalog/utils/cat.js
deleted file mode 100644
index 4d73e56..0000000
--- a/catalog/utils/cat.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Equivalent to unix cat command.
- * Return all the lines in an array. All other fields in the input message are stripped.
- * @param lines An array of strings.
- */
-function main(msg) {
- var lines = msg.lines || [];
- var retn = {lines: lines, payload: lines.join("\n")};
- console.log('cat: returning ' + JSON.stringify(retn));
- return retn;
-}
-
-
diff --git a/catalog/utils/cat.swift b/catalog/utils/cat.swift
deleted file mode 100644
index 34738ad..0000000
--- a/catalog/utils/cat.swift
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * Equivalent to unix cat command.
- * Return all the lines in an array. All other fields in the input message are stripped.
- * @param lines An array of strings.
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let lines = args["lines"] as? [Any] {
- var payload = ""
- for line in lines {
- payload += "\(line)\n"
- }
- return ["lines": lines, "payload": payload]
- } else {
- return ["error": "You must specify a lines parameter!"]
- }
-}
diff --git a/catalog/utils/date.js b/catalog/utils/date.js
deleted file mode 100644
index cbea7b3..0000000
--- a/catalog/utils/date.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * Print and return the current date.
- */
-function main() {
- var now = new Date();
- console.log('It is now ' + now);
- return { date: now };
-}
diff --git a/catalog/utils/head.js b/catalog/utils/head.js
deleted file mode 100644
index f6d5487..0000000
--- a/catalog/utils/head.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Return the first num lines of an array.
- * @param lines An array of strings.
- * @param num Number of lines to return.
- */
-function main(msg) {
- var lines = msg.lines || [];
- var num = msg.num || 1;
- var head = lines.slice(0, num);
- console.log('head get first ' + num + ' lines of ' + lines + ': ' + head);
- return {lines: head, num: num};
-}
-
-
diff --git a/catalog/utils/head.swift b/catalog/utils/head.swift
deleted file mode 100644
index 4e06237..0000000
--- a/catalog/utils/head.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * Return the first num lines of an array.
- * @param lines An array of strings.
- * @param num Number of lines to return.
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let lines = args["lines"] as? [Any] {
- var num: Int?
- if let value = args["num"] as? Int {
- num = value
- } else if let value = args["num"] as? Double {
- num = Int(value)
- } else {
- num = 1
- }
- return ["lines": Array(lines.prefix(num!)), "num": num!]
- } else {
- return ["error": "You must specify a lines parameter!"]
- }
-}
diff --git a/catalog/utils/pipe.js b/catalog/utils/pipe.js
deleted file mode 100644
index dd3d5c3..0000000
--- a/catalog/utils/pipe.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Invokes a sequence of actions, piping the output of each to the input of the next.
- *
- * @param _actions An array of action names to invoke.
- * @param <everything else> Passed as input to the first action.
- */
-function main(msg) {
- // The actions to invoke sequentially.
- var actions = msg['_actions'];
-
- if (typeof actions === 'string') {
- try {
- actions = JSON.parse(actions);
- } catch (e) {
- return whisk.error('invalid sequence of actions');
- }
- }
-
- if (!Array.isArray(actions)) {
- return whisk.error('invalid sequence of actions');
- }
-
- console.log(actions.length, 'actions to invoke:', actions);
-
- // The input to the first action.
- var input = msg;
- delete input['_actions'];
- console.log('input to first action:', JSON.stringify(input));
- invokeActions(actions, input, function(result) {
- console.log('chain ending with result', JSON.stringify(result));
- whisk.done(result);
- });
-
- return whisk.async();
-}
-
-/**
- * Invokes a sequence of actions.
- *
- * @param actions Array of action names.
- * @param input Input to the first action.
- * @param terminate Continuation to which the result from the final successful action is passed.
- */
-function invokeActions(actions, input, terminate) {
- if (Array.isArray(actions) && actions.length > 0) {
- var params = {
- name: actions[0],
- parameters: input,
- blocking: true,
- next: function(error, activation) {
- if (!error) {
- console.log('invoke action', actions[0]);
- console.log(' id:', activation.activationId);
- console.log(' input:', input);
- console.log(' result:', activation.result);
- actions.shift();
- invokeActions(actions, activation.result, terminate);
- } else {
- console.log('stopped chain at', actions[0], 'because of an error:', error);
- whisk.error(error);
- }
- }
- };
- whisk.invoke(params);
- } else terminate(input);
-}
diff --git a/catalog/utils/sort.js b/catalog/utils/sort.js
deleted file mode 100644
index 2017bcf..0000000
--- a/catalog/utils/sort.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Sort a set of lines.
- * @param lines An array of strings to sort.
- */
-function main(msg) {
- var lines = msg.lines || [];
- //console.log('sort got ' + lines.length + ' lines');
- console.log('sort input msg: ' + JSON.stringify(msg));
- console.log('sort before: ' + lines);
- lines.sort();
- console.log('sort after: ' + lines);
- return {lines: lines, length: lines.length};
-}
-
diff --git a/catalog/utils/sort.swift b/catalog/utils/sort.swift
deleted file mode 100644
index 50169b7..0000000
--- a/catalog/utils/sort.swift
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * Sort a set of lines.
- * @param lines An array of strings to sort.
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let lines = args["lines"] as? [Any] {
- let sorted = lines.sorted { (arg1, arg2) -> Bool in
- String(arg1) < String(arg2)
- }
- return ["lines": sorted, "length": lines.count]
- } else {
- return ["error": "You must specify a lines parameter!"]
- }
-}
diff --git a/catalog/utils/split.js b/catalog/utils/split.js
deleted file mode 100644
index 43d36bc..0000000
--- a/catalog/utils/split.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Splits a string into an array of strings
- * Return lines in an array.
- * @param payload A string.
- * @param separator The character, or the regular expression, to use for splitting the string
- */
-function main(msg) {
- var separator = msg.separator || /\r?\n/;
- var payload = msg.payload.toString();
- var lines = payload.split(separator);
- var retn = {lines: lines, payload: msg.payload};
- console.log('split: returning ' + JSON.stringify(retn));
- return retn;
-}
diff --git a/catalog/utils/split.swift b/catalog/utils/split.swift
deleted file mode 100644
index eb35081..0000000
--- a/catalog/utils/split.swift
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Sample code using the experimental Swift 3 runtime
- * Splits a string into an array of strings
- * Return lines in an array.
- * @param payload A string.
- * @param separator The separator to use for splitting the string
- */
-func main(args: [String:Any]) -> [String:Any] {
- if let payload = args["payload"] as? String {
- let lines: [String]
- if let separator = args["separator"] as? String {
- lines = payload.components(separatedBy: separator)
- } else {
- lines = payload.characters.split {$0 == "\n" || $0 == "\r\n"}.map(String.init)
- }
- return ["lines": lines, "payload": payload]
- } else {
- return ["error": "You must specify a payload parameter!"]
- }
-}
diff --git a/catalog/watson/languageId.js b/catalog/watson/languageId.js
deleted file mode 100644
index 2ddb136..0000000
--- a/catalog/watson/languageId.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var watson = require('watson-developer-cloud');
-
-/**
- * Identify the language of some text.
- *
- * @param payload The text to identify.
- * @param username The watson service username.
- * @param password The watson service password.
- * @return An object with the following properties: {
- * payload: the original text,
- * language: the identified language,
- * confidence: the confidence score
- * }
- */
-function main(params) {
- var payload = params.payload;
- console.log('payload is', payload);
- var language_translation = watson.language_translation({
- username: params.username,
- password: params.password,
- version: 'v2'
- });
-
- language_translation.identify({text: payload}, function (err, response) {
- if (err) {
- console.log('error:', err);
- whisk.error(err);
- } else {
- var language = response.languages[0].language;
- var confidence = response.languages[0].confidence;
- console.log('language:', language, ', payload:', payload);
- whisk.done({language: language, payload: payload, confidence: confidence});
- }
- });
-
- return whisk.async()
-}
-
diff --git a/catalog/watson/speechToText.js b/catalog/watson/speechToText.js
deleted file mode 100644
index f97eb0e..0000000
--- a/catalog/watson/speechToText.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var watson = require('watson-developer-cloud');
-var fs = require('fs');
-var stream = require('stream');
-
-function isValidEncoding(encoding) {
- return encoding === 'ascii' ||
- encoding === 'utf8' ||
- encoding === 'utf16le' ||
- encoding === 'ucs2' ||
- encoding === 'base64' ||
- encoding === 'binary' ||
- encoding === 'hex';
-}
-
-/**
- * Transcribes speech from various languages and audio formats to text
- * See https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text/api/v1/#recognize_audio_websockets
- *
- * @param content_type The MIME type of the audio. Required.
- * @param model The identifier of the model to be used for the recognition request.
- * @param continuous Indicates whether multiple final results that represent consecutive phrases separated by long pauses are returned.
- * @param inactivity_timeout The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed. The default is 30 seconds.
- * @param interim_results Indicates whether the service is to return interim results.
- * @param keywords A list of keywords to spot in the audio.
- * @param keywords_threshold A confidence value that is the lower bound for spotting a keyword.
- * @param max_alternatives The maximum number of alternative transcripts to be returned.
- * @param word_alternatives_threshold A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative.
- * @param word_confidence Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word.
- * @param timestamps Indicates whether time alignment is returned for each word.
- * @param X-Watson-Learning-Opt-Out Indicates whether to opt out of data collection for the call.
- * @param watson-token Provides an authentication token for the service as an alternative to providing service credentials.
- * @param encoding The encoding of the speech binary data. Required.
- * @param payload The encoded data to turn into text. Required.
- * @param username The Watson service username.
- * @param password The Watson service password.
- *
- * @return {
- * "data": "Final results for the request",
- * "results": "Interim results for the request"
- * "error": "Errors for the connection"
- * }
- */
-function main(params) {
- var payload = params.payload;
- var encoding = params.encoding;
- var username = params.username;
- var password = params.password;
-
- console.log('params:', params);
-
- if (!payload) {
- return whisk.done({
- 'error': 'No payload specified.'
- });
- } else if (!isValidEncoding(encoding)) {
- return whisk.done({
- 'error': 'Not a valid encoding.'
- });
- }
-
- var response = {};
- var speechToText = watson.speech_to_text({
- username: username,
- password: password,
- version: 'v1'
- });
-
- // Create the stream.
- var recognizeStream = speechToText.createRecognizeStream({
- content_type: params.content_type,
- model: params.model,
- continuous: params.continuous,
- inactivity_timeout: params.inactivity_timeout,
- interim_results: params.interim_results,
- keywords: params.keywords,
- max_alternatives: params.max_alternatives,
- word_alternatives_threshold: params.word_alternatives_threshold,
- word_confidence: params.word_confidence,
- timestamps: params.timestamps,
- 'X-Watson-Learning-Opt-Out': params['X-Watson-Learning-Opt-Out'],
- 'watson-token': params['watson-token']
- });
-
- // Pipe in some audio.
- var b = Buffer(payload, encoding);
- var s = new stream.Readable();
- s._read = function noop() {}; // Needed to escape not implemented exception
- s.push(b);
- s.pipe(recognizeStream);
- s.push(null);
-
- // Pipe out the transcription.
- recognizeStream.pipe(fs.createWriteStream('output'));
-
- // Get strings instead of buffers from `data` events.
- recognizeStream.setEncoding('utf8');
-
- // Listen for 'data' events for only the final results.
- // Listen for 'results' events to get interim results.
- ['data', 'results', 'error', 'connection-close'].forEach(function (name) {
- recognizeStream.on(name, function (event_) {
- if (name === 'data') {
- response.data = event_;
- whisk.done(response);
- } else if (name === 'results' && params.interim_results) {
- if (!response.results)
- response.results = [];
- response.results.push(event_);
- } else if (name === 'error' || name === 'connection-close') {
- response.error = event_ && typeof(event_.toString) === 'function' ?
- event_.toString() : 'Watson API failed';
- whisk.done(response);
- }
- });
- });
-
- return whisk.async();
-}
-
diff --git a/catalog/watson/textToSpeech.js b/catalog/watson/textToSpeech.js
deleted file mode 100644
index afae382..0000000
--- a/catalog/watson/textToSpeech.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var watson = require('watson-developer-cloud');
-
-function isValidEncoding(encoding) {
- return encoding === 'ascii' ||
- encoding === 'utf8' ||
- encoding === 'utf16le' ||
- encoding === 'ucs2' ||
- encoding === 'base64' ||
- encoding === 'binary' ||
- encoding === 'hex';
-}
-
-/**
- * Synthesizes text to spoken audio.
- * See https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/text-to-speech/api/v1/
- *
- * @param voice The voice to be used for synthesis. Example: en-US_MichaelVoice
- * @param accept The requested MIME type of the audio. Example: audio/wav
- * @param payload The text to synthesized. Required.
- * @param encoding The encoding of the speech binary data. Defaults to base64.
- * @param username The Watson service username.
- * @param password The Watson service password.
- *
- * @return {
- * "payload": "<encoded speech file>",
- * "encoding": "<encoding of payload>",
- * "content_type": "<content_type of payload>"
- * }
- */
-function main(params) {
- var voice = params.voice;
- var accept = params.accept;
- var payload = params.payload;
- var encoding = isValidEncoding(params.encoding) ? params.encoding : 'base64';
- var username = params.username;
- var password = params.password;
-
- console.log('params:', params);
-
- var textToSpeech = watson.text_to_speech({
- username: username,
- password: password,
- version: 'v1'
- });
-
- textToSpeech.synthesize({
- voice: voice,
- accept: accept,
- text: payload,
- }, function (err, res) {
- if (err) {
- whisk.error(err);
- } else {
- whisk.done({
- payload: res.toString(encoding),
- encoding: encoding,
- mimetype: accept
- });
- }
- }, function (err) {
- whisk.error(err);
- });
- return whisk.async();
-}
-
diff --git a/catalog/watson/translate.js b/catalog/watson/translate.js
deleted file mode 100644
index 3333082..0000000
--- a/catalog/watson/translate.js
+++ /dev/null
@@ -1,210 +0,0 @@
-var watson = require('watson-developer-cloud');
-
-/**
- * Translate a string from one language to another.
- *
- * @param translateFrom The two digit code of the language to translate from.
- * @param translateTo The two digit code of the language to translate to.
- * @param translateParam The input parameter to translate. Defaults to 'payload'.
- * @param username The Watson service username.
- * @param password The Watson service password.
- * @return The translateParam parameter with all values translated, or error if
- * Watson service returns error
- */
-function main(params) {
- console.log('params:', params);
-
- var from = params.translateFrom || 'en';
- var to = params.translateTo || 'fr';
- var translateParam = params.translateParam || 'payload';
- var input = {};
- input[translateParam] = params[translateParam];
-
- var texts = getTextsToTranslate(input);
- doTranslateTexts(texts, from, to, params.username, params.password, function(error, translatedTexts) {
-
- if (error) {
- whisk.error(error)
- } else {
- var output = setTranslatedTexts(input, {translatedTexts: translatedTexts});
- console.log('output:', JSON.stringify(output));
- whisk.done(output);
- }
- });
- return whisk.async()
-}
-
-/**
- * Return all the string values in an object.
- *
- * This will recursively traverse the object.
- */
-function getTextsToTranslate(obj) {
- var texts = [];
- if (typeof obj === 'string') {
- texts.push(obj);
- } else if (typeof obj === 'object') {
- for (var e in obj) {
- var value = obj[e];
- if (typeof value === 'string')
- texts.push(value);
- else if (typeof value === 'object')
- texts = texts.concat(getTextsToTranslate(value));
- }
- }
- return texts;
-}
-
-/**
- * Set the string values in an object to the translated values.
- *
- * This will recursively traverse the object.
- */
-function setTranslatedTexts(obj, translations) {
- var translatedTexts = translations.translatedTexts || [];
- var i = translations.start || 0;
- if (typeof obj === 'string') {
- obj = translatedTexts[i++];
- } else if (typeof obj === 'object') {
- for (var e in obj) {
- var value = obj[e];
- if (typeof value === 'string') {
- obj[e] = translatedTexts[i++];
- } else if (typeof value === 'object') {
- var translations = {translatedTexts: translatedTexts, start: i};
- setTranslatedTexts(value, translations);
- i = translations.start;
- }
- }
- }
- translations.start = i;
- return obj;
-}
-
-/**
- * Translate an array of strings.
- */
-function doTranslateTexts(texts, from, to, username, password, next) {
- var translated = [];
- var language_translation = watson.language_translation({
- username: username,
- password: password,
- version: 'v2'
- });
- var options = { text: texts, source: from, target: to };
- language_translation.translate(options, function (err, response) {
- if (err) {
- console.log('error:', err);
- if (next) next(err, null)
- } else {
- var translation = response.translations[0].translation;
- //console.log('response:', response);
- for (var e in response.translations) {
- translated.push(removeDiacritics(response.translations[e].translation));
- }
- }
- if (next) next(null, translated);
- });
-}
-
-/**
- * Return a string with diacritics removed.
- * From http://web.archive.org/web/20120918093154/http://lehelk.com/2011/05/06/script-to-remove-diacritics
- */
-function removeDiacritics (str) {
-
- var defaultDiacriticsRemovalMap = [
- {'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
- {'base':'AA','letters':/[\uA732]/g},
- {'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
- {'base':'AO','letters':/[\uA734]/g},
- {'base':'AU','letters':/[\uA736]/g},
- {'base':'AV','letters':/[\uA738\uA73A]/g},
- {'base':'AY','letters':/[\uA73C]/g},
- {'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
- {'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
- {'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},
- {'base':'DZ','letters':/[\u01F1\u01C4]/g},
- {'base':'Dz','letters':/[\u01F2\u01C5]/g},
- {'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},
- {'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},
- {'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},
- {'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},
- {'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},
- {'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g},
- {'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},
- {'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},
- {'base':'LJ','letters':/[\u01C7]/g},
- {'base':'Lj','letters':/[\u01C8]/g},
- {'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},
- {'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},
- {'base':'NJ','letters':/[\u01CA]/g},
- {'base':'Nj','letters':/[\u01CB]/g},
- {'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},
- {'base':'OI','letters':/[\u01A2]/g},
- {'base':'OO','letters':/[\uA74E]/g},
- {'base':'OU','letters':/[\u0222]/g},
- {'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},
- {'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},
- {'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},
- {'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},
- {'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},
- {'base':'TZ','letters':/[\uA728]/g},
- {'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},
- {'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},
- {'base':'VY','letters':/[\uA760]/g},
- {'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},
- {'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},
- {'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},
- {'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},
- {'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},
- {'base':'aa','letters':/[\uA733]/g},
- {'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g},
- {'base':'ao','letters':/[\uA735]/g},
- {'base':'au','letters':/[\uA737]/g},
- {'base':'av','letters':/[\uA739\uA73B]/g},
- {'base':'ay','letters':/[\uA73D]/g},
- {'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},
- {'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},
- {'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},
- {'base':'dz','letters':/[\u01F3\u01C6]/g},
- {'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},
- {'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},
- {'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},
- {'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},
- {'base':'hv','letters':/[\u0195]/g},
- {'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},
- {'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},
- {'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},
- {'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},
- {'base':'lj','letters':/[\u01C9]/g},
- {'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},
- {'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},
- {'base':'nj','letters':/[\u01CC]/g},
- {'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},
- {'base':'oi','letters':/[\u01A3]/g},
- {'base':'ou','letters':/[\u0223]/g},
- {'base':'oo','letters':/[\uA74F]/g},
- {'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},
- {'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},
- {'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},
- {'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},
- {'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},
- {'base':'tz','letters':/[\uA729]/g},
- {'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},
- {'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},
- {'base':'vy','letters':/[\uA761]/g},
- {'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},
- {'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},
- {'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},
- {'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}
- ];
-
- for(var i=0; i<defaultDiacriticsRemovalMap.length; i++) {
- str = str.replace(defaultDiacriticsRemovalMap[i].letters, defaultDiacriticsRemovalMap[i].base);
- }
-
- return str;
-
-}
-
diff --git a/catalog/weather/forecast.js b/catalog/weather/forecast.js
deleted file mode 100755
index f37516c..0000000
--- a/catalog/weather/forecast.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var request = require('request');
-
-/**
- * Get hourly weather forecast for a lat/long from the Weather API service.
- *
- * Must specify one of zipCode or latitude/longitude.
- *
- * @param username The Weather service API account username.
- * @param username The Weather service API account password.
- * @param latitude Latitude of coordinate to get forecast.
- * @param longitude Longitude of coordinate to get forecast.
- * @param zipCode ZIP code of desired forecast.
- * @return The hourly forecast for the lat/long.
- */
-function main(params) {
- console.log('input params:', params);
- var username = params.username;
- var password = params.password;
- var lat = params.latitude || '0';
- var lon = params.longitude || '0';
- var language = params.language || 'en-US';
- var units = params.units || 'm';
- var timePeriod = params.timePeriod || '10day';
- var url = 'https://twcservice.mybluemix.net/api/weather/v1/geocode/' + lat + '/' + lon;
- var qs = {language: language, units: units};
-
- switch(timePeriod) {
- case '48hour':
- url += '/forecast/hourly/48hour.json';
- break;
- case 'current':
- url += '/observations.json';
- break;
- case 'timeseries':
- url += '/observations/timeseries.json';
- qs.hours = '23';
- break;
- case '10day':
- default:
- url += '/forecast/daily/10day.json';
- break;
- }
-
- console.log('url:', url);
- request({url:url, qs: qs, auth: {username: username, password: password}, timeout: 30000}, function (error, response, body) {
- if (!error && response.statusCode === 200) {
- var j = JSON.parse(body);
- whisk.done(j);
- } else {
- console.log('error getting forecast');
- console.log('http status code:', (response||{}).statusCode);
- console.log('error:', error);
- console.log('body:', body);
- whisk.error({
- error: error,
- response: response,
- body: body
- });
- }
- });
-
- return whisk.async();
-}
diff --git a/catalog/websocket/sendWebSocketMessageAction.js b/catalog/websocket/sendWebSocketMessageAction.js
deleted file mode 100644
index 8868bbc..0000000
--- a/catalog/websocket/sendWebSocketMessageAction.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Sends a payload message to the designated WebSocket URI
- *
- * @param uri String representation of the WebSocket uri
- * @param payload Message to send to the WebSocket
- * @return Standard OpenWhisk success/error response
- */
-function main(params) {
- if (!params.uri) {
- return whisk.error('You must specify a uri parameter.');
- }
- var uri = params.uri;
-
- console.log("URI param is " + params.uri);
-
- if (!params.payload) {
- return whisk.error('You must specify a payload parameter.');
- }
- var payload = params.payload;
-
- console.log("Payload param is " + params.payload);
-
- var WebSocket = require('ws');
-
- var connectionEstablished = false;
- var ws = new WebSocket(uri);
-
- var connectionTimeout = 30 * 1000; // 30 seconds
-
- setTimeout(function() {
- if (!connectionEstablished) {
- whisk.error('Did not establish websocket connection to ' + uri + ' in a timely manner.');
- }
- }, connectionTimeout);
-
- ws.on('open', function() {
- connectionEstablished = true;
-
- console.log("Sending payload: " + payload);
- ws.send(payload, function(error) {
- if (error) {
- console.log("Error received communicating with websocket: " + error);
- ws.close();
- whisk.error(error)
- } else {
- console.log("Send was successful.")
- ws.close();
- whisk.done({
- 'payload': payload
- });
- }
- });
- });
-
- ws.on('error', function(error) {
- console.log("Error communicating with websocket: " + error);
- ws.close();
- whisk.error(error);
- });
-
- return whisk.async();
-}
diff --git a/tests/src/packages/GreetingTests.scala b/tests/src/packages/GreetingTests.scala
deleted file mode 100644
index f381151..0000000
--- a/tests/src/packages/GreetingTests.scala
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015-2016 IBM Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package packages.samples
-
-import java.io.File
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-
-import common.TestHelpers
-import common.Wsk
-import common.WskProps
-import common.WskTestHelpers
-import spray.json._
-import spray.json.DefaultJsonProtocol._
-
-@RunWith(classOf[JUnitRunner])
-class GreetingTests extends TestHelpers
- with WskTestHelpers {
-
- implicit val wskprops = WskProps()
- val wsk = new Wsk()
- val catalogDir = new File(scala.util.Properties.userDir.toString(), "../packages")
- val greetingAction = "/whisk.system/samples/greeting"
-
- behavior of "Greeting sample"
-
- it should "contain stranger from somewhere when using a 'wrong' parameter" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val helloMessage = "Hello, stranger from somewhere!".toJson
- val run = wsk.action.invoke(greetingAction, Map("dummy" -> "dummy".toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result shouldBe Some(JsObject("payload" -> helloMessage.toJson))
- }
- }
-
- it should "contain the sent name when using the 'name' parameter, defaulting the place to somewhere" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val helloStranger = "Hello, Mork from somewhere!".toJson
- val run = wsk.action.invoke(greetingAction, Map("name" -> "Mork".toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result shouldBe Some(JsObject("payload" -> helloStranger.toJson))
- }
- }
-
- it should "contain the sent name and place when using 'name' and 'place' parameters" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val helloMessage = "Hello, Mork from Ork!".toJson
- val run = wsk.action.invoke(greetingAction, Map("name" -> "Mork".toJson, "place" -> "Ork".toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result shouldBe Some(JsObject("payload" -> helloMessage.toJson))
- }
- }
-}
diff --git a/tests/src/packages/SlackTests.scala b/tests/src/packages/SlackTests.scala
deleted file mode 100644
index ab6078b..0000000
--- a/tests/src/packages/SlackTests.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015-2016 IBM Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package packages.slack
-
-import org.junit.runner.RunWith
-import org.scalatest.BeforeAndAfterAll
-import org.scalatest.junit.JUnitRunner
-
-import common.JsHelpers
-import common.TestHelpers
-import common.Wsk
-import common.WskProps
-import common.WskTestHelpers
-import spray.json.DefaultJsonProtocol.StringJsonFormat
-import spray.json.pimpAny
-
-@RunWith(classOf[JUnitRunner])
-class SlackTests extends TestHelpers
- with WskTestHelpers
- with BeforeAndAfterAll
- with JsHelpers {
-
- implicit val wskprops = WskProps()
- val wsk = new Wsk()
- val username = "Test";
- val channel = "gittoslack";
- val text = "Hello Test!";
- val url = "https://hooks.slack.com/services/ABC/";
- val slackAction = "/whisk.system/slack/post"
-
- val expectedChannel = "channel: '" + channel + "'"
- val expectedUsername = "username: '" + username + "'";
- val expectedText = "text: '" + text + "'";
-
- "Slack Package" should "print the object being sent to slack" in {
- val run = wsk.action.invoke(slackAction, Map("username" -> username.toJson, "channel" -> channel.toJson, "text" -> text.toJson, "url" -> url.toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe true
- val logs = activation.logs.get.mkString("\n")
- logs should include(expectedChannel)
- logs should include(expectedUsername)
- logs should include(expectedText)
- logs should include(url)
- }
- }
-
-}
diff --git a/tests/src/packages/UtilsTests.scala b/tests/src/packages/UtilsTests.scala
deleted file mode 100644
index 2a7e0ac..0000000
--- a/tests/src/packages/UtilsTests.scala
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright 2015-2016 IBM Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package packages
-
-import common._
-import org.junit.runner.RunWith
-import org.scalatest.Matchers
-import org.scalatest.junit.JUnitRunner
-import spray.json._
-import spray.json.DefaultJsonProtocol.StringJsonFormat
-
-@RunWith(classOf[JUnitRunner])
-class UtilsTests extends TestHelpers with WskTestHelpers with Matchers {
-
- implicit val wskprops = WskProps()
- val usePythonCLI = false
- val wsk = new Wsk(usePythonCLI)
- val lines = JsArray(JsString("seven"), JsString("eight"), JsString("nine"))
-
- behavior of "Util Actions"
-
- /**
- * Test the Node.js "cat" action
- */
- it should "concatenate an array of strings using the node.js cat action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("cat.js")
- val actionName = "catNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""payload":"seven\neight\nnine"""")
- }
- }
-
- /**
- * Test the "cat" action using Node.js 6
- */
- it should "concatenate an array of strings using the cat action on node.js 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("cat.js")
- val actionName = "catNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""payload":"seven\neight\nnine"""")
- }
- }
-
- /**
- * Test the Swift "cat" action using Swift 3
- */
- ignore should "concatenate an array of strings using the swift cat action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("utils/cat.swift")
- val actionName = "catSwift3"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("swift:3"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""payload":"seven\neight\nnine\n"""")
- }
-
- }
-
- /**
- * Test the Node.js "split" action
- */
- it should "split a string into an array of strings using the node.js split action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("split.js")
- val actionName = "splitNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "seven,eight,nine".toJson, "separator" -> ",".toJson))) {
- _.response.result.get.toString should include(""""lines":["seven","eight","nine"]""")
- }
- }
-
- /**
- * Test the "split" action using Node.js 6
- */
- it should "split a string into an array of strings using the split action on nodejs 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("split.js")
- val actionName = "splitNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "seven,eight,nine".toJson, "separator" -> ",".toJson))) {
- _.response.result.get.toString should include(""""lines":["seven","eight","nine"]""")
- }
- }
-
- /**
- * Test the Swift "split" action using Swift 3
- */
- ignore should "split a string into an array of strings using the swift split action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("utils/split.swift")
- val actionName = "splitSwift3"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("swift:3"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "seven,eight,nine".toJson, "separator" -> ",".toJson))) {
- _.response.result.get.toString should include(""""lines":["seven","eight","nine"]""")
- }
- }
-
- /**
- * Test the Node.js "head" action
- */
- it should "extract first n elements of an array of strings using the node.js head action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("head.js")
- val actionName = "headNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines, "num" -> JsNumber(2)))) {
- _.response.result.get.toString should include(""""lines":["seven","eight"]""")
- }
- }
-
- /**
- * Test the "head" action using Node.js 6
- */
- it should "extract first n elements of an array of strings using the head action on nodejs 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("head.js")
- val actionName = "headNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines, "num" -> JsNumber(2)))) {
- _.response.result.get.toString should include(""""lines":["seven","eight"]""")
- }
- }
-
- /**
- * Test the Swift "head" action using Swift 3
- */
- ignore should "extract first n elements of an array of strings using the swift head action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("utils/head.swift")
- val actionName = "headSwift3"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("swift:3"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines, "num" -> JsNumber(2)))) {
- _.response.result.get.toString should include(""""lines":["seven","eight"]""")
- }
- }
-
- /**
- * Test the Node.js "sort" action
- */
- it should "sort an array of strings using the node.js sort action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("sort.js")
- val actionName = "sortNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""lines":["eight","nine","seven"]""")
- }
- }
-
- /**
- * Test the "sort" action using Node.js 6
- */
- it should "sort an array of strings using the sort action on nodejs 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("sort.js")
- val actionName = "sortNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""lines":["eight","nine","seven"]""")
- }
- }
-
- /**
- * Test the Swift "sort" action using Swift 3
- */
- ignore should "sort an array of strings using the swift sort action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("utils/sort.swift")
- val actionName = "sortSwift3"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("swift:3"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("lines" -> lines))) {
- _.response.result.get.toString should include(""""lines":["eight","nine","seven"]""")
- }
- }
-
- /**
- * Test the Node.js "wordCount" action
- */
- it should "count the number of words in a string using the node.js word count action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("wc.js")
- val actionName = "wcNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "one two three".toJson))) {
- _.response.result.get.toString should include(""""count":3""")
- }
- }
-
- /**
- * Test the "wordCount" action using Node.js 6
- */
- it should "count the number of words in a string using the word count action on nodejs 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getTestActionFilename("wc.js")
- val actionName = "wcNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "one two three".toJson))) {
- _.response.result.get.toString should include(""""count":3""")
- }
- }
-
- /**
- * Test the Swift "wordCount" action using Swift 3
- */
- ignore should "count the number of words in a string using the swift word count action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("samples/wc.swift")
- val actionName = "wcSwift3"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("swift:3"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("payload" -> "one two three".toJson))) {
- _.response.result.get.toString should include(""""count":3""")
- }
- }
-
- /**
- * Test the Node.js "helloPromises" action
- */
- it should "return a hello message as an array of strings using the node.js helloPromises action" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("samples/helloPromises.js")
- val actionName = "promisesNodejs"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("place" -> "Chicago".toJson))) {
- _.response.result.get.toString should include(""""lines":["Hello,","stranger","from","Chicago!"]""")
- }
- }
-
- /**
- * Test the "helloPromises" action using Node.js 6
- */
- it should "return a hello message as an array of strings using helloPromises action on nodejs 6" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val wsk = new Wsk(usePythonCLI)
-
- val file = TestUtils.getCatalogFilename("samples/helloPromises.js")
- val actionName = "promisesNodejs6"
-
- assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
- action.create(name = actionName, artifact = Some(file), kind = Some("nodejs:6"))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(actionName, Map("place" -> "Chicago".toJson))) {
- _.response.result.get.toString should include(""""lines":["Hello,","stranger","from","Chicago!"]""")
- }
- }
-
-}
diff --git a/tests/src/packages/websocket/WebSocketTests.scala b/tests/src/packages/websocket/WebSocketTests.scala
deleted file mode 100644
index 8b247fd..0000000
--- a/tests/src/packages/websocket/WebSocketTests.scala
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2015-2016 IBM Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package packages.websocket
-
-import java.net.URI
-
-import scala.concurrent.duration.DurationInt
-import scala.language.postfixOps
-
-import org.junit.runner.RunWith
-import org.scalatest.BeforeAndAfterAll
-import org.scalatest.junit.JUnitRunner
-
-import common.JsHelpers
-import common.TestHelpers
-import common.Wsk
-import common.WskProps
-import common.WskTestHelpers
-import spray.json.DefaultJsonProtocol.StringJsonFormat
-import spray.json.pimpAny
-import spray.json.JsObject
-
-@RunWith(classOf[JUnitRunner])
-class WebSocketTests
- extends TestHelpers
- with WskTestHelpers
- with BeforeAndAfterAll
- with JsHelpers {
-
- implicit val wskprops = WskProps()
- val wsk = new Wsk(usePythonCLI = false)
-
- val websocketSendAction = "/whisk.system/websocket/send"
-
- behavior of "Websocket action"
-
- /**
- * This test requires a websocket server running on Bluemix.
- * A very simple CF app has been deployed to the "IBM Whisk" org
- * and "dev" space using the lime account.
- *
- * If the test fails, the first thing to check would be ensure
- * the "TestAppForWebSocketAction" app is actually running.
- */
- var serverURI: URI = new URI("ws://owwebsocketserver.mybluemix.net:80")
-
- it should "Use the websocket action to send a payload" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val uniquePayload = s"The cow says ${System.currentTimeMillis()}".toJson
- val run = wsk.action.invoke(websocketSendAction, Map("uri" -> serverURI.toString.toJson, "payload" -> uniquePayload))
- withActivation(wsk.activation, run, 1 second, 1 second, 180 seconds) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result shouldBe Some(JsObject(
- "payload" -> uniquePayload))
- }
- }
-
- it should "Return an error due to a malformed URI" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val badURI = new URI("ws://localhost:80")
-
- val run = wsk.action.invoke(websocketSendAction, Map("uri" -> badURI.toString.toJson, "payload" -> "This is the message to send".toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe false
-
- // the exact error content comes from the ws Node module
- activation.response.result.get.fields.get("error") shouldBe defined
- }
- }
-
- it should "Require a payload parameter" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val run = wsk.action.invoke(websocketSendAction, Map("uri" -> serverURI.toString.toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe false
- activation.response.result shouldBe Some(JsObject(
- "error" -> "You must specify a payload parameter.".toJson))
- }
- }
-
- it should "Require a uri parameter" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val run = wsk.action.invoke(websocketSendAction, Map("payload" -> "This is the message to send".toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.success shouldBe false
- activation.response.result shouldBe Some(JsObject(
- "error" -> "You must specify a uri parameter.".toJson))
- }
- }
-}