You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Our project welcomes external contributions! If you have an itch, please feel free to scratch it.
3
4
4
5
To contribute code or documentation, please submit a pull request to the [GitHub repository](https://github.com/IBM/ogs-serverless-apis).
@@ -7,17 +8,17 @@ A good way to familiarize yourself with the codebase and contribution process is
7
8
8
9
**We appreciate your effort, and want to avoid a situation where a contribution requires extensive rework (by you or by us), sits in the queue for a long time, or cannot be accepted at all!**
9
10
10
-
###Proposing new features
11
+
## Proposing new features
11
12
12
13
If you would like to implement a new feature, please [raise an issue](https://github.com/IBM/ogs-serverless-apis/issues) before sending a pull request so the feature can be discussed.
13
14
This is to avoid you spending your valuable time working on a feature that the project developers are not willing to accept into the code base.
14
15
15
-
###Fixing bugs
16
+
## Fixing bugs
16
17
17
18
If you would like to fix a bug, please [raise an issue](https://github.com/IBM/ogs-serverless-apis/issues) before sending a pull request so it can be discussed.
18
19
If the fix is trivial or non controversial then this is not usually necessary.
19
20
20
-
###Merge approval
21
+
## Merge approval
21
22
22
23
The project maintainers use LGTM (Looks Good To Me) in comments on the code review to
23
24
indicate acceptance. A change requires LGTMs from two of the maintainers of each
@@ -26,13 +27,17 @@ component affected.
26
27
For more details, see the [MAINTAINERS](MAINTAINERS.md) page.
27
28
28
29
## Communication
30
+
29
31
Please feel free to connect with us on our [Slack channel](https://dwopen.slack.com).
30
32
31
33
## Setup
34
+
32
35
Please add any special setup instructions for your project to help the developer become productive quickly.
33
36
34
37
## Testing
38
+
35
39
Please provide information that helps the developer test any changes they make before submitting.
36
40
37
41
## Coding style guidelines
42
+
38
43
Beautiful code rocks! Please share any specific style guidelines you might have for your project.
Copy file name to clipboardExpand all lines: README-ko.md
+39-28Lines changed: 39 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,10 @@ IBM Bluemix의 Apache OpenWhisk로 REST API 매핑을 생성하십시오. 이
16
16
2.[REST 엔드포인트 생성하기](#2-rest-엔드포인트-생성하기)
17
17
3.[정리하기](#3-정리하기)
18
18
19
-
# 1. OpenWhisk 액션 생성하기
20
-
## cat 엔티티를 생성하는 액션 만들기
19
+
## 1. OpenWhisk 액션 생성하기
20
+
21
+
### cat 엔티티를 생성하는 액션 만들기
22
+
21
23
`create-cat.js`이란 이름의 파일을 생성하십시오. 이 파일은 JavaScript 함수로 작성된 OpenWhisk 액션을 정의하게 됩니다. 이 함수는 요청된 매개 변수 (`name` 및 `color`)를 확인하며 cat에 대한 고유한 id를 리턴하거나 매개 변수가 없는 경우 오류를 리턴합니다.
22
24
> **참고**: 이 예제는 단순화 된 것이며 백엔드 데이터 저장소와 연결되어 있지 않습니다. 좀 더 복잡한 예제는, [REST API 예제](https://github.com/IBM/openwhisk-serverless-apis)를 참고하시기 바랍니다.
23
25
@@ -41,7 +43,8 @@ function main(params) {
41
43
}
42
44
```
43
45
44
-
## cat 엔티티를 리턴하는 액션 만들기
46
+
### cat 엔티티를 리턴하는 액션 만들기
47
+
45
48
`fetch-cat.js`이란 이름의 파일을 생성하십시오. 이 파일은 JavaScript 함수로 작성된 OpenWhisk 액션을 정의하게 됩니다. 이 함수는 요청된 매개 변수 (`id`)를 확인하며 Tabby색 고양이 Tahoma를 리턴합니다.
46
49
> **참고**: 다시 말하지만, 단순화된 데모용으로 백엔드 데이터 저장소 연결보다는 항상 Tahoma를 리턴합니다.
47
50
@@ -67,50 +70,54 @@ function main(params) {
67
70
}
68
71
```
69
72
70
-
## 액션 업로드하기
73
+
### 액션 업로드하기
74
+
71
75
다음 단계에서는 방금 생성한 JavaScript 함수로 부터 OpenWhisk 액션을 생성하게 됩니다. 이들 액션에 `--web true`라는 플래그를 추가하여 "Web Actions"로서 인식하도록 합니다. 이는 나중에 REST 엔드 포인트를 추가할 때 필요합니다.
OpenWhisk 액션은 명백하게 호출되거나 이벤트에 대응하는 무상태(stateless) 코드 조각입니다. 지금은, 명백하게 호출하는 방법으로 액션을 테스트 하게 됩니다. 나중에는, HTTP 요청에 대응하여 액션을 호출하게 됩니다. 아래 코드로 액션을 호출하고 `--param` 명령줄 인수를 사용하여 매개 변수를 전달하십시오.
79
85
80
86
```bash
81
-
wsk action invoke \
87
+
bx wsk action invoke \
82
88
--blocking \
83
89
--param name Tahoma \
84
90
--param color Tabby \
85
91
create-cat
86
92
87
-
wsk action invoke \
93
+
bx wsk action invoke \
88
94
--blocking \
89
95
--param id 1 \
90
96
fetch-cat
91
97
```
92
98
93
99
> **참고**: 오류 메시지가 보이는 경우 아래 [문제 해결](#문제-해결) 영역을 참고 하십시오.
94
100
95
-
# 2. REST 엔드포인트 생성하기
96
-
## `/v1/cat` 엔드포인트에 대한 POST와 GET REST 매핑 생성하기
97
-
지금까지 OpenWhisk 액션을 생성했고, 이제 Bluemix API 게이트웨이를 통해 OpenWhisk 액션을 노출하게 됩니다. 이를 위해 이 명령을 이용합니다: `wsk api create $BASE_PATH $API_PATH $API_VERB $ACTION `
101
+
## 2. REST 엔드포인트 생성하기
102
+
103
+
### `/v1/cat` 엔드포인트에 대한 POST와 GET REST 매핑 생성하기
104
+
105
+
지금까지 OpenWhisk 액션을 생성했고, 이제 Bluemix API 게이트웨이를 통해 OpenWhisk 액션을 노출하게 됩니다. 이를 위해 이 명령을 이용합니다: `bx wsk api create $BASE_PATH $API_PATH $API_VERB $ACTION`
98
106
99
107
이 기능은 [Bluemix Native API Management](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway)의 일부이며 현재 보안, 속도 제한 등과 같은 매우 강력한 API 관리 기능을 제공합니다. 비록 지금은 단지 CLI를 사용하여 public REST endpoint로 액션을 노출하고 있습니다.
wsk api create -n "Cats API" /v1 /cat post create-cat
111
+
bx wsk api create -n "Cats API" /v1 /cat post create-cat
107
112
108
113
# 노출 /v1/cat?id=1
109
-
wsk api create /v1 /cat get fetch-cat
114
+
bx wsk api create /v1 /cat get fetch-cat
110
115
```
116
+
111
117
CLI는 두 가지 경우 모두 API 이용을 위한 URL을 출력합니다. 다음 영역에서 사용을 위해 모든 정보를 기록해 두십시오.
112
118
113
-
## `curl` HTTP 요청으로 테스트 하기
119
+
### `curl` HTTP 요청으로 테스트 하기
120
+
114
121
앞서 명령으로 생성된 API URL을 가져옵니다. 액션 테스트를 위해 `curl`을 사용하여 http POST와 GET 요청을 보냅니다. 필요로하는 매개 변수 전달을 위해 POST에 대해서는 요청의 body에, GET에 대해서는 경로로 전달되는 것을 기억하십시오. OpenWhisk는 이와 같은 매개변수를 액션에 자동으로 전달합니다.
가장 먼저 OpenWhisk 활성화 로그에서 오류를 확인 하십시오. 명령창에서 `wsk activation poll`을 이용하여 로그 메시지를 확인하거나 [Bluemix의 모니터링 콘솔](https://console.ng.bluemix.net/openwhisk/dashboard)에서 시각적으로 상세정보를 확인해 보십시오.
144
+
## 문제 해결
145
+
146
+
가장 먼저 OpenWhisk 활성화 로그에서 오류를 확인 하십시오. 명령창에서 `bx wsk activation poll`을 이용하여 로그 메시지를 확인하거나 [Bluemix의 모니터링 콘솔](https://console.ng.bluemix.net/openwhisk/dashboard)에서 시각적으로 상세정보를 확인해 보십시오.
147
+
148
+
오류가 즉각적으로 분명하지 않다면, [최신 버젼의 `bx wsk` CLI](https://console.ng.bluemix.net/openwhisk/learn/cli)가 설치되어 있는지 확인하십시오. 만약 이전 것이라면 다운로드하고 업데이트 하십시오.
138
149
139
-
오류가 즉각적으로 분명하지 않다면, [최신 버젼의 `wsk` CLI](https://console.ng.bluemix.net/openwhisk/learn/cli)가 설치되어 있는지 확인하십시오. 만약 이전 것이라면 다운로드하고 업데이트 하십시오.
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).
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 (`bx wsk`) or IBM Cloud command line plugin (`bx bx wsk`)](https://github.com/IBM/openwhisk-action-trigger-rule/blob/master/docs/OPENWHISK.md).
10
10
11
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).
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.
20
22
> **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).
21
23
@@ -39,7 +41,8 @@ function main(params) {
39
41
}
40
42
```
41
43
42
-
## Create an action to return a cat entity
44
+
### Create an action to return a cat entity
45
+
43
46
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.
44
47
> **Note**: Again, for the purpose of this simplified demo we always return Tahoma the cat, rather than connecting to a backend datastore.
45
48
@@ -65,50 +68,54 @@ function main(params) {
65
68
}
66
69
```
67
70
68
-
## Upload the actions
71
+
### Upload the actions
72
+
69
73
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.
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.
77
83
78
84
```bash
79
-
wsk action invoke \
85
+
bx wsk action invoke \
80
86
--blocking \
81
87
--param name Tahoma \
82
88
--param color Tabby \
83
89
create-cat
84
90
85
-
wsk action invoke \
91
+
bx wsk action invoke \
86
92
--blocking \
87
93
--param id 1 \
88
94
fetch-cat
89
95
```
90
96
91
97
> **Note**: If you see any error messages, refer to the [Troubleshooting](#troubleshooting) section below.
92
98
93
-
# 2. Create REST endpoints
94
-
## Create POST and GET REST mappings for `/v1/cat` endpoint
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 `
99
+
## 2. Create REST endpoints
100
+
101
+
### Create POST and GET REST mappings for `/v1/cat` endpoint
102
+
103
+
Now that we have our Cloud Functions created, we will expose them through the Bluemix API Gateway. To do this we use: `bx wsk api create $BASE_PATH $API_PATH $API_VERB $ACTION`
96
104
97
105
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.
98
106
99
107
```bash
100
-
# Send along credentials with the command or provide them interactively
# Exposes POST /v1/cat {"name": "Tahoma", "color": "Tabby"}
104
-
wsk api create -n "Cats API" /v1 /cat post create-cat
109
+
bx wsk api create -n "Cats API" /v1 /cat post create-cat
105
110
106
111
# Exposes /v1/cat?id=1
107
-
wsk api create /v1 /cat get fetch-cat
112
+
bx wsk api create /v1 /cat get fetch-cat
108
113
```
114
+
109
115
In both cases, the CLI will output the URL required to use the API. Make note of it for the next section.
110
116
111
-
## Test with `curl` HTTP requests
117
+
### Test with `curl` HTTP requests
118
+
112
119
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.
### Remove the API mappings and delete the actions
124
132
125
133
```bash
126
134
# Remove API base which removes all the mappings
127
-
wsk api delete /v1
135
+
bx wsk api delete /v1
128
136
129
137
# Remove actions
130
-
wsk action delete create-cat
131
-
wsk action delete fetch-cat
138
+
bx wsk action delete create-cat
139
+
bx wsk action delete fetch-cat
132
140
```
133
141
134
-
# Troubleshooting
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 [Cloud Functions monitoring console](https://console.ng.bluemix.net/openwhisk/dashboard).
142
+
## Troubleshooting
143
+
144
+
Check for errors first in the Cloud Functions activation log. Tail the log on the command line with `bx wsk activation poll` or drill into details visually with the [Cloud Functions monitoring console](https://console.ng.bluemix.net/openwhisk/dashboard).
145
+
146
+
If the error is not immediately obvious, make sure you have the [latest version of the `bx wsk` CLI installed](https://console.ng.bluemix.net/openwhisk/learn/cli). If it's older than a few weeks, download an update.
136
147
137
-
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.
0 commit comments