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 c07ba86

Browse files
authored
Merge pull request #24 from IBM/oscon
Oscon
2 parents c76777f + d94fbed commit c07ba86

File tree

5 files changed

+91
-64
lines changed

5 files changed

+91
-64
lines changed

‎CONTRIBUTING.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## Contributing In General
1+
# Contributing In General
2+
23
Our project welcomes external contributions! If you have an itch, please feel free to scratch it.
34

45
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
78

89
**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!**
910

10-
### Proposing new features
11+
## Proposing new features
1112

1213
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.
1314
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.
1415

15-
### Fixing bugs
16+
## Fixing bugs
1617

1718
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.
1819
If the fix is trivial or non controversial then this is not usually necessary.
1920

20-
### Merge approval
21+
## Merge approval
2122

2223
The project maintainers use LGTM (Looks Good To Me) in comments on the code review to
2324
indicate acceptance. A change requires LGTMs from two of the maintainers of each
@@ -26,13 +27,17 @@ component affected.
2627
For more details, see the [MAINTAINERS](MAINTAINERS.md) page.
2728

2829
## Communication
30+
2931
Please feel free to connect with us on our [Slack channel](https://dwopen.slack.com).
3032

3133
## Setup
34+
3235
Please add any special setup instructions for your project to help the developer become productive quickly.
3336

3437
## Testing
38+
3539
Please provide information that helps the developer test any changes they make before submitting.
3640

3741
## Coding style guidelines
42+
3843
Beautiful code rocks! Please share any specific style guidelines you might have for your project.

‎LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2015-2017 IBM Corporation
190+
Copyright 2018-2018 IBM Corporation
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

‎MAINTAINERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Maintainers Guide
1+
# Maintainers Guide
22

33
This guide is intended for maintainers — anybody with commit access to one or more Developer Technology repositories.
44

‎README-ko.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ IBM Bluemix의 Apache OpenWhisk로 REST API 매핑을 생성하십시오. 이
1616
2. [REST 엔드포인트 생성하기](#2-rest-엔드포인트-생성하기)
1717
3. [정리하기](#3-정리하기)
1818

19-
# 1. OpenWhisk 액션 생성하기
20-
## cat 엔티티를 생성하는 액션 만들기
19+
## 1. OpenWhisk 액션 생성하기
20+
21+
### cat 엔티티를 생성하는 액션 만들기
22+
2123
`create-cat.js`이란 이름의 파일을 생성하십시오. 이 파일은 JavaScript 함수로 작성된 OpenWhisk 액션을 정의하게 됩니다. 이 함수는 요청된 매개 변수 (`name``color`)를 확인하며 cat에 대한 고유한 id를 리턴하거나 매개 변수가 없는 경우 오류를 리턴합니다.
2224
> **참고**: 이 예제는 단순화 된 것이며 백엔드 데이터 저장소와 연결되어 있지 않습니다. 좀 더 복잡한 예제는, [REST API 예제](https://github.com/IBM/openwhisk-serverless-apis)를 참고하시기 바랍니다.
2325
@@ -41,7 +43,8 @@ function main(params) {
4143
}
4244
```
4345

44-
## cat 엔티티를 리턴하는 액션 만들기
46+
### cat 엔티티를 리턴하는 액션 만들기
47+
4548
`fetch-cat.js`이란 이름의 파일을 생성하십시오. 이 파일은 JavaScript 함수로 작성된 OpenWhisk 액션을 정의하게 됩니다. 이 함수는 요청된 매개 변수 (`id`)를 확인하며 Tabby색 고양이 Tahoma를 리턴합니다.
4649
> **참고**: 다시 말하지만, 단순화된 데모용으로 백엔드 데이터 저장소 연결보다는 항상 Tahoma를 리턴합니다.
4750
@@ -67,50 +70,54 @@ function main(params) {
6770
}
6871
```
6972

70-
## 액션 업로드하기
73+
### 액션 업로드하기
74+
7175
다음 단계에서는 방금 생성한 JavaScript 함수로 부터 OpenWhisk 액션을 생성하게 됩니다. 이들 액션에 `--web true`라는 플래그를 추가하여 "Web Actions"로서 인식하도록 합니다. 이는 나중에 REST 엔드 포인트를 추가할 때 필요합니다.
76+
7277
```bash
73-
wsk action create create-cat create-cat.js --web true
74-
wsk action create fetch-cat fetch-cat.js --web true
78+
bx wsk action create create-cat create-cat.js --web true
79+
bx wsk action create fetch-cat fetch-cat.js --web true
7580
```
7681

77-
## 액션에 대해 단위 테스트하기
82+
### 액션에 대해 단위 테스트하기
83+
7884
OpenWhisk 액션은 명백하게 호출되거나 이벤트에 대응하는 무상태(stateless) 코드 조각입니다. 지금은, 명백하게 호출하는 방법으로 액션을 테스트 하게 됩니다. 나중에는, HTTP 요청에 대응하여 액션을 호출하게 됩니다. 아래 코드로 액션을 호출하고 `--param` 명령줄 인수를 사용하여 매개 변수를 전달하십시오.
7985

8086
```bash
81-
wsk action invoke \
87+
bx wsk action invoke \
8288
--blocking \
8389
--param name Tahoma \
8490
--param color Tabby \
8591
create-cat
8692

87-
wsk action invoke \
93+
bx wsk action invoke \
8894
--blocking \
8995
--param id 1 \
9096
fetch-cat
9197
```
9298

9399
> **참고**: 오류 메시지가 보이는 경우 아래 [문제 해결](#문제-해결) 영역을 참고 하십시오.
94100
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`
98106

99107
이 기능은 [Bluemix Native API Management](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway)의 일부이며 현재 보안, 속도 제한 등과 같은 매우 강력한 API 관리 기능을 제공합니다. 비록 지금은 단지 CLI를 사용하여 public REST endpoint로 액션을 노출하고 있습니다.
100108

101109
```bash
102-
# 명령과 함께 신임 정보를 보내거나 대화식으로 제공합니다
103-
wsk bluemix login --user $YOUR_BLUEMIX_USERNAME --password $YOUR_BLUEMIX_PASSWORD
104-
105110
# POST로 노출 /v1/cat {"name": "Tahoma", "color": "Tabby"}
106-
wsk api create -n "Cats API" /v1 /cat post create-cat
111+
bx wsk api create -n "Cats API" /v1 /cat post create-cat
107112

108113
# 노출 /v1/cat?id=1
109-
wsk api create /v1 /cat get fetch-cat
114+
bx wsk api create /v1 /cat get fetch-cat
110115
```
116+
111117
CLI는 두 가지 경우 모두 API 이용을 위한 URL을 출력합니다. 다음 영역에서 사용을 위해 모든 정보를 기록해 두십시오.
112118

113-
## `curl` HTTP 요청으로 테스트 하기
119+
### `curl` HTTP 요청으로 테스트 하기
120+
114121
앞서 명령으로 생성된 API URL을 가져옵니다. 액션 테스트를 위해 `curl`을 사용하여 http POST와 GET 요청을 보냅니다. 필요로하는 매개 변수 전달을 위해 POST에 대해서는 요청의 body에, GET에 대해서는 경로로 전달되는 것을 기억하십시오. OpenWhisk는 이와 같은 매개변수를 액션에 자동으로 전달합니다.
115122

116123
```bash
@@ -121,25 +128,29 @@ curl -X POST -H 'Content-Type: application/json' -d '{"name":"Tahoma","color":"T
121128
curl $THE_URL_FROM_ABOVE?id=1
122129
```
123130

124-
# 3. 정리하기
125-
## 모든 API 매핑을 제거하고 액션을 삭제하십시오
131+
## 3. 정리하기
132+
133+
### 모든 API 매핑을 제거하고 액션을 삭제하십시오
126134

127135
```bash
128136
# 모든 매핑을 제거하는 API 베이스 삭제
129-
wsk api delete /v1
137+
bx wsk api delete /v1
130138

131139
# 액션 삭제
132-
wsk action delete create-cat
133-
wsk action delete fetch-cat
140+
bx wsk action delete create-cat
141+
bx wsk action delete fetch-cat
134142
```
135143

136-
# 문제 해결
137-
가장 먼저 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)가 설치되어 있는지 확인하십시오. 만약 이전 것이라면 다운로드하고 업데이트 하십시오.
138149

139-
오류가 즉각적으로 분명하지 않다면, [최신 버젼의 `wsk` CLI](https://console.ng.bluemix.net/openwhisk/learn/cli)가 설치되어 있는지 확인하십시오. 만약 이전 것이라면 다운로드하고 업데이트 하십시오.
140150
```bash
141-
wsk property get --cliversion
151+
bx wsk property get --cliversion
142152
```
143153

144-
# 라이센스
154+
## 라이센스
155+
145156
[Apache 2.0](LICENSE.txt)

‎README.md

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ Create REST API mappings with IBM Cloud Functions powered by Apache OpenWhisk. T
66

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

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).
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).
1010

1111
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

1313
1. [Create Cloud Functions](#1-create-cloud-functions)
1414
2. [Create REST endpoints](#2-create-rest-endpoints)
15-
4. [Clean up](#3-clean-up)
15+
3. [Clean up](#3-clean-up)
16+
17+
## 1. Create Cloud Functions
18+
19+
### Create an action to create a cat entity
1620

17-
# 1. Create Cloud Functions
18-
## Create an action to create a cat entity
1921
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.
2022
> **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).
2123
@@ -39,7 +41,8 @@ function main(params) {
3941
}
4042
```
4143

42-
## Create an action to return a cat entity
44+
### Create an action to return a cat entity
45+
4346
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.
4447
> **Note**: Again, for the purpose of this simplified demo we always return Tahoma the cat, rather than connecting to a backend datastore.
4548
@@ -65,50 +68,54 @@ function main(params) {
6568
}
6669
```
6770

68-
## Upload the actions
71+
### Upload the actions
72+
6973
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.
74+
7075
```bash
71-
wsk action create create-cat create-cat.js --web true
72-
wsk action create fetch-cat fetch-cat.js --web true
76+
bx wsk action create create-cat create-cat.js --web true
77+
bx wsk action create fetch-cat fetch-cat.js --web true
7378
```
7479

75-
## Unit test the actions
80+
### Unit test the actions
81+
7682
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.
7783

7884
```bash
79-
wsk action invoke \
85+
bx wsk action invoke \
8086
--blocking \
8187
--param name Tahoma \
8288
--param color Tabby \
8389
create-cat
8490

85-
wsk action invoke \
91+
bx wsk action invoke \
8692
--blocking \
8793
--param id 1 \
8894
fetch-cat
8995
```
9096

9197
> **Note**: If you see any error messages, refer to the [Troubleshooting](#troubleshooting) section below.
9298
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`
96104

97105
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.
98106

99107
```bash
100-
# Send along credentials with the command or provide them interactively
101-
wsk bluemix login --user $YOUR_BLUEMIX_USERNAME --password $YOUR_BLUEMIX_PASSWORD
102-
103108
# 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
105110

106111
# Exposes /v1/cat?id=1
107-
wsk api create /v1 /cat get fetch-cat
112+
bx wsk api create /v1 /cat get fetch-cat
108113
```
114+
109115
In both cases, the CLI will output the URL required to use the API. Make note of it for the next section.
110116

111-
## Test with `curl` HTTP requests
117+
### Test with `curl` HTTP requests
118+
112119
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.
113120

114121
```bash
@@ -119,25 +126,29 @@ curl -X POST -H 'Content-Type: application/json' -d '{"name":"Tahoma","color":"T
119126
curl $THE_URL_FROM_ABOVE?id=1
120127
```
121128

122-
# 3. Clean up
123-
## Remove the API mappings and delete the actions
129+
## 3. Clean up
130+
131+
### Remove the API mappings and delete the actions
124132

125133
```bash
126134
# Remove API base which removes all the mappings
127-
wsk api delete /v1
135+
bx wsk api delete /v1
128136

129137
# 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
132140
```
133141

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.
136147

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.
138148
```bash
139-
wsk property get --cliversion
149+
bx wsk property get --cliversion
140150
```
141151

142-
# License
152+
## License
153+
143154
[Apache 2.0](LICENSE.txt)

0 commit comments

Comments
(0)

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