Actions

Subsections

The Action entity schema contains the necessary information to deploy an OpenWhisk function and define its deployment configurations, inputs and outputs.

Fields

Key NameRequiredValue TypeDefaultDescription
versionnoversionN/AThe optional user-controlled version for the Action.
functionyesstringN/ARequired source location (path inclusive) of the Action code either:Relative to the Package manifest file.Relative to the specified Repository.
codenostringN/AThis optional field is now replaced by the “function” field.
runtimemaybestringN/Ahe 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.
inputsnolist of parameterN/AThe optional ordered list inputs to the Action.
outputsnolist of parameterN/AThe optional outputs from the Action.
limitsnomap of limit keys and valuesN/AOptional map of limit keys and their values.See section “Valid limit keys” (below) for a listing of recognized keys and values.
feednoboolenfalseOptional indicator that the Action supports the required parameters (and operations) to be run as a Feed Action.
web | web-exportnobooleanyes | no | raw | falseThe 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-httpnobooleanfalseThe 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’.
dockernostringN/AThe optional key that references a Docker image (e.g., openwhisk/skeleton).
nativenobooleanfalseThe optional key (flag) that indicates the Action is should use the Docker skeleton image for OpenWhisk (i.e., short-form for docker: openwhisk/skeleton).
finalnobooleanfalseThe 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-optionsnobooleanfalseThe optional flag (annotation) enables a web action to respond to OPTIONS requests with customized headers, otherwise a default CORS response applies.
require-whisk-authnobooleanfalseThe optional flag (annotation) protects the web action so that it is only accessible to an authenticated subject.
mainnostringN/AThe 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”.

Requirements

  • The Action name (i.e., <actionName> MUST be less than or equal to 256 characters.
  • The Action entity schema includes all general Entity Schema fields in addition to any fields declared above.
  • Supplying a runtime name without a version indicates that OpenWhisk SHOULD use the most current version.
  • Supplying a runtime major version without a minor version (et al.) indicates OpenWhisk SHOULD use the most current minor version.
  • Unrecognized limit keys (and their values) SHALL be ignored.
  • Invalid values for known limit keys SHALL result in an error.
  • If the Feed is a Feed Action (i.e., the feed key's value is set to true), it MUST support the following parameters:
    • lifecycleEvent: one of ‘CREATE’, ‘DELETE’, ‘PAUSE’,or ‘UNPAUSE’. These operation names MAY be supplied in lowercase (i.e., ‘create’, ‘delete’, ‘pause’, etc.).
    • triggerName: the fully-qualified name of the trigger which contains events produced from this feed.
    • authKey: the Basic auth. credentials of the OpenWhisk user who owns the trigger.
  • The keyname ‘kind’ is currently supported as a synonym for the key named ‘runtime’; in the future it MAY be deprecated.
  • When a code is specified, runtime SHALL be a required field.

Notes

  • Input and output parameters are implemented as JSON Objects within the OpenWhisk framework.
  • The maximum code size for an Action currently must be less than 48 MB.
  • The maximum payload size for an Action (i.e., POST content length or size) currently must be less than 1 MB.
  • The maximum parameter size for an Action currently must be less than 1 MB.
  • if no value for runtime is supplied, the value ‘language:default’ will be assumed.

Grammar

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

Example

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

Valid Runtime names

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 valueOpenWhisk kindDocker image nameDescription
nodejs@10nodejs:10openwhisk/action-nodejs-v8:latestLatest NodeJS 10 runtime
nodejs@8nodejs:8openwhisk/action-nodejs-v8:latestLatest NodeJS 8 runtime
nodejs@12nodejs:12openwhisk/nodejs12action:latestLatest NodeJS 12 runtime
javajavaopenwhisk/java8action:latestLatest Java (8) language runtime
php, php@7.3php:7.3openwhisk/action-php-v7.3:latestLatest PHP (7.3) language runtime
php, php@7.2php:7.2openwhisk/action-php-v7.2:latestLatest PHP (7.2) language runtime
php, php@7.1php:7.1openwhisk/action-php-v7.1:latestLatest PHP (7.1) language runtime
python@3python:3openwhisk/python3action:latestLatest Python 3 language runtime
python, python@2python:2openwhisk/python2action:latestLatest Python 2 language runtime
rubyruby:2.5openwhisk/action-ruby-v2.5:latestLatest Ruby 2.5 language runtime
swift@4.2swift:4.2openwhisk/action-swift-v4.2:latestLatest Swift 4.2 language runtime
swift@4.1swift:4.1openwhisk/action-swift-v4.1:latestLatest Swift 4.1 language runtime
swift@3.1.1swift:3.1.1openwhisk/action-swift-v3.1.1:latestLatest Swift 3.1.1 language runtime
dotnet, dotnet@2.2dotnet:2.2openwhisk/action-dotnet-v2.2:latestLatest .NET Core 2.2 runtime
language:defaultN/AN/APermit the OpenWhisk platform to select the correct default language runtime.

Notes

  • If no value for runtime is supplied, the value ‘language:default’ will be assumed.

Recognized File extensions

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:

Valid Limit keys

Limit Notes

  1. The default values and ranges for limit configurations reflect the defaults for the OpenWhisk platform (open source code).  These values may be changed over time to reflect the open source community consensus.
  2. Serverless providers that use Apache OpenWhisk MAY choose to enforce different defaults and value ranges for limits.
  3. This limit is not currently user configurable.
  4. The parameter size limit also applies to Triggers and Packages.

Web Actions

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.

  • headers: a JSON object where the keys are header-names and the values are string values for those headers (default is no headers).
  • code: a valid HTTP status code (default is 200 OK).
  • body: a string which is either plain text or a base64 encoded string (for binary data).