Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Code Block
$ wsk api-experimental delete /hello

Check it is removed by listing the APIs.

Code Block
$ wsk api-experimental list

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

Code Block
$ curl -v http://172.17.0.1:9001/api/3ae95da5-842f-45ae-afe1-3ddebae136e4/hello/echo?greeting=Hello+World

As expected this fails with a 404/Not Found status 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:

Code Block
$ 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:

Code Block
$ curl -v http://172.17.0.1:9001/api/3ae95da5-842f-45ae-afe1-3ddebae136e4/club/book

So lets quickly define the actions:

Code Block
$ wsk action create getBooks getBooks.js

...


$ wsk action create putBooks putBooks.js

Calling again returns as expected:

Code Block
$ curl http://172.17.0.1:9001/api/3ae95da5-842f-45ae-afe1-3ddebae136e4/club/book

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

Code Block
$ curl -XPOST http://172.17.0.1:9001/api/3ae95da5-842f-45ae-afe1-3ddebae136e4/club/book?file=myFile\&title=some+meaningless+stuff

Or

Code Block
$ curl http://172.17.0.1:9001/api/3ae95da5-842f-45ae-afe1-3ddebae136e4/club/book?file=book01

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

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

And finally clean up again:

Code Block
$ wsk api-experimental delete "Book Club"

And check:

Code Block
$ wsk api-experimental list