Git Product home page Git Product logo

openwhisk-client-js's Introduction

openwhisk-client-js

JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs.

installation

$ npm install openwhisk

usage

var openwhisk = require('openwhisk');
var ow = openwhisk({api: 'https://openwhisk.ng.bluemix.net/api/v1/', api_key: '...', namespace: 'default_namespace'});

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! })

list resources

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 endpoint

retrieve resource

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 endpoint

delete resource

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 endpoint

invoke action

ow.actions.invoke({actionName: '...'})

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 endpoint

create & update action

ow.actions.create({actionName: '...', action: 'function main() {};'})
ow.actions.update({actionName: '...', action: 'function main() {};'})

The following mandatory parameters are supported:

  • actionName - action identifier
  • action - String containing JS function source code or JSON object containing full parameters for the action body

The following optional parameters are supported:

  • namespace - set custom namespace for endpoint

fire trigger

ow.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 endpoint

create & update trigger

ow.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 endpoint

create & update packages

ow.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 endpoint

create & update rule

ow.rules.create({ruleName: '...', action: '...', trigger: '...'})
ow.rules.update({ruleName: '...', action: '...', trigger: '...'})

The following optional parameters are supported:

  • namespace - set custom namespace for endpoint

enable & disable rule

ow.rules.enable({ruleName: '...'})
ow.rules.disable({ruleName: '...'})

The following optional parameters are supported:

  • namespace - set custom namespace for endpoint

create & delete feeds

ow.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 endpoint
  • params - JSON object containing parameters for the feed being invoked (default: {})

openwhisk-client-js's People

Contributors

jthomas avatar starpit avatar rabbah avatar mrutkows avatar

Watchers

James Cloos avatar Aleksander Slominski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.