The Action entity schema contains the necessary information to deploy an OpenWhisk function and define its deployment configurations, inputs and outputs.
Key Name | Required | Value Type | Default | Description |
---|---|---|---|---|
version | no | version | N/A | The optional user-controlled version for the Action. |
function | yes | string | N/A | Required source location (path inclusive) of the Action code either:Relative to the Package manifest file.Relative to the specified Repository. |
code | no | string | N/A | This optional field is now replaced by the “function” field. |
runtime | maybe | string | N/A | he required runtime name (and optional version) that the Action code requires for an execution environment.Note: May be optional if tooling is allowed to make assumptions about file extensions or infer from functional code. |
inputs | no | list of parameter | N/A | The optional ordered list inputs to the Action. |
outputs | no | list of parameter | N/A | The optional outputs from the Action. |
limits | no | map of limit keys and values | N/A | Optional map of limit keys and their values.See section “Valid limit keys” (below) for a listing of recognized keys and values. |
feed | no | boolen | false | Optional indicator that the Action supports the required parameters (and operations) to be run as a Feed Action. |
web | web-export | no | boolean | yes | no | raw | false | The optional flag (annotation) that makes the action accessible to REST calls without authentication.For details on all types of Web Actions, see: Web Actions. |
raw-http | no | boolean | false | The optional flag (annotation) to indicate if a Web Action is able to consume the raw contents within the body of an HTTP request.Note: this option is ONLY valid if “web” or “web-export” is set to ‘true’. |
docker | no | string | N/A | The optional key that references a Docker image (e.g., openwhisk/skeleton). |
native | no | boolean | false | The optional key (flag) that indicates the Action is should use the Docker skeleton image for OpenWhisk (i.e., short-form for docker: openwhisk/skeleton). |
final | no | boolean | false | The optional flag (annotation) which makes all of the action parameters that are already defined immutable.Note: this option is ONLY valid if “web” or “web-export” is set to ‘true’. |
web-custom-options | no | boolean | false | The optional flag (annotation) enables a web action to respond to OPTIONS requests with customized headers, otherwise a default CORS response applies. |
require-whisk-auth | no | boolean | false | The optional flag (annotation) protects the web action so that it is only accessible to an authenticated subject. |
main | no | string | N/A | The optional name of the function to be aliased as a function named “main”.Note: by convention, Action functions are required to be called “main”; this field allows existing functions not named “main” to be aliased and accessed as if they were named “main”. |
<actionName>[.<type>]: <Entity schema> version: <version> function: <string> code: <string> runtime: <name>[@<[range of ]version>] inputs: <list of parameter> outputs: <list of parameter> limits: <list of limit key-values> feed: <boolean> # default: false web | web-export: <boolean> | yes | no | raw raw-http: <boolean> docker: <string> native: <boolean> final: <boolean> web-custom-options: <boolean> require-whisk-auth: <boolean> main: <string>
Note: the optional [.] grammar is used for naming Web Actions.
my_awesome_action: version: 1.0 description: An awesome action written for node.js function: src/js/action.js runtime: nodejs@>0.12<6.0 inputs: not_awesome_input_value: description: Some input string that is boring type: string outputs: awesome_output_value: description: Impressive output string type: string limits: memorySize: 512 kB logSize: 5 MB
The following runtime values are currently supported by the OpenWhisk platform.
Each of these runtimes also include additional built-in packages (or libraries) that have been determined be useful for Actions surveyed and tested by the OpenWhisk platform.
These packages may vary by OpenWhisk release; examples of supported runtimes as of this specification version include:
Runtime value | OpenWhisk kind | Docker image name | Description |
---|---|---|---|
nodejs | nodejs | openwhisk/nodejsaction:latest | Latest NodeJS runtime |
nodejs@6 | nodejs:6 | openwhisk/nodejs6action:latest | Latest NodeJS 6 runtime |
nodejs@8 | nodejs:8 | openwhisk/action-nodejs-v8:latest | Latest NodeJS 8 runtime |
java, java@8 | java | openwhisk/java8action:latest | Latest Java (8) language runtime |
php, php@7.1 | php:7.1 | openwhisk/action-php-v7.1:latest | Latest PHP (7.1) language runtime |
python, python@2 | python:2 | openwhisk/python2action:latest | Latest Python 2 language runtime |
python@3 | python:3 | openwhisk/python3action:latest | Latest Python 3 language runtime |
swift | swift | openwhisk/swiftaction:latest | Latest Swift language runtime |
swift@3 | swift | openwhisk/swift3action:latest | Latest Swift 3 language runtime |
swift@3.1.1 | swift | openwhisk/action-swift-v3.1.1:latest | Latest Swift 3.1.1 language runtime |
language:default | N/A | N/A | Permit the OpenWhisk platform to select the correct default language runtime. |
Although it is best practice to provide a runtime value when declaring an Action, it is not required. In those cases, that a runtime is not provided, the package tooling will attempt to derive the correct runtime based upon the the file extension for the Action's function (source code file). The following file extensions are recognized and will be run on the latest version of corresponding Runtime listed below:
OpenWhisk can turn any Action into a ‘web action’ causing it to return HTTP content without use of an API Gateway. Simply supply a supported ‘type’ extension to indicate which content type is to be returned and identified in the HTTP header (e.g., .json, .html, .text or .http).
Return values from the Action's function are used to construct the HTTP response. The following response parameters are supported in the response object.