Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs.
$ npm install openwhisk
This client library can use environment parameters to automatically configure the authentication credentials, platform endpoint and namespace. These parameters are defined within the Node.js runtime environment in OpenWhisk. Unless you want to override these values, you can construct the client instance without further configuration.
var openwhisk = require('openwhisk');
function action() {
var ow = openwhisk();
return ow.actions.invoke({actionName: 'sample'})
}
exports.main = action
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! })
Users can override default constructor parameters by passing in explicit options as shown in the example below.
Please note: Due to an issue with the Node.js runtime in OpenWhisk, environment variables used by the constructor are not available until the invocation function handler is called. If you want to define the client instance outside this function, you will need to manually pass in the constructor options .
var openwhisk = require('openwhisk');
// DOES NOT WORK! Environment parameters not set.
var ow = openwhisk();
function action() {
return ow.actions.invoke({actionName: 'sample'})
}
exports.main = action
var openwhisk = require('openwhisk');
var options = {apihost: 'openwhisk.ng.bluemix.net', api_key: '...'};
var ow = openwhisk(options);
ow.actions.invoke({actionName: 'sample'}).then(result => console.log(result))
Client constructor supports the following mandatory parameters:
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.Client constructor supports the following optional parameters:
api. Full API URL for OpenWhisk platform, e.g. https://openwhisk.ng.bluemix.net/api/v1/
. This value overrides apihost
if both are present.
namespace. Namespace for resource requests, defaults to _
.
ignore_certs. Turns off server SSL/TLS certificate verification. This allows the client to be used against local deployments of OpenWhisk with a self-signed certificate. Defaults to false.
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.
const actionName = 'reverseWords'
const blocking = true
const params = {msg: 'this is some words to reverse'}
ow.actions.invoke({actionName, blocking, params}).then(result => {
console.log('here's the reversed string', result.reversed)
}).catch(err => {
console.error(failed to invoke actions', err)
})
const triggerName = 'eventTrigger'
const params = {msg: 'event trigger message string'}
ow.triggers.invoke({triggerName, params}).then(result => {
console.log('trigger fired!')
}).catch(err => {
console.error('failed to fire trigger', err)
})
const actionName = 'reverseWords'
const action = fs.readFileSync('source.js', {encoding: 'utf8'})
ow.actions.create({actionName, action}).then(result => {
console.log('action created!')
}).catch(err => {
console.error('failed to create action', err)
})
const actionName = 'reverseWords'
const action = fs.readFileSync('package.zip')
ow.actions.create({actionName, action}).then(result => {
console.log('action created!')
}).catch(err => {
console.error('failed to create action', err)
})
const actionName = 'reverseWords'
ow.actions.retrieve({actionName}).then(action => {
console.log('action resource', action)
}).catch(err => {
console.error('failed to retrieve action', err)
})
ow.packages.list().then(packages => {
packages.forEach(package => console.log(package.name))
}).catch(err => {
console.error('failed to list packages', err)
})
const packageName = 'myPackage'
const package = {
parameters: [
{key: "colour", value: "green"},
{key: "name", value: "Freya"}
]
}
ow.packages.update({packageName, package}).then(package => {
console.log('updated package:', package.name)
}).catch(err => {
console.error('failed to update package', err)
})
// for example...
const params = {cron: '*/8 * * * * *', trigger_payload: {name: 'James'}}
const feedName = 'alarms/alarm'
const namespace = 'whisk.system'
const trigger = 'alarmTrigger'
ow.feeds.create({feedName, namespace, trigger, params}).then(package => {
console.log('alarm trigger feed created')
}).catch(err => {
console.error('failed to create alarm trigger', err)
})
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 endpointow.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 endpointow.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 endpointow.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: '...'})
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: /
)FAQs
JavaScript client library for the Apache OpenWhisk platform
The npm package openwhisk receives a total of 10,285 weekly downloads. As such, openwhisk popularity was classified as popular.
We found that openwhisk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.