Packages
Browsing public packages
IBM Cloud Functions comes pre-installed with a number of public packages, which include trigger feeds used to register triggers with event sources.
Actions in public packages can be used by anyone, the caller pays the invocation cost.
Using ibmcloud fn CLI you can get a list of packages in a namespace, list the entities in a package and get a description of the entities within a package.
Get a list of packages in the
/whisk.systemnamespace.ibmcloud fn package list /whisk.systempackages /whisk.system/alarms shared /whisk.system/cloudant shared /whisk.system/combinators shared /whisk.system/cos shared /whisk.system/github shared /whisk.system/messaging shared /whisk.system/pushnotifications shared /whisk.system/samples shared /whisk.system/slack shared /whisk.system/utils shared /whisk.system/watson-speechToText shared /whisk.system/watson-textToSpeech shared /whisk.system/watson-translator shared /whisk.system/weather shared /whisk.system/websocket sharedSome Packages have Actions that are also Feeds, that is they implement the Feed interface and know how to manage (connect) to external services that are event sources.
Get a list of entities in the
/whisk.system/cloudantpackage.ibmcloud fn package get --summary /whisk.system/cloudantpackage /whisk.system/cloudant: Cloudant database service (parameters: *apihost, *bluemixServiceName, *dbname, *host, overwrite, *password, *username) action /whisk.system/cloudant/read: Read document from database (parameters: dbname, id, params) action /whisk.system/cloudant/write: Write document in database (parameters: dbname, doc) ... feed /whisk.system/cloudant/changes: Database change feed (parameters: dbname, filter, query_params)This output shows that the Cloudant package provides many actions including
readandwrite, and a trigger feed calledchanges. Thechangesfeed causes triggers to be fired when documents are added to the specified Cloudant database.The Cloudant package also defines the parameters
username,password,host, anddbname. These parameters must be specified for the actions and feeds to be meaningful. The parameters allow the actions to operate on a specific Cloudant account.
Invoking actions in a package
You can invoke actions in a package, just as with other actions. The next few steps show how to invoke the greeting action in the /whisk.system/samples package with different parameters.
Invoke the greeting action without any parameters.
Invoke the action with parameters.
Notice that the output uses the
nameandplaceparameters that were passed to the action.
Creating and using package bindings
Although you can use the entities in a package directly, you might find yourself passing the same parameters to the action every time. You can avoid this by binding to a package and specifying default parameters. These parameters are inherited by the actions in the package.
Bind to the
/whisk.system/samplespackage and set a defaultpayloadparameter value.Get a description of the package binding.
Notice that all the actions in the
/whisk.system/samplespackage are available in themySamplespackage binding.Invoke an action in the package binding
Invoke an action and overwrite the default parameter value.
Sharing packages
Make the package public...
Share the package with all users:
Last updated
Was this helpful?