Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Cloud Functions #127

Merged
merged 10 commits into from
Jun 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions functions/datastore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ View the [source code][code].

## Deploy and Test

1. Follow the [Cloud Functions quickstart guide](https://cloud.google.com/functions/quickstart) to setup Cloud Functions for your project.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

1. Clone this repository:

Expand All @@ -19,27 +20,35 @@ View the [source code][code].

1. Create a Cloud Storage Bucket to stage our deployment:

gsutil mb gs://<your-bucket-name>
gsutil mb gs://[YOUR_BUCKET_NAME]

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Ensure the Cloud Datastore API is enabled:

[Click here to enable the Cloud Datastore API](https://console.cloud.google.com/flows/enableapi?apiid=datastore.googleapis.com&redirect=https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/functions/datastore)

1. Deploy the "ds-get" function with an HTTP trigger:

gcloud alpha functions deploy ds-get --bucket <your-bucket-name> --trigger-http --entry-point get
gcloud alpha functions deploy ds-get --bucket [YOUR_BUCKET_NAME] --trigger-http --entry-point get

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the "ds-set" function with an HTTP trigger:

gcloud alpha functions deploy ds-set --bucket <your-bucket-name> --trigger-http --entry-point set
gcloud alpha functions deploy ds-set --bucket [YOUR_BUCKET_NAME] --trigger-http --entry-point set

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the "ds-del" function with an HTTP trigger:

gcloud alpha functions deploy ds-del --bucket <your-bucket-name> --trigger-http --entry-point del
gcloud alpha functions deploy ds-del --bucket [YOUR_BUCKET_NAME] --trigger-http --entry-point del

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the "ds-set" function to create a new entity:

gcloud alpha functions call ds-set --data '{"kind":"gcf-test","key":"foobar","value":{"message": "Hello World!"}}'
gcloud alpha functions call ds-set --data '{"kind":"gcf-test","key":"foobar","value":{"message":"Hello World!"}}'

1. Call the "ds-get" function to read the newly created entity:

Expand All @@ -52,3 +61,5 @@ View the [source code][code].
1. Call the "ds-get" function again to verify it was deleted:

gcloud alpha functions call ds-get --data '{"kind":"gcf-test","key":"foobar"}'

[quickstart]: https://cloud.google.com/functions/quickstart
21 changes: 16 additions & 5 deletions functions/gcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ View the [source code][code].

## Deploy and Test

1. Follow the [Cloud Functions quickstart guide](https://cloud.google.com/functions/quickstart) to setup Cloud Functions for your project.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

1. Clone this repository:

Expand All @@ -19,20 +20,30 @@ View the [source code][code].

1. Create a Cloud Storage Bucket to stage our deployment:

gsutil mb gs://<your-bucket-name>
gsutil mb gs://[YOUR_BUCKET_NAME]

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Upload the sample file to the bucket:

gsutil cp sample.txt gs://<your-bucket-name>
gsutil cp sample.txt gs://[YOUR_BUCKET_NAME]

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the "wordCount" function with an HTTP trigger:

gcloud alpha functions deploy wordCount --bucket <your-bucket-name> --trigger-http --entry-point map
gcloud alpha functions deploy wordCount --bucket [YOUR_BUCKET_NAME] --trigger-http --entry-point map

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the "wordCount" function using the sample file:

gcloud alpha functions call wordCount --data '{"bucket":"<your-bucket-name>","file":"sample.txt"}'
gcloud alpha functions call wordCount --data '{"bucket":"[YOUR_BUCKET_NAME]","file":"sample.txt"}'

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

You should see something like this in your console

The file sample.txt has 114 words

[quickstart]: https://cloud.google.com/functions/quickstart
33 changes: 25 additions & 8 deletions functions/helloworld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@ View the [documentation][docs] or the [source code][code].
[docs]: https://cloud.google.com/functions/writing
[code]: index.js

## Deploy
## Deploy and Test

This example deploys the function with an HTTP trigger.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

gcloud alpha functions deploy helloworld --bucket <your-bucket-name> --trigger-http
1. Clone this repository:

## Test
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/functions/module

gcloud alpha functions call helloworld
1. Create a Cloud Storage Bucket to stage our deployment:

Running the above command should print "Hello World!".
gsutil mb gs://[YOUR_BUCKET_NAME]

You can also use `curl` to trigger the function:
* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

curl -X POST https://<your-project-region>.<your-project-id>.cloudfunctions.net/helloworld
1. Deploy the `helloworld` function with an HTTP trigger:

gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the `helloworld` function:

gcloud alpha functions call helloworld

You should see something like this in your console:

executionId: abcd1234-0
result: Hello World!

[quickstart]: https://cloud.google.com/functions/quickstart
38 changes: 31 additions & 7 deletions functions/log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,40 @@ View the [documentation][docs] or the [source code][code].
[docs]: https://cloud.google.com/functions/walkthroughs
[code]: index.js

## Deploy
## Deploy and Test

This example deploys the function with an HTTP trigger.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

gcloud alpha functions deploy helloworld --bucket <your-bucket-name> --trigger-http
1. Clone this repository:

## Test
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/functions/module

gcloud alpha functions call helloworld
1. Create a Cloud Storage Bucket to stage our deployment:

You can also use `curl` to trigger the function:
gsutil mb gs://[YOUR_BUCKET_NAME]

curl -X POST https://<your-project-region>.<your-project-id>.cloudfunctions.net/helloworld
* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the `helloworld` function with an HTTP trigger:

gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the `helloworld` function:

gcloud alpha functions call helloworld

1. Check the logs for the `helloworld` function:

gcloud alpha functions get-logs helloworld

You should see something like this in your console:

D ... User function triggered, starting execution
I ... I am a log entry!
D ... Execution took 1 ms, user function completed successfully

[quickstart]: https://cloud.google.com/functions/quickstart
39 changes: 32 additions & 7 deletions functions/log2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,41 @@ View the [documentation][docs] or the [source code][code].
[docs]: https://cloud.google.com/functions/walkthroughs
[code]: index.js

## Deploy
## Deploy and Test

This example deploys the function with an HTTP trigger.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

gcloud alpha functions deploy helloworld --bucket <your-bucket-name> --trigger-http
1. Clone this repository:

## Test
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/functions/module

gcloud alpha functions call helloworld
1. Create a Cloud Storage Bucket to stage our deployment:

You can also use `curl` to trigger the function:
gsutil mb gs://[YOUR_BUCKET_NAME]

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the `helloworld` function with an HTTP trigger:

gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the `helloworld` function:

gcloud alpha functions call helloworld --data '{"message":"Hello World!"}'

1. Check the logs for the `helloworld` function:

gcloud alpha functions get-logs helloworld

You should see something like this in your console:

D ... User function triggered, starting execution
I ... My GCF Function: Hello World!
D ... Execution took 1 ms, user function completed successfully

[quickstart]: https://cloud.google.com/functions/quickstart

curl -X POST https://<your-project-region>.<your-project-id>.cloudfunctions.net/helloworld
48 changes: 41 additions & 7 deletions functions/message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,50 @@ View the [documentation][docs] or the [source code][code].
[docs]: https://cloud.google.com/functions/writing
[code]: index.js

## Deploy
## Deploy and Test

This example deploys the function with an HTTP trigger.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

gcloud alpha functions deploy helloworld --bucket <your-bucket-name> --trigger-http
1. Clone this repository:

## Test
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/functions/module

gcloud alpha functions call helloworld
1. Create a Cloud Storage Bucket to stage our deployment:

You can also use `curl` to trigger the function:
gsutil mb gs://[YOUR_BUCKET_NAME]

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Deploy the `helloworld` function with an HTTP trigger:

gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the `helloworld` function with some data:

gcloud alpha functions call helloworld --data '{"message":"keyboard cat"}'

1. Call the `helloworld` function without any data:

gcloud alpha functions call helloworld

You should see something like this in your console:

executionId: abcd1234-0
result: Hello World!

1. Check the logs for the `helloworld` function:

gcloud alpha functions get-logs helloworld

You should see something like this in your console:

D ... User function triggered, starting execution
I ... keyboard cat
D ... Execution took 1 ms, user function completed successfully

[quickstart]: https://cloud.google.com/functions/quickstart

curl -X POST https://<your-project-region>.<your-project-id>.cloudfunctions.net/helloworld --data '{"message":"cat"}'
33 changes: 25 additions & 8 deletions functions/module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,35 @@ View the [documentation][docs] or the [source code][code].
[docs]: https://cloud.google.com/functions/writing
[code]: index.js

## Deploy
## Deploy and Test

This example deploys the function with an HTTP trigger.
1. Follow the [Cloud Functions quickstart guide][quickstart] to setup Cloud
Functions for your project.

gcloud alpha functions deploy helloworld --bucket <your-bucket-name> --trigger-http
1. Clone this repository:

## Test
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/functions/module

gcloud alpha functions call helloworld
1. Create a Cloud Storage Bucket to stage our deployment:

Running the above command should print "Hello World!".
gsutil mb gs://[YOUR_BUCKET_NAME]

You can also use `curl` to trigger the function:
* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

curl -X POST https://<your-project-region>.<your-project-id>.cloudfunctions.net/helloworld
1. Deploy the `helloworld` function with an HTTP trigger:

gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http

* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket.

1. Call the `helloworld` function:

gcloud alpha functions call helloworld

You should see something like this in your console:

executionId: abcd1234-0
result: Hello World!

[quickstart]: https://cloud.google.com/functions/quickstart
2 changes: 2 additions & 0 deletions functions/ocr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
config.json
Loading