### CouchDB Initialization Playbook Output Source: https://github.com/apache/openwhisk/blob/master/tools/db/README.md Example output from the `initdb.yml` playbook when initializing a CouchDB instance. It shows tasks for setup, inclusion, checking, and creating the database and its indexes. ```text PLAY [ansible] ***************************************************************** TASK [setup] ******************************************************************* Tuesday 14 June 2016 16:33:51 +0200 (0:00:00.017) 0:00:00.017 ********** ok: [ansible] TASK [include] ***************************************************************** Tuesday 14 June 2016 16:33:51 +0200 (0:00:00.262) 0:00:00.280 ********** included: /your/path/to/openwhisk/ansible/tasks/initdb.yml for ansible TASK [check if the immortal subjects db with CouchDB exists?] ****************** Tuesday 14 June 2016 16:33:51 +0200 (0:00:00.060) 0:00:00.340 ********** ok: [ansible] TASK [create immortal subjects db with CouchDB] ******************************** Tuesday 14 June 2016 16:33:51 +0200 (0:00:00.329) 0:00:00.670 ********** ok: [ansible] TASK [recreate the "full" index on the "auth" database] ************************ Tuesday 14 June 2016 16:33:52 +0200 (0:00:00.166) 0:00:00.837 ********** ok: [ansible] TASK [recreate necessary "auth" keys] ****************************************** Tuesday 14 June 2016 16:33:52 +0200 (0:00:00.162) 0:00:01.000 ********** ok: [ansible] => (item=guest) ok: [ansible] => (item=whisk.system) PLAY RECAP ********************************************************************* ansible : ok=6 changed=0 unreachable=0 failed=0 ``` -------------------------------- ### Activation List Output Example Source: https://github.com/apache/openwhisk/blob/master/docs/conductors.md An example of the output from 'wsk activation list', displaying multiple activations with their metadata. ```text Datetime Activation ID Kind Start Duration Status Entity 2019-03-16 20:03:00 8690bc9904794c9390bc9904794c930e nodejs:6 warm 2ms success guest/tripleAndIncrement:0.0.1 2019-03-16 20:02:59 7e76452bec32401db6452bec32001d68 nodejs:6 cold 32ms success guest/increment:0.0.1 2019-03-16 20:02:59 097250ad10a24e1eb250ad10a23e1e96 nodejs:6 warm 2ms success guest/tripleAndIncrement:0.0.1 2019-03-16 20:02:58 4991a50ed9ed4dc091a50ed9edddc0bb nodejs:6 cold 33ms success guest/triple:0.0.1 2019-03-16 20:02:57 aee63124f3504aefa63124f3506aef8b nodejs:6 cold 34ms success guest/tripleAndIncrement:0.0.1 2019-03-16 20:02:57 22da217c8e3a4b799a217c8e3a0b79c4 sequence warm 3.46s success guest/tripleAndIncrement:0.0.1 ``` -------------------------------- ### Configure wskadmin-next for CouchDB Source: https://github.com/apache/openwhisk/blob/master/tools/admin/README-NEXT.md Example configuration file for wskadmin-next to connect to a default CouchDB setup. This file can be passed to the utility using the -c option. ```scala include classpath("application.conf") whisk { couchdb { protocol = "http" host = "172.17.0.1" port = "5984" username = "whisk_admin" password = "some_passw0rd" provider = "CouchDB" databases { WhiskAuth = "whisk_local_subjects" WhiskEntity = "whisk_local_whisks" WhiskActivation = "whisk_local_activations" } } } ``` -------------------------------- ### Perform a full setup, deploy, and test cycle with redo Source: https://github.com/apache/openwhisk/blob/master/tools/build/README.md Convenient command for a complete initial setup, deployment, and testing of OpenWhisk. ```bash redo setup prereq couchdb initdb deploy tests ``` -------------------------------- ### Install Bash Command Completion via Stdout Source: https://github.com/apache/openwhisk/blob/master/docs/cli.md Installs bash command completion by evaluating the stdout output of the `wsk sdk install` command. This is an alternative method to sourcing the script directly. ```bash eval "`wsk sdk install bashauto --stdout`" ``` -------------------------------- ### Install OpenJDK 8 Source: https://github.com/apache/openwhisk/blob/master/tools/ubuntu-setup/README.md Installs all required software for OpenWhisk using Open JDK 8. This script should be run from the tools/ubuntu-setup directory. ```bash (cd tools/ubuntu-setup && ./all.sh) ``` -------------------------------- ### Install Git and Clone OpenWhisk Source: https://github.com/apache/openwhisk/blob/master/tools/ubuntu-setup/README.md Installs git if not present, clones the OpenWhisk repository, and changes the directory to the cloned repository. This is a prerequisite for setting up OpenWhisk. ```bash sudo apt-get install git -y git clone https://github.com/apache/openwhisk.git openwhisk cd openwhisk ``` -------------------------------- ### Install Homebrew and Dependencies Source: https://github.com/apache/openwhisk/blob/master/tools/macos/README.md Installs Homebrew, Cask, Java 11, Scala, GNU tar, pip, and essential Python packages for OpenWhisk setup. Ensure Docker and Ansible versions are compatible. ```bash echo ' # install homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install cask brew tap homebrew/cask # install for AdoptOpenJDK (java11) brew tap AdoptOpenJDK/openjdk # install java 11 brew install --cask adoptopenjdk11 # install scala brew install scala # install gnu tar brew install gnu-tar # install pip sudo easy_install pip # install script prerequisites pip install docker==5.0.0 ansible==4.1.0 jinja2==3.0.1 couchdb==1.2 httplib2==0.19.1 requests==2.25.1 six==1.16.0 ' ``` -------------------------------- ### Example Invocation Output Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md This is an example output from invoking the 'hello' action, showing environment variables and the function's payload. It indicates that KubernetesContainerFactory based invocation is working. ```json { "HOME": "/root", "HOSTNAME": "wsk0-2-prewarm-nodejs10", "KUBERNETES_PORT": "tcp://10.96.0.1:443", "KUBERNETES_PORT_443_TCP": "tcp://10.96.0.1:443", "KUBERNETES_PORT_443_TCP_ADDR": "10.96.0.1", "KUBERNETES_PORT_443_TCP_PORT": "443", "KUBERNETES_PORT_443_TCP_PROTO": "tcp", "KUBERNETES_SERVICE_HOST": "10.96.0.1", "KUBERNETES_SERVICE_PORT": "443", "KUBERNETES_SERVICE_PORT_HTTPS": "443", "NODE_VERSION": "10.15.3", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "PWD": "/nodejsAction", "YARN_VERSION": "1.13.0", "__OW_ACTION_NAME": "/guest/hello", "__OW_ACTION_VERSION": "0.0.1", "__OW_ACTIVATION_ID": "71e48d2d62e142eca48d2d62e192ec2d", "__OW_API_HOST": "http://host.docker.internal:3233", "__OW_DEADLINE": "1570223213407", "__OW_NAMESPACE": "guest", "__OW_TRANSACTION_ID": "iSOoNklk6V7l7eh8KJnvugidKEmaNJmv", "payload": "hello, world" } ``` -------------------------------- ### Clone and Run Standalone OpenWhisk Source: https://github.com/apache/openwhisk/blob/master/README.md Clone the OpenWhisk repository and start the standalone stack. Ensure Docker, Java, and Node.js are installed. ```bash git clone https://github.com/apache/openwhisk.git cd openwhisk ./gradlew core:standalone:bootRun ``` -------------------------------- ### Running the ColdBlockingInvokeSimulation Source: https://github.com/apache/openwhisk/blob/master/tests/performance/README.md Example command to execute the ColdBlockingInvokeSimulation using Gradle. Set the necessary environment variables before running. ```bash OPENWHISK_HOST="openwhisk.mydomain.com" USERS="10" REQUESTS_PER_SEC="50" ./gradlew gatlingRun-org.apache.openwhisk.ColdBlockingInvokeSimulation ``` -------------------------------- ### Install Oracle JDK 8 Source: https://github.com/apache/openwhisk/blob/master/tools/ubuntu-setup/README.md Installs all required software for OpenWhisk using Oracle JDK 8. This script should be run from the tools/ubuntu-setup directory. ```bash (cd tools/ubuntu-setup && ./all.sh oracle) ``` -------------------------------- ### Install Homebrew and OpenWhisk Dependencies on Mac Source: https://github.com/apache/openwhisk/blob/master/tools/macos/docker-machine/README.md This script installs Homebrew, Cask, VirtualBox, Docker, Docker-machine, Java, Scala, GNU tar, pip, and necessary Python packages for OpenWhisk setup. It's recommended to copy and paste the entire block into your terminal. ```bash echo ' # install homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install cask brew tap homebrew/cask # install virtualbox brew install --cask virtualbox # install docker 1.12.0 brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/33301827c3d770bfd49f0e50d84e0b125b06b0b7/Formula/docker.rb # install docker-machine brew install docker-machine # install java 8 brew install --cask java # install scala brew install scala # install gnu tar brew install gnu-tar # install pip sudo easy_install pip # install script prerequisites sudo -H pip install docker==2.2.1 ansible==2.5.2 jinja2==2.9.6 couchdb==1.1 httplib2==0.9.2 requests==2.10.0' | bash ``` -------------------------------- ### Full Activation Record Example Source: https://github.com/apache/openwhisk/blob/master/docs/actions.md An example of a complete activation record, including activation ID, duration, and response details. ```json { "activationId": "5a64676ec8aa46b5a4676ec8aaf6b5d2", "duration": 3, "response": { "result": { "msg": "Hello, stranger from somewhere!" }, "status": "success", "success": true }, ... } ``` -------------------------------- ### Node.js 20 Runtime without Reactive Configuration Source: https://github.com/apache/openwhisk/blob/master/docs/actions.md This configuration defines a static setup for the 'nodejs:20' runtime. It specifies initial container counts and memory allocation, ensuring a fixed number of prewarmed containers are available when an invoker starts. ```json { "kind": "nodejs:20", "default": true, "image": { "prefix": "openwhisk", "name": "action-nodejs-v20", "tag": "nightly" }, "deprecated": false, "attached": { "attachmentName": "codefile", "attachmentType": "text/plain" }, "stemCells": [ { "initialCount": 2, "memory": "256 MB" } ] } ``` -------------------------------- ### Example Gradle Build Scan URL Source: https://github.com/apache/openwhisk/blob/master/tools/build/README.md An example of a URL found in Travis CI build logs that links to a Gradle Build Scan report. ```text https://gradle.com/s/reldo4qqlg3ka ``` -------------------------------- ### Install NPM Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Installs the Node.js module dependencies listed in package.json. This command should be run in the action's root directory. ```bash npm install ``` -------------------------------- ### OpenWhisk Metrics Configuration Example Source: https://github.com/apache/openwhisk/blob/master/docs/metrics.md Example Ansible configuration for enabling and configuring OpenWhisk metrics, including Kamon StatsD host and port, and logging. ```yaml metrics_kamon: true metrics_kamon_tags: false metrics_kamon_statsd_host: '192.168.99.100' metrics_kamon_statsd_port: '8125' metrics_log: true ``` -------------------------------- ### Install Prerequisites Playbook Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Executes the Ansible playbook to install necessary prerequisites on all target hosts in the environment. This step is not required for local environments. ```shell ansible-playbook -i environments/$ENVIRONMENT prereq.yml ``` -------------------------------- ### Get Greeting Action Summary Source: https://github.com/apache/openwhisk/blob/master/docs/packages.md Retrieve the summary for the 'greeting' action in the '/whisk.system/samples' package. This shows the action's description and its expected parameters. ```bash $ wsk action get --summary /whisk.system/samples/greeting ``` ```text action /whisk.system/samples/greeting: Returns a friendly greeting (parameters: name, place) ``` -------------------------------- ### Get package summary with action Source: https://github.com/apache/openwhisk/blob/master/docs/packages.md After creating an action, retrieve the package summary again to see the newly added action listed. ```bash $ wsk package get --summary custom package /myNamespace/custom (parameters: none defined) action /myNamespace/custom/identity (parameters: none defined) ``` -------------------------------- ### Ruby Multi-File Action Example Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Define a Ruby action script that utilizes relative imports to include other Ruby files. This example demonstrates how to structure multi-file actions for the OpenWhisk runtime. ```ruby require "./hello" def main(args) hello(args) end ``` -------------------------------- ### User Activation Event Example Source: https://github.com/apache/openwhisk/blob/master/docs/metrics.md An example JSON payload for an 'Activation' user event. It includes execution metadata like status code, duration, and memory. ```json { "body": { "statusCode": 0, "duration": 3, "name": "whisk.system/invokerHealthTestAction0", "waitTime": 583915671, "conductor": false, "kind": "nodejs:6", "initTime": 0, "memory": 256, "size": 463, "causedBy": false }, "eventType": "Activation", "source": "invoker0", "subject": "whisk.system", "timestamp": 1524476122676, "userId": "d0888ad5-5a92-435e-888a-d55a92935e54", "namespace": "whisk.system" } ``` -------------------------------- ### CouchDB Environment Variables and Setup Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Sets environment variables for CouchDB connection details and then executes the Ansible setup playbook. This is used for configuring the database for the deployment. ```shell export OW_DB=CouchDB export OW_DB_USERNAME= export OW_DB_PASSWORD= export OW_DB_PROTOCOL= export OW_DB_HOST= export OW_DB_PORT= ansible-playbook -i environments/$ENVIRONMENT setup.yml ``` -------------------------------- ### Example Feed Action Invocation Source: https://github.com/apache/openwhisk/blob/master/docs/feeds.md This example demonstrates how the OpenWhisk system invokes a feed action when a trigger is created via the CLI with the --feed parameter. It shows the parameters passed to the feed action, including lifecycleEvent, triggerName, authKey, and service-specific parameters. ```bash wsk action invoke mycloudant/changes -p lifecycleEvent CREATE -p triggerName T -p authKey -p password -p username -p dbName mytype ``` -------------------------------- ### Example Cargo.toml for Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-rust.md A sample Cargo.toml file specifying dependencies like serde_json, serde, and serde_derive for a Rust action. ```toml [package] name = "actions" version = "0.1.0" authors = ["John Doe "] edition = "2018" [dependencies] serde_json = "1.0" serde = "1.0" serde_derive = "1.0" ``` -------------------------------- ### Interact with Book Club API (GET) Source: https://github.com/apache/openwhisk/blob/master/docs/apigateway.md This example shows how to retrieve a list of books from the book club using an HTTP GET request to the exposed API endpoint. ```APIDOC ## Interact with Book Club API (GET) ### Description This command demonstrates how to retrieve a list of all books in the book club by sending an HTTP GET request to the API Gateway. ### Method `curl -X GET` ### Endpoint `https://${APIHOST}:9001/api/${GENERATED_API_ID}/club/books` ### Response #### Success Response (200) - **result** (array) - An array of book objects, where each object contains 'name' and 'isbn'. ### Response Example ```json { "result": [{"name":"JavaScript: The Good Parts", "isbn":"978-0596517748"}] } ``` ``` -------------------------------- ### Database Operation Metrics Examples Source: https://github.com/apache/openwhisk/blob/master/docs/metrics.md Examples of database operation metrics, including start counts, error counts, and finish/error times. These follow a pattern based on the operation type. ```text openwhisk.counter.database_getDocument_start openwhisk.counter.database_getDocument_error openwhisk.histogram.database_getDocument_finish openwhisk.histogram.database_getDocument_error ``` -------------------------------- ### Shell Script to Build C Binary Source: https://github.com/apache/openwhisk/blob/master/docs/actions-docker.md A shell script to install GCC and build a C executable from source. ```bash #!/bin/bash apk add gcc libc-dev gcc main.c -o exec ``` -------------------------------- ### Initialize OpenWhisk environment with redo Source: https://github.com/apache/openwhisk/blob/master/tools/build/README.md Set up the development environment, including Docker machine, CouchDB, and Elasticsearch. ```bash redo setup prereq ``` ```bash redo couchdb initdb ``` ```bash redo elasticsearch ``` ```bash redo mongodb ``` -------------------------------- ### Example Action Invocation Result Source: https://github.com/apache/openwhisk/blob/master/docs/actions-docker.md The expected output when invoking the 'tfjs' action, showing the versions of the TensorFlow.js libraries installed in the custom runtime. ```json { "tf": { "tfjs": "1.0.4", "tfjs-converter": "1.0.4", "tfjs-core": "1.0.4", "tfjs-data": "1.0.4", "tfjs-layers": "1.0.4", "tfjs-node": "1.0.3" } } ``` -------------------------------- ### Invoke Action Using Test Script Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Use the 'tools/invoke.py' script to initialize and run the 'hello' action with different inputs. Ensure you are in the top-level project directory. ```bash $ cd $ python tools/invoke.py init hello example/hello.rb {"ok":true} $ python tools/invoke.py run '{}' {"greeting":"Hello stranger!"} $ python tools/invoke.py run '{"name":"Mike"}' {"greeting":"Hello Mike!"} ``` -------------------------------- ### Using dep for Vendor Folders Source: https://github.com/apache/openwhisk/blob/master/docs/actions-go.md Demonstrates the process of initializing and ensuring dependencies using the 'dep' tool for Go projects with vendor folders. This is necessary when using third-party libraries. ```bash DEPPROJECTROOT=$(realpath $PWD/../..) dep init ``` ```bash dep ensure ``` -------------------------------- ### Go Action for Sequence Actions (Array Input/Output) Source: https://github.com/apache/openwhisk/blob/master/docs/actions-go.md This example shows a Go action designed for sequence actions, accepting an array as input and returning an array. The signature is `func Main(obj []interface{}) []interface{}`. ```go package main // Main is the function implementing the action func Main(obj []interface{}) []interface{} { return obj } ``` -------------------------------- ### Precompiling Multiple Go Sources with Docker Source: https://github.com/apache/openwhisk/blob/master/docs/actions-go.md This snippet illustrates how to precompile multiple Go source files, including those in subdirectories, using Docker. It first zips the source directory and then passes the zip file to the Docker container for compilation. ```bash cd src zip -r ../src.zip * cd .. docker -i run openwhisk/action-golang-v1.15 -compile main exec.zip ``` -------------------------------- ### Install Parcel Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Install the Parcel bundler as a development dependency using NPM. ```bash npm install parcel-bundler --save-dev ``` -------------------------------- ### Build and deploy OpenWhisk with redo Source: https://github.com/apache/openwhisk/blob/master/tools/build/README.md Compile and deploy the entire OpenWhisk system. ```bash redo deploy ``` -------------------------------- ### Run OpenWhisk Standalone Server Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md Execute the standalone server JAR to start OpenWhisk on the default port. This will also launch a Playground UI. ```bash java -jar openwhisk-standalone.jar ``` -------------------------------- ### Install Webpack Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Install the Webpack CLI as a development dependency using NPM. ```bash npm install webpack-cli --save-dev ``` -------------------------------- ### Install Rollup.js Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Install Rollup.js and its required plugins as development dependencies using NPM. ```bash npm install rollup rollup-plugin-commonjs rollup-plugin-node-resolve --save-dev ``` -------------------------------- ### Run Action via Single Entrypoint (Activation Example) Source: https://github.com/apache/openwhisk/blob/master/docs/single_entrypoint_proxy_contract.md To run an action, send a JSON object with an 'activation' key to the '/' endpoint. The 'activation' key signals the intent to run the function, though some fields may not be used outside the control plane. ```json { "activation": { "namespace": "", "action_name": "hello", "api_host": "", "api_key": "", "activation_id": "", "transaction_id": "", "deadline": 1000000 }, "value": { "name": "Alan Turing", "place": "England" } } ``` -------------------------------- ### Install Ansible Dependencies Source: https://github.com/apache/openwhisk/blob/master/tools/macos/docker-machine/README.md Installs required Python packages, including Ansible and Jinja2, for deploying OpenWhisk. ```bash brew install python pip install ansible==2.5.0 pip install jinja2==2.9.6 ``` -------------------------------- ### Install Ansible and Jinja2 on Ubuntu Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Installs the required Ansible and Jinja2 versions for OpenWhisk deployment on Ubuntu systems. ```shell sudo apt-get install python-pip sudo pip install ansible==4.1.0 sudo pip install jinja2==3.0.1 ``` -------------------------------- ### Ansible Playbooks for Setup Source: https://github.com/apache/openwhisk/blob/master/tools/macos/README.md Executes a series of Ansible playbooks to set up the OpenWhisk environment, including database configuration, initialization, wiping existing data, and downloading the CLI. These are prerequisites for running unit tests. ```bash cd ./ansible ansible-playbook setup.yml -e mode=HA ansible-playbook couchdb.yml ansible-playbook initdb.yml ansible-playbook wipe.yml ansible-playbook downloadcli-github.yml ansible-playbook properties.yml ``` -------------------------------- ### Create New .NET Core Class Library Project Source: https://github.com/apache/openwhisk/blob/master/docs/actions-dotnet.md Use the dotnet CLI to create a new C# class library project for your action. ```bash dotnet new classlib -n Apache.OpenWhisk.Example.Dotnet -lang "C#" cd Apache.OpenWhisk.Example.Dotnet ``` -------------------------------- ### Get Namespace Limits Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves the limits set for a namespace, such as invocationsPerMinute, concurrentInvocations, etc., using a GET request. ```bash curl -u $AUTH https://$APIHOST/api/v1/namespaces/_/limits ``` -------------------------------- ### Install Ansible and Jinja2 on Docker for Mac Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Installs the required Ansible and Jinja2 versions for OpenWhisk deployment on Docker for Mac. ```shell sudo easy_install pip sudo pip install ansible==4.1.0 pip install jinja2==3.0.1 ``` -------------------------------- ### Deploying Precompiled Go Action Source: https://github.com/apache/openwhisk/blob/master/docs/actions-go.md This command shows how to create an OpenWhisk action from a precompiled zip archive. The archive contains the executable binary. ```bash wsk action create my-action exec.zip --kind go:1.15 ``` -------------------------------- ### Get Recent Activations Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves a list of the last 3 activations by passing the query parameter 'limit=3' in a GET request. ```bash curl -u $AUTH https://$APIHOST/api/v1/namespaces/_/activations?limit=3 ``` -------------------------------- ### Prepare Environment for Compilation Test Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Prepare the environment by creating necessary directories and copying action files to simulate the state before compilation. This is a prerequisite for testing the compiler directly. ```bash $ cd /proxy $ mkdir -p action/2/src action/2/bin $ cp action/1/bin/main__.rb action/2/src/exec $ find action/2 action/2 action/2/bin action/2/src action/2/src/exec ``` -------------------------------- ### Display Help Message for Standalone Server Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md Use the -h or --help flag to display all available command-line options for the OpenWhisk standalone server. ```bash java -jar openwhisk-standalone.jar -h ``` -------------------------------- ### NodeJS Hello World Action with Parameters Source: https://github.com/apache/openwhisk/blob/master/docs/single_entrypoint_proxy_contract.md A NodeJS action that constructs a greeting using input parameters. Demonstrates parameter access within the action. ```javascript function main(params) { return { payload: 'Hello ' + params.name + ' from ' + params.place + '!' }; } ``` -------------------------------- ### Run System Basic Tests with Properties Source: https://github.com/apache/openwhisk/blob/master/tests/README.md Execute system basic tests against a running OpenWhisk setup. Server details and authentication can be provided via system properties or environment variables. ```bash ./gradlew :tests:testSystemBasic -Dwhisk.auth="23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP" -Dwhisk.server=https://localhost -Dopenwhisk.home=`pwd` ``` -------------------------------- ### User Metric Event Example Source: https://github.com/apache/openwhisk/blob/master/docs/metrics.md An example JSON payload for a 'Metric' user event. It includes the metric name and its value, such as 'ConcurrentInvocations'. ```json { "body": { "metricName": "ConcurrentInvocations", "metricValue": 1 }, "eventType": "Metric", "source": "controller0", "subject": "guest", "timestamp": 1524476104419, "userId": "23bc46b1-71f6-4ed5-8c54-816aa4f8c502", "namespace": "guest" } ``` -------------------------------- ### Example Cache Invalidation Event Source: https://github.com/apache/openwhisk/blob/master/core/cosmosdb/cache-invalidator/README.md An example of a cache invalidation event generated by the service when a package is created using the guest account. ```json {"instanceId":"cache-invalidator","key":{"mainId":"guest/test-package"}} ``` -------------------------------- ### Package Ruby Action and Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-ruby.md Command to create a zip archive containing the main Ruby file ('main.rb') and a helper file ('helper.rb'). The entry point file must be named 'main.rb'. ```bash zip -r hello_ruby.zip main.rb helper.rb ``` -------------------------------- ### Launch Standalone with Custom Runtimes Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md Launch the standalone server with a custom runtime manifest file specified via the -m argument. ```bash java -jar openwhisk-standalone.jar -m custom-runtime.json ``` -------------------------------- ### Run Parcel Build Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Execute the Parcel build process by providing the entry point file. ```bash npx parcel index.js ``` -------------------------------- ### Implement Hello World .NET Core Action Source: https://github.com/apache/openwhisk/blob/master/docs/actions-dotnet.md This C# code defines a simple action that greets a user by name, returning a JSON object. ```csharp using System; using Newtonsoft.Json.Linq; namespace Apache.OpenWhisk.Example.Dotnet { public class Hello { public JObject Main(JObject args) { string name = "stranger"; if (args.ContainsKey("name")) { name = args["name"].ToString(); } JObject message = new JObject(); message.Add("greeting", new JValue($"Hello, {name}!")); return (message); } } } ``` -------------------------------- ### Deploy OpenWhisk with a Lean Setup Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md This command deploys OpenWhisk with a lean configuration, excluding Kafka, Zookeeper, and separate Invoker entities. It replaces the standard deployment command at the specified step. ```shell ansible-playbook -i environments/$ENVIRONMENT openwhisk.yml -e lean=true ``` -------------------------------- ### Verify Docker Version Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Checks the installed Docker version. Ensure Docker is installed and meets the multi-stage build requirement (version 17.05 or higher). ```bash # Verify docker version $ docker --version Docker version 18.09.3 ``` -------------------------------- ### Show redo usage information Source: https://github.com/apache/openwhisk/blob/master/tools/build/README.md Display help and usage instructions for the 'redo' script. ```bash redo -h ``` -------------------------------- ### Get Activation Details Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves all details of a specific activation, including results and logs, by passing the activation identifier as a path parameter in a GET request. ```bash curl -u $AUTH https://$APIHOST/api/v1/namespaces/_/activations/f81dfddd7156401a8a6497f2724fec7b ``` -------------------------------- ### Display owperf Help and Defaults Source: https://github.com/apache/openwhisk/blob/master/tools/owperf/README.md Use this command to view all available command-line options and their default values for the owperf tool. ```bash ./owperf.sh -h ``` -------------------------------- ### Clone ActionLoop Starter Kit Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Clones the openwhisk-devtools repository to obtain the ActionLoop starter kit and moves it to the home directory for development. ```bash $ git clone https://github.com/apache/openwhisk-devtools $ mv openwhisk-devtools/actionloop-starter-kit ~/actionloop-demo-ruby-v2.6 ``` -------------------------------- ### Zipping and Creating Action from Package Folder Source: https://github.com/apache/openwhisk/blob/master/docs/actions-go.md This snippet shows how to package a Go action located within a sub-package and create it in OpenWhisk. Ensure you zip the contents of the 'src' directory. ```bash cd src zip -r ../hello.zip * cd .. wsk action create hellozip hello.zip --kind go:1.15 ``` -------------------------------- ### Start ActionLoop Proxy in Debug Mode Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md After navigating to the correct directory, start the proxy in debug mode to observe its behavior. It will listen on port 8080. ```bash cd /ruby2.6 $ make debug # results omitted for brevity ... # (you should see a shell prompt of your image) $ /bin/proxy -debug 2019/04/08 07:47:36 OpenWhisk ActionLoop Proxy 2: starting ``` -------------------------------- ### Custom Configuration File Example Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md To override default settings, provide a custom application.conf file using the -c option. This file must include the default standalone.conf. ```hocon include classpath("standalone.conf") whisk { //Custom config } ``` ```bash java -jar openwhisk-standalone.jar -c custom.conf ``` -------------------------------- ### Create Swift Action Command Source: https://github.com/apache/openwhisk/blob/master/docs/actions-swift.md Command-line instruction to create an OpenWhisk action named 'helloSwift' from a 'hello.swift' file. ```bash wsk action create helloSwift hello.swift ``` -------------------------------- ### Install Bash Command Completion for OpenWhisk CLI Source: https://github.com/apache/openwhisk/blob/master/docs/cli.md Installs bash command completion script for the OpenWhisk CLI. This script enables tab completion for `wsk` commands. ```bash wsk sdk install bashauto ``` -------------------------------- ### Build Docker Image and Enter Debug Shell Source: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md Navigate to the runtime's subdirectory and use 'make debug' to rebuild the image and enter an interactive shell for testing. ```bash cd ruby2.6 $ make debug # results omitted for brevity ... ``` -------------------------------- ### Install Python Dependencies in Virtual Environment Source: https://github.com/apache/openwhisk/blob/master/docs/actions-python.md Command to install Python dependencies from 'requirements.txt' into a virtual environment using the 'openwhisk/python3action' Docker image. This ensures compatibility with the OpenWhisk runtime. ```bash docker run --rm -v "$PWD:/tmp" openwhisk/python3action bash \ -c "cd tmp && virtualenv virtualenv && source virtualenv/bin/activate && pip install -r requirements.txt" ``` -------------------------------- ### Get Only Action Result using cURL Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Invoke an action and retrieve only the `response.result` field by appending `&result=true` to the blocking invocation URL. This simplifies getting the direct output of an action. ```bash curl -u $AUTH "https://$APIHOST/api/v1/namespaces/_/actions/hello?blocking=true&result=true" \ -X POST -H "Content-Type: application/json" \ -d '{"name":"John"}' ``` -------------------------------- ### Run Standalone Server with Gradle Source: https://github.com/apache/openwhisk/blob/master/core/standalone/README.md Execute the standalone server directly using Gradle's bootRun task. This is an alternative to running the JAR file. ```bash $ ./gradlew :core:standalone:bootRun ``` -------------------------------- ### Create an Action Source: https://github.com/apache/openwhisk/blob/master/docs/actions.md Use `wsk action create` to create a new action in your namespace from a local file. The command takes the action name and the path to the source file as arguments. ```bash wsk action create greeting greeting.js ok: created action greeting ``` -------------------------------- ### Cloudant Environment Variables and Setup Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Sets environment variables for Cloudant connection details and then executes the Ansible setup playbook. This is used for configuring the database for the deployment when using Cloudant. ```shell export OW_DB=Cloudant export OW_DB_USERNAME= export OW_DB_PASSWORD= export OW_DB_PROTOCOL=https export OW_DB_HOST=.cloudant.com export OW_DB_PORT=443 ansible-playbook -i environments/$ENVIRONMENT setup.yml ``` -------------------------------- ### Create Echo Action with Annotations Source: https://github.com/apache/openwhisk/blob/master/docs/annotations.md This snippet demonstrates creating an 'echo' action using the wsk CLI, including annotations for description, parameters, sample input, and sample output. ```bash wsk action create echo echo.js \ -a description 'An action which returns its input. Useful for logging input to enable debug/replay.' \ -a parameters '[{ "required":false, "description": "Any JSON entity" }]' \ -a sampleInput '{ "msg": "Five fuzzy felines"}' \ -a sampleOutput '{ "msg": "Five fuzzy felines"}' ``` -------------------------------- ### Create a new user with wskadmin-next Source: https://github.com/apache/openwhisk/blob/master/tools/admin/README-NEXT.md Command to create a new user (subject) in OpenWhisk. A unique key will be printed upon successful creation. ```bash $ wskadmin-next user create userA ``` -------------------------------- ### Install NPM Dependencies in Docker Container Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Installs Node.js dependencies within a Docker container to compile native modules for the correct runtime. This is useful when the zip file size limit is a concern. ```bash docker run -it -v $PWD:/nodejsAction openwhisk/action-nodejs-v10 "npm install" ``` -------------------------------- ### Run Webpack Build Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Execute the Webpack build process using the specified configuration file. ```bash npx webpack --config webpack.config.js ``` -------------------------------- ### JCenter Dependency Download Failure Example Source: https://github.com/apache/openwhisk/blob/master/docs/dev/troubleshooting/build-failures.md This snippet shows an example of a build failure caused by issues resolving dependencies from the JCenter repository. Check the JFrog Bintray status page if you encounter this. ```text FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'openwhisk'. > Could not resolve all files for configuration ':classpath'. > Could not download groovy-all.jar (org.codehaus.groovy:groovy-all:2.4.7) > Could not get resource 'https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.4.7/groovy-all-2.4.7.jar'. > Could not GET 'https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.4.7/groovy-all-2.4.7.jar'. > Connect to akamai.bintray.com:443 [akamai.bintray.com/23.45.134.89] failed: Connection timed out (Connection timed out) ``` -------------------------------- ### Compile Multi-File Swift Project with Dependencies Source: https://github.com/apache/openwhisk/blob/master/docs/actions-swift.md Compile a multi-file Swift project with dependencies. First, create a zip archive of your project structure (including Package.swift and Sources/). Then, pass this zip to the docker container via stdin to receive a zip archive containing the compiled executable. ```bash zip - -r * | docker run -i openwhisk/action-swift-v4.2 -compile main >../action-bin.zip ``` ```bash wsk action update helloSwiftly action-bin.zip --kind swift:4.2 wsk action invoke helloSwiftly -r ``` -------------------------------- ### Create a Package Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Creates a new package by sending a PUT request with the package name in the body. ```bash curl -u $AUTH https://$APIHOST/api/v1/namespaces/_/packages/iot?overwrite=true \ -X PUT -H "Content-Type: application/json" \ -d '{"namespace":"_","name":"iot"}' ``` -------------------------------- ### Get Specific Namespace Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace} ### Description Retrieves details for a specific namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace} ### Parameters #### Path Parameters - **namespace** (string) - Required - The name of the namespace. ### Response #### Success Response (200) - **Namespace object** #### Response Example ```json { "name": "user1", "separator": "/" } ``` ``` -------------------------------- ### Get Namespace Limits Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves the limits for a specified namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/limits ### Description Retrieves the resource limits for a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/limits ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace to get limits for. ### Response #### Success Response (200) - **Object containing limit details** #### Response Example ```json { "actions": { "count": { "limit": 1000 }, "size": { "limit": 262144000 } }, "triggers": { "count": { "limit": 1000 } }, "rules": { "count": { "limit": 1000 } }, "packages": { "count": { "limit": 1000 } }, "entities": { "count": { "limit": 10000 } } } ``` ``` -------------------------------- ### Create Action Sequence Source: https://github.com/apache/openwhisk/blob/master/docs/triggers_rules.md Command to create an action sequence named 'recordLocationAndHello' composed of two existing actions: '/whisk.system/utils/echo' and 'hello'. ```bash $ wsk action create recordLocationAndHello --sequence /whisk.system/utils/echo,hello ``` -------------------------------- ### Get Specific Activation Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific activation within a namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/activations/{activationName} ### Description Retrieves details for a specific activation in a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/activations/{activationName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the activation. - **activationName** (string) - Required - The name or ID of the activation. ### Response #### Success Response (200) - **Activation object** #### Response Example ```json { "activationId": "1234abcd-5678-efgh-9012-ijkl34567890", "namespace": "user1", "name": "myAction", "version": "1.0.0", "start": 1678886400000, "end": 1678886401000, "duration": 1000, "response": { "status": "success", "statusCode": 200, "success": true }, "logs": "..." } ``` ``` -------------------------------- ### Get Specific Package Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific package within a namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/packages/{packageName} ### Description Retrieves details for a specific package in a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/packages/{packageName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the package. - **packageName** (string) - Required - The name of the package. ### Response #### Success Response (200) - **Package object** #### Response Example ```json { "name": "myPackage", "namespace": "user1", "version": "1.0.0", "publish": true } ``` ``` -------------------------------- ### Create Zip Archive for Action Source: https://github.com/apache/openwhisk/blob/master/docs/actions-docker.md Bundles the compiled binary into a zip file for deployment as an OpenWhisk action. ```bash zip -r action.zip exec ``` -------------------------------- ### Get Specific Rule Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific rule within a namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/rules/{ruleName} ### Description Retrieves details for a specific rule in a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/rules/{ruleName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the rule. - **ruleName** (string) - Required - The name of the rule. ### Response #### Success Response (200) - **Rule object** #### Response Example ```json { "name": "myRule", "namespace": "user1", "version": "1.0.0", "trigger": "myTrigger", "action": "myAction", "publish": true } ``` ``` -------------------------------- ### Get Specific Trigger Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific trigger within a namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/triggers/{triggerName} ### Description Retrieves details for a specific trigger in a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/triggers/{triggerName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the trigger. - **triggerName** (string) - Required - The name of the trigger. ### Response #### Success Response (200) - **Trigger object** #### Response Example ```json { "name": "myTrigger", "namespace": "user1", "version": "1.0.0", "publish": true } ``` ``` -------------------------------- ### Create Cloudant Service Source: https://github.com/apache/openwhisk/blob/master/tools/db/README.md Use the `cf` command-line tool to create a Cloudant NoSQL database service instance for OpenWhisk. ```bash # Create a Cloudant service cf create-service cloudantNoSQLDB Shared cloudant-for-openwhisk ``` -------------------------------- ### Get Specific Action Source: https://github.com/apache/openwhisk/blob/master/docs/rest_api.md Retrieves details for a specific action within a namespace. ```APIDOC ## GET /api/v1/namespaces/{namespace}/actions/[{packageName}/]{actionName} ### Description Retrieves details for a specific action, optionally within a package, in a given namespace. ### Method GET ### Endpoint https://$APIHOST/api/v1/namespaces/{namespace}/actions/[{packageName}/]{actionName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the action. - **packageName** (string) - Optional - The name of the package containing the action. - **actionName** (string) - Required - The name of the action. ### Response #### Success Response (200) - **Action object** #### Response Example ```json { "name": "myAction", "namespace": "user1", "version": "1.0.0", "exec": { "kind": "nodejs:default", "code": "function main(params) { return {payload: params.payload}}; " }, "publish": true } ``` ``` -------------------------------- ### Action Invocation Result Source: https://github.com/apache/openwhisk/blob/master/docs/actions-nodejs.md Example JSON output from invoking the weather action with a specified location. ```json { "msg": "It is 28 degrees in Brooklyn, NY and Cloudy" } ``` -------------------------------- ### OpenWhisk Deployment with Elasticsearch Source: https://github.com/apache/openwhisk/blob/master/ansible/README.md Execute these commands to build the Docker image, set up CouchDB, and then deploy OpenWhisk with Elasticsearch as the activation backend. ```shell cd ./gradlew distDocker cd ansible # couchdb is still needed to store subjects and actions ansible-playbook -i environments/$ENVIRONMENT couchdb.yml ansible-playbook -i environments/$ENVIRONMENT initdb.yml ansible-playbook -i environments/$ENVIRONMENT wipe.yml # this will deploy a simple ES cluster, you can skip this to use external ES cluster ansible-playbook -i environments/$ENVIRONMENT elasticsearch.yml ansible-playbook -i environments/$ENVIRONMENT openwhisk.yml -e db_activation_backend=ElasticSearch # installs a catalog of public packages and actions ansible-playbook -i environments/$ENVIRONMENT postdeploy.yml # to use the API gateway ansible-playbook -i environments/$ENVIRONMENT apigateway.yml ansible-playbook -i environments/$ENVIRONMENT routemgmt.yml ``` -------------------------------- ### Get Specific Activation Details Source: https://github.com/apache/openwhisk/blob/master/docs/conductors.md This command retrieves detailed information about a specific activation using its ID. ```bash wsk activation get 4f91f9ed0d874aaa91f9ed0d87baaa07 ``` -------------------------------- ### Invoke Action Using Default Package Parameter Source: https://github.com/apache/openwhisk/blob/master/docs/parameters.md Invoke the 'MyApp/hello' action without providing any parameters. The action will use the default 'name' parameter set on the 'MyApp' package. ```bash wsk action invoke --result MyApp/hello ``` -------------------------------- ### JavaScript Web Action Example Source: https://github.com/apache/openwhisk/blob/master/docs/webactions.md A basic JavaScript function for a web action that returns its input parameters. ```javascript function main(params) { return { response: params }; } ``` -------------------------------- ### Build OpenWhisk Docker Image Source: https://github.com/apache/openwhisk/blob/master/tools/macos/README.md Navigates to the OpenWhisk project directory and builds the Docker image using Gradle. Ensure you are in the correct project path. ```bash cd /your/path/to/openwhisk ./gradlew distDocker ``` -------------------------------- ### Configure wsk CLI with Brew Source: https://github.com/apache/openwhisk/blob/master/tools/macos/README.md Installs the OpenWhisk CLI (wsk) using Homebrew and sets the API host and authentication properties. The auth property uses a local file for credentials. ```bash brew install wsk wsk property set --apihost https://localhost wsk property set --auth `cat ansible/files/auth.guest` ```