Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit c0cd7de

Browse files
committed
Use Cloud Functions naming.
1 parent cbeaebd commit c0cd7de

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

‎README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# OpenWhisk Building Block - HTTP REST API Trigger
1+
# Triggering IBM Cloud Functions on HTTP REST API calls
22

33
*Read this in other languages: [한국어](README-ko.md).*
44

5-
Create REST API mappings with Apache OpenWhisk on IBM Bluemix. This tutorial should take about 5 minutes to complete. After this, move on to more complex serverless applications such as those tagged [_openwhisk-hands-on-demo_](https://github.com/search?q=topic%3Aopenwhisk-hands-on-demo+org%3AIBM&type=Repositories).
5+
Create REST API mappings with IBM Cloud Functions powered by Apache OpenWhisk. This tutorial should take about 5 minutes to complete. After this, move on to more complex serverless applications such as those tagged [_openwhisk-hands-on-demo_](https://github.com/search?q=topic%3Aopenwhisk-hands-on-demo+org%3AIBM&type=Repositories).
66

77
![Sample Architecture](openwhisk-rest-api-trigger.png)
88

9-
If you're not familiar with the OpenWhisk programming model [try the action, trigger, and rule sample first](https://github.com/IBM/openwhisk-action-trigger-rule). [You'll need a Bluemix account and the latest OpenWhisk command line tool](https://github.com/IBM/openwhisk-action-trigger-rule/blob/master/docs/OPENWHISK.md).
9+
If you're not familiar with the Cloud Functions/OpenWhisk programming model [try the action, trigger, and rule sample first](https://github.com/IBM/openwhisk-action-trigger-rule). [You'll need an IBM Cloud account and the latest OpenWhisk (`wsk`) or IBM Cloud command line plugin (`bx wsk`)](https://github.com/IBM/openwhisk-action-trigger-rule/blob/master/docs/OPENWHISK.md).
1010

11-
This example provides two REST endpoints for HTTP `POST` and `GET` methods that are mapped to corresponding OpenWhisk `create-cat` and `fetch-cat` actions.
11+
This example provides two REST endpoints for HTTP `POST` and `GET` methods that are mapped to corresponding `create-cat` and `fetch-cat` Cloud Functions (OpenWhisk actions).
1212

13-
1. [Create OpenWhisk actions](#1-create-openwhisk-actions)
13+
1. [Create Cloud Functions](#1-create-cloud-functions)
1414
2. [Create REST endpoints](#2-create-rest-endpoints)
1515
4. [Clean up](#3-clean-up)
1616

17-
# 1. Create OpenWhisk actions
17+
# 1. Create Cloud Functions
1818
## Create an action to create a cat entity
19-
Create a file named `create-cat.js`. This file will define an OpenWhisk action written as a JavaScript function. It checks for the required parameters(`name` and `color`) and returns a unique identifier for the cat, or an error if either parameter is missing.
19+
Create a file named `create-cat.js`. This file will define an action written as a JavaScript function. It checks for the required parameters(`name` and `color`) and returns a unique identifier for the cat, or an error if either parameter is missing.
2020
> **Note**: This example is simplified, and does not connect to a backend datastore. For a more sophisticated example, check out this [REST API example](https://github.com/IBM/openwhisk-serverless-apis).
2121
2222
```javascript
@@ -40,7 +40,7 @@ function main(params) {
4040
```
4141

4242
## Create an action to return a cat entity
43-
Create a file named `fetch-cat.js`. This file will define an OpenWhisk action written as a JavaScript function. It checks for the required parameter(`id`) and returns Tahoma, the tabby colored cat.
43+
Create a file named `fetch-cat.js`. This file will define another action written as a JavaScript function. It checks for the required parameter(`id`) and returns Tahoma, the tabby colored cat.
4444
> **Note**: Again, for the purpose of this simplified demo we always return Tahoma the cat, rather than connecting to a backend datastore.
4545
4646
```javascript
@@ -66,14 +66,14 @@ function main(params) {
6666
```
6767

6868
## Upload the actions
69-
The next step will be to create OpenWhisk actions from the JavaScript functions that we just created. We also add the `--web true` flag, to annotate these actions as "Web Actions". This will be necessary later when we add REST endpoints.
69+
The next step will be to deploy Cloud Functions from the JavaScript files that we just created. We also add the `--web true` flag, to annotate these actions as "Web Actions". This will be necessary later when we add REST endpoints as it makes the actions HTTP-aware.
7070
```bash
7171
wsk action create create-cat create-cat.js --web true
7272
wsk action create fetch-cat fetch-cat.js --web true
7373
```
7474

7575
## Unit test the actions
76-
OpenWhisk actions are stateless code snippets that can be invoked explicitly or in response to an event. For right now, we will test our actions by explicitly invoking them. Later, we will trigger our actions in response to an HTTP request. Invoke the actions using the code below and pass the parameters using the `--param` command line argument.
76+
Cloud Functions (OpenWhisk actions) are stateless code snippets that can be invoked explicitly or in response to an event. For right now, we will test our actions by explicitly invoking them. Later, we will trigger our actions in response to an HTTP request. Invoke the actions using the code below and pass the parameters using the `--param` command line argument.
7777

7878
```bash
7979
wsk action invoke \
@@ -92,9 +92,9 @@ wsk action invoke \
9292
9393
# 2. Create REST endpoints
9494
## Create POST and GET REST mappings for `/v1/cat` endpoint
95-
Now that we have our OpenWhisk actions created, we will expose our OpenWhisk actions through the Bluemix API Gateway. To do this we will use: `wsk api create $BASE_PATH $API_PATH $API_VERB $ACTION `
95+
Now that we have our Cloud Functions created, we will expose them through the Bluemix API Gateway. To do this we use: `wsk api create $BASE_PATH $API_PATH $API_VERB $ACTION `
9696

97-
This feature is part of the [Bluemix Native API Management](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway) service and currently supports very powerful API management features like security, rate limiting, and more. For now though we're just using the CLI to expose our action with a public REST endpoint.
97+
This feature is part of the [IBM Cloud Native API Management](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway) service and currently supports very powerful API management features like security, rate limiting, and more. For now though we're just using the CLI to expose our action with a public REST endpoint.
9898

9999
```bash
100100
# Send along credentials with the command or provide them interactively
@@ -109,7 +109,7 @@ wsk api create /v1 /cat get fetch-cat
109109
In both cases, the CLI will output the URL required to use the API. Make note of it for the next section.
110110

111111
## Test with `curl` HTTP requests
112-
Take note of the API URL that is generated from the previous command. Send an http POST and GET request using `curl` to test the actions. Remember to send the required parameters in the body of the request for POST, or as path parameters for GET. OpenWhisk automatically forwards these parameters to the actions we created.
112+
Take note of the API URL that is generated from the previous command. Send an HTTP POST and GET request using `curl` to test the actions. Remember to send the required parameters in the body of the request for POST, or as path parameters for GET. The IBM Cloud Functions system automatically forwards these parameters to the actions we created.
113113

114114
```bash
115115
# POST /v1/cat {"name": "Tahoma", "color": "Tabby"}
@@ -132,7 +132,7 @@ wsk action delete fetch-cat
132132
```
133133

134134
# Troubleshooting
135-
Check for errors first in the OpenWhisk activation log. Tail the log on the command line with `wsk activation poll` or drill into details visually with the [monitoring console on Bluemix](https://console.ng.bluemix.net/openwhisk/dashboard).
135+
Check for errors first in the Cloud Functions activation log. Tail the log on the command line with `wsk activation poll` or drill into details visually with the [monitoring console on Bluemix](https://console.ng.bluemix.net/openwhisk/dashboard).
136136

137137
If the error is not immediately obvious, make sure you have the [latest version of the `wsk` CLI installed](https://console.ng.bluemix.net/openwhisk/learn/cli). If it's older than a few weeks, download an update.
138138
```bash

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /