commit | d0a8f7ce4712de3477f877b39aac2f893bde0244 | [log] [tgz] |
---|---|---|
author | Priti Desai <pdesai@us.ibm.com> | Tue Feb 07 07:38:13 2017 -0800 |
committer | James Thomas <jthomas.uk@gmail.com> | Tue Feb 07 15:38:13 2017 +0000 |
tree | 3ee62c6dd9d59f9bd43ad82e209d216570c2b8a9 | |
parent | e664a7466b1a51ffdb459ebe9a7d93b70e2546f2 [diff] |
Update README.md example package.get (#27)
JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs.
$ npm install openwhisk
var openwhisk = require('openwhisk'); var options = {apihost: 'openwhisk.ng.bluemix.net', api_key: '...'}; var ow = openwhisk(options);
Client constructor supports the following options:
openwhisk.ng.bluemix.net
or my_whisk_host:80
. Used with API URL template ${protocol}://${apihost}/api/v1/
. If port is missing or port value is 443 in the apihost string, protocol is HTTPS. Otherwise, protocol is HTTP.https://openwhisk.ng.bluemix.net/api/v1/
. This value overrides apihost
if both are present.Client constructor will read values for the apihost
, namespace
and api_key
options from the environment if the following parameters are set. Explicit parameter values override these values.
All methods return a Promise resolved asynchronously with the results. Failures are available through the catch method.
ow.resource.operation().then(function () { // success! }).catch(function (err) { // failed! })
ow.actions.list() ow.activations.list() ow.triggers.list() ow.rules.list() ow.namespaces.list() ow.packages.list()
Query parameters for the API calls are supported (e.g. limit, skip, etc.) by passing an object with the named parameters as the first argument.
ow.actions.list({skip: 100, limit: 50})
The following optional parameters are supported:
namespace
- set custom namespace for endpointExample to list packages:
ow.packages.list() .then(function (packages) { return { "packages": packages }; }) .catch (function (err) { return { "err": err }; });
ow.actions.get({actionName: '...'}) ow.activations.get({activation: '...'}) ow.triggers.get({triggerName: '...'}) ow.rules.get({ruleName: '...'}) ow.namespaces.get({namespace: '...'}) ow.packages.get({packageName: '...'})
The following optional parameters are supported:
namespace
- set custom namespace for endpointExample to fetch a package by name:
ow.packages.get({packageName: "mypackage"}) .then(function (pkg) { return { "package": pkg }; }) .catch(function (err){ return { "err": err }; )};
ow.actions.delete({actionName: '...'}) ow.triggers.delete({triggerName: '...'}) ow.rules.delete({ruleName: '...'}) ow.packages.delete({packageName: '...'})
The following optional parameters are supported:
namespace
- set custom namespace for endpointow.actions.invoke({actionName: '...'})
The actionName
parameter supports the following formats: actionName
, package/actionName
, /namespace/actionName
, /namespace/package/actionName
.
If actionName
includes a namespace, this overrides any other namespace
properties.
The following optional parameters are supported:
blocking
- delay returning until action has finished executing (default: false
)params
- JSON object containing parameters for the action being invoked (default: {}
)namespace
- set custom namespace for endpointow.actions.create({actionName: '...', action: 'function main() {};'}) ow.actions.update({actionName: '...', action: 'function main() {};'})
The following mandatory parameters are supported:
actionName
- action identifieraction
- String containing JS function source code, Buffer containing package action zip file or JSON object containing full parameters for the action bodyThe following optional parameters are supported:
namespace
- set custom namespace for endpointow.triggers.invoke({triggerName: '...'})
The following optional parameters are supported:
params
- JSON object containing parameters for the trigger being fired (default: {}
)namespace
- set custom namespace for endpointow.triggers.create({triggerName: '...'}) ow.triggers.update({triggerName: '...'})
The following optional parameters are supported:
trigger
- JSON object containing parameters for the trigger body (default: {}
)namespace
- set custom namespace for endpointow.packages.create({packageName: '...'}) ow.packages.update({packageName: '...'})
The following optional parameters are supported:
package
- JSON object containing parameters for the package body (default: {}
)namespace
- set custom namespace for endpointExample of updating a package to set parameters (overwrites existing parameters):
var options = { packageName: "mypackage", package: { parameters: [ {key: "colour", value: "green"}, {key: "name", value: "Freya"} ] } } ow.packages.update(options) .then(function (pkg) { ... }
ow.rules.create({ruleName: '...', action: '...', trigger: '...'}) ow.rules.update({ruleName: '...', action: '...', trigger: '...'})
trigger
and action
identifiers will have the default namespace (/_/
) appended in the request, unless a fully qualified name is passed in (/custom_ns/action_or_trigger_name
).
The following optional parameters are supported:
namespace
- set namespace for ruleow.rules.enable({ruleName: '...'}) ow.rules.disable({ruleName: '...'})
The following optional parameters are supported:
namespace
- set custom namespace for endpointow.feeds.create({feedName: '...', trigger: '...'}) ow.feeds.delete({feedName: '...', trigger: '...'}) // for example... const params = {cron: '*/8 * * * * *', trigger_payload: {name: 'James'}} ow.feeds.create({feedName: 'alarms/alarm', namespace: 'whisk.system', trigger: 'alarmTrigger', params})
The following optional parameters are supported:
namespace
- set custom namespace for endpointparams
- JSON object containing parameters for the feed being invoked (default: {}
)API Gateway support is currently experimental and may be subject to breaking changes.
ow.routes.list()
The following optional parameters are supported to filter the result set:
relpath
- relative URI path for endpointsbasepath
- base URI path for endpointsoperation
- HTTP methodslimit
- limit result set sizeskip
- skip results from indexrelpath
is only valid when basepath
is also specified.
ow.routes.delete({basepath: '...'})
The following optional parameters are supported to filter the result set:
relpath
- relative URI path for endpointsoperation
- HTTP methodsow.routes.create({relpath: '...', operation: '...', action: '...'})
action
supports normal (actionName) and fully-qualified (/namespace/actionName) formats.
The following optional parameters are supported to filter the result set:
basepath
- base URI path for endpoints (default: /
)