Work in Progress.

  • Needs instructions/links on how to setup system for demo
  • Needs full output from commands
  • Link file names to attachements


Demo Runbook

$ wsk api-experimental create /hello /echo get /whisk.system/utils/echo

Lets first implement a simple echoing API calling the OpenWhisk built-in echo action. This echo action just returns all request parameters as a result.

$ curl

So we registered and got the access URL back. Lets use cURL to "call" this API. As expected when not specifying any parameters, we don't get anything back. Lets just add a greeting.

$ curl

We can also list the routings configured with the API gateway using the "list" command:

$ wsk api-experimental list

For now we only have the echo API. Lets now.

We don't need this API any longer, so lets remove it:

$ wsk api-experimental delete /hello

Check it is removed by listing the APIs.

$ wsk api-experimental list

And just to be really sure, lets try to call it again, anyway:

$ curl -v

As expected this fails with a 404/Not Found status.

One nice feature of the current experimental integration is support for configuring APIs with Swagger JSON files. I have prepared such a file "bookClub.json" from which we can create the API using the "--config-file" option to the create command:

$ wsk api-experimental create --config-file bookClub.json

Beware this just configures the API gateway routing. The actions may not actually exist yet. So requesting the URLs may yield an error such as 404/Not Found:

$ curl -v

So lets quickly define the actions:

$ wsk action create getBooks getBooks.js
$ wsk action create putBooks putBooks.js

Calling again returns as expected:

$ curl

Requesting the URLs through the API gateway will map request parameters to function parameters. Lets test this with a simple book upload:

$ curl -XPOST\&title=some+meaningless+stuff


$ curl

For completeness you can extract the API in Swagger format and store in a local file:

$ wsk api-experimental get "Book Club" > bookClub.$$.json

And finally clean up again:

$ wsk api-experimental delete "Book Club"

And check:

$ wsk api-experimental list


  File Modified
File book01.json Jan 31, 2017 by Felix Meschberger
File bookClub.json Jan 31, 2017 by Felix Meschberger
JavaScript File getBooks.js Jan 31, 2017 by Felix Meschberger
File hello.json Jan 31, 2017 by Felix Meschberger
JavaScript File putBooks.js Jan 31, 2017 by Felix Meschberger

  • No labels