From 982dfae3e27f6e4eaf08153f45e1ca8c2862ff7d Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Mon, 29 Aug 2016 16:13:19 -0700 Subject: [PATCH] Auto-generate sample READMEs. --- bigquery/README.md | 88 ++++++++---------- bigquery/samples.json | 26 ++++++ datastore/README.md | 46 +++++----- datastore/samples.json | 27 ++++++ language/README.md | 21 +++-- language/analyze.js | 2 +- language/samples.json | 12 +++ logging/README.md | 62 ++++++------- logging/logs.js | 2 +- logging/samples.json | 25 ++++++ logging/sinks.js | 2 +- monitoring/README.md | 38 ++++---- monitoring/samples.json | 27 ++++++ package.json | 1 + prediction/README.md | 20 ++--- prediction/samples.json | 15 ++++ pubsub/README.md | 46 +++++----- pubsub/samples.json | 26 ++++++ pubsub/subscriptions.js | 2 +- resource/README.md | 10 +-- resource/projects.js | 2 +- resource/samples.json | 12 +++ scripts/gen-readmes | 54 ++++++++++++ speech/README.md | 42 ++++----- speech/recognize_streaming.js | 2 + speech/samples.json | 25 ++++++ storage/README.md | 162 ++++++++++++++++------------------ storage/acl.js | 2 +- storage/buckets.js | 2 +- storage/files.js | 2 +- storage/samples.json | 47 ++++++++++ storage/transfer.js | 8 +- translate/README.md | 23 +++-- translate/samples.json | 12 +++ translate/translate.js | 2 +- vision/README.md | 87 ++++++++---------- vision/samples.json | 43 +++++++++ vision/textDetection.js | 3 + 38 files changed, 671 insertions(+), 357 deletions(-) create mode 100644 bigquery/samples.json create mode 100644 datastore/samples.json create mode 100644 language/samples.json create mode 100644 logging/samples.json create mode 100644 monitoring/samples.json create mode 100644 prediction/samples.json create mode 100644 pubsub/samples.json create mode 100644 resource/samples.json create mode 100755 scripts/gen-readmes create mode 100644 speech/samples.json create mode 100644 storage/samples.json create mode 100644 translate/samples.json create mode 100644 vision/samples.json diff --git a/bigquery/README.md b/bigquery/README.md index 0192714938..1825b57c03 100644 --- a/bigquery/README.md +++ b/bigquery/README.md @@ -1,8 +1,8 @@ Google Cloud Platform logo -# Google BigQuery Node.js Samples +# BigQuery Node.js Samples -[BigQuery][bigquery_docs] is Google's fully managed, petabyte scale, low cost +[BigQuery][bigquery_docs] is Google's fully managed, petabyte scale, low cost analytics data warehouse. [bigquery_docs]: https://cloud.google.com/bigquery/docs/ @@ -11,10 +11,9 @@ analytics data warehouse. * [Setup](#setup) * [Samples](#samples) - * [Create A Simple Application With the API](#create-a-simple-application-with-the-api) * [Datasets](#datasets) - * [Queries](#queries) * [Tables](#tables) + * [Queries](#queries) ## Setup @@ -28,20 +27,9 @@ analytics data warehouse. ## Samples -### Create A Simple Application With the API - -View the [documentation][basics_docs] or the [source code][basics_code]. - -__Run the sample:__ - - node getting_started - -[basics_docs]: https://cloud.google.com/bigquery/create-simple-app-api -[basics_code]: getting_started.js - ### Datasets -View the [documentation][datasets_docs] or the [source code][datasets_code]. +View the [documentation][datasets_0_docs] or the [source code][datasets_0_code]. __Usage:__ `node datasets --help` @@ -54,8 +42,8 @@ Commands: Options: --projectId, -p Optionally specify the project ID to use. - [string] - --help Show help [boolean] + [string] [default: "nodejs-docs-samples"] + --help Show help [boolean] Examples: node datasets create my_dataset Create a new dataset named "my_dataset". @@ -70,38 +58,12 @@ Examples: For more information, see https://cloud.google.com/bigquery/docs ``` -[datasets_docs]: https://cloud.google.com/bigquery/docs -[datasets_code]: datasets.js - -### Queries - -View the [documentation][queries_docs] or the [source code][queries_code]. - -__Usage:__ `node queries --help` - -``` -Commands: - sync Run a synchronous query. - async Start an asynchronous query. - poll Get the status of a job. - -Options: - --help Show help [boolean] - -Examples: - node queries sync "SELECT * FROM publicdata:samples.natality LIMIT 5;" - node queries async "SELECT * FROM publicdata:samples.natality LIMIT 5;" - node queries poll 12345 - -For more information, see https://cloud.google.com/bigquery/docs -``` - -[queries_docs]: https://cloud.google.com/bigquery/docs -[queries_code]: queries.js +[datasets_0_docs]: https://cloud.google.com/bigquery/docs +[datasets_0_code]: datasets.js ### Tables -View the [documentation][tables_docs] or the [source code][tables_code]. +View the [documentation][tables_1_docs] or the [source code][tables_1_code]. __Usage:__ `node tables --help` @@ -132,5 +94,33 @@ Examples: For more information, see https://cloud.google.com/bigquery/docs ``` -[tables_docs]: https://cloud.google.com/bigquery/docs -[tables_code]: tables.js +[tables_1_docs]: https://cloud.google.com/bigquery/docs +[tables_1_code]: tables.js + +### Queries + +View the [documentation][queries_2_docs] or the [source code][queries_2_code]. + +__Usage:__ `node queries --help` + +``` +Commands: + sync Run a synchronous query. + async Start an asynchronous query. + poll Get the status of a job. + +Options: + --help Show help [boolean] + +Examples: + node queries sync "SELECT * FROM + publicdata:samples.natality LIMIT 5;" + node queries async "SELECT * FROM + publicdata:samples.natality LIMIT 5;" + node queries poll 12345 + +For more information, see https://cloud.google.com/bigquery/docs +``` + +[queries_2_docs]: https://cloud.google.com/bigquery/docs +[queries_2_code]: queries.js diff --git a/bigquery/samples.json b/bigquery/samples.json new file mode 100644 index 0000000000..b3e6f3394a --- /dev/null +++ b/bigquery/samples.json @@ -0,0 +1,26 @@ +{ + "id": "bigquery", + "samples": [ + { + "id": "datasets", + "name": "Datasets", + "file": "datasets.js", + "docs_link": "https://cloud.google.com/bigquery/docs", + "usage": "node datasets --help" + }, + { + "id": "tables", + "name": "Tables", + "file": "tables.js", + "docs_link": "https://cloud.google.com/bigquery/docs", + "usage": "node tables --help" + }, + { + "id": "queries", + "name": "Queries", + "file": "queries.js", + "docs_link": "https://cloud.google.com/bigquery/docs", + "usage": "node queries --help" + } + ] +} diff --git a/datastore/README.md b/datastore/README.md index 5c34edc732..726474c53d 100644 --- a/datastore/README.md +++ b/datastore/README.md @@ -1,6 +1,6 @@ Google Cloud Platform logo -# Google Cloud Datastore Node.js Samples +# Datastore Node.js Samples [Cloud Datastore][datastore_docs] is a NoSQL document database built for automatic scaling, high performance, and ease of application development. @@ -11,7 +11,7 @@ automatic scaling, high performance, and ease of application development. * [Setup](#setup) * [Samples](#samples) - * [Getting started with Google Cloud Datastore API](#getting-started-with-google-cloud-datastore-api) + * [Tasks](#tasks) * [Concepts](#concepts) * [Errors and Error Handling](#errors-and-error-handling) @@ -27,39 +27,33 @@ automatic scaling, high performance, and ease of application development. ## Samples -### Getting started with Google Cloud Datastore API +### Tasks -View the [documentation][tasks_docs] or the [source code][tasks_code]. +View the [documentation][tasks_0_docs] or the [source code][tasks_0_code]. -__Run the sample:__ +__Usage:__ `node tasks --help` -Usage: `node tasks [args]...` +``` +Usage: -Print usage: + new Adds a task with a description + done Marks a task as done + list Lists all tasks by creation time + delete Deletes a task +``` - node tasks - -Example: - - node tasks list - -[tasks_docs]: https://cloud.google.com/datastore/docs/datastore-api-tutorial -[tasks_code]: tasks.js +[tasks_0_docs]: https://cloud.google.com/datastore/docs/datastore-api-tutorial +[tasks_0_code]: tasks.js ### Concepts -View the [documentation][concepts_docs] or the [source code][concepts_code]. - -[concepts_docs]: https://cloud.google.com/datastore/docs/concepts/entities -[concepts_code]: concepts.js +View the [documentation][concepts_1_docs] or the [source code][concepts_1_code].[concepts_1_docs]: https://cloud.google.com/datastore/docs/concepts/entities +[concepts_1_code]: concepts.js ### Errors and Error Handling -View the [documentation][error_docs] or the [source code][error_code]. - -__Run the sample:__ - - node error +View the [documentation][error_2_docs] or the [source code][error_2_code]. -[error_docs]: https://cloud.google.com/datastore/docs/concepts/errors -[error_code]: error.js +__Usage:__ `node error` +[error_2_docs]: https://cloud.google.com/datastore/docs/concepts/errors +[error_2_code]: error.js diff --git a/datastore/samples.json b/datastore/samples.json new file mode 100644 index 0000000000..de32a4ab76 --- /dev/null +++ b/datastore/samples.json @@ -0,0 +1,27 @@ +{ + "id": "datastore", + "samples": [ + { + "id": "tasks", + "name": "Tasks", + "file": "tasks.js", + "docs_link": "https://cloud.google.com/datastore/docs/datastore-api-tutorial", + "usage": "node tasks --help" + }, + { + "id": "concepts", + "name": "Concepts", + "file": "concepts.js", + "docs_link": "https://cloud.google.com/datastore/docs/concepts/entities" + }, + { + "id": "error", + "name": "Errors and Error Handling", + "file": "error.js", + "docs_link": "https://cloud.google.com/datastore/docs/concepts/errors", + "usage": { + "text": "node error" + } + } + ] +} diff --git a/language/README.md b/language/README.md index d7a0fddadd..22641249b2 100644 --- a/language/README.md +++ b/language/README.md @@ -29,7 +29,7 @@ Learning API. ### Analyze -View the [documentation][analyze_docs] or the [source code][analyze_code]. +View the [documentation][analyze_0_docs] or the [source code][analyze_0_code]. __Usage:__ `node analyze --help` @@ -43,20 +43,23 @@ Commands: syntaxFromFile Detect the syntax of text in a GCS file. Options: - --language, -l The language of the text. [string] - --type, -t Type of text [string] [choices: "text", "html"] [default: "text"] - --help Show help [boolean] + --language, -l The language of the text. [string] + --type, -t Type of text. [string] [choices: "text", "html"] [default: "text"] + --help Show help [boolean] Examples: - node analyze sentimentFromString "President Obama is speaking at the White House." + node analyze sentimentFromString "President Obama is + speaking at the White House." node analyze sentimentFromFile my-bucket file.txt - node analyze entitiesFromString "

President Obama is speaking at the White House.

" -t html + node analyze entitiesFromString "

President Obama is + speaking at the White House.

" -t html node analyze entitiesFromFile my-bucket file.txt - node analyze syntaxFromString "President Obama is speaking at the White House." + node analyze syntaxFromString "President Obama is speaking + at the White House." node analyze syntaxFromFile my-bucket es_file.txt -l es For more information, see https://cloud.google.com/natural-language/docs ``` -[analyze_docs]: https://cloud.google.com/natural-language/docs -[analyze_code]: analyze.js +[analyze_0_docs]: https://cloud.google.com/natural-language/docs/ +[analyze_0_code]: analyze.js diff --git a/language/analyze.js b/language/analyze.js index 93a6642f39..27bb62b4e6 100644 --- a/language/analyze.js +++ b/language/analyze.js @@ -296,7 +296,7 @@ cli .example('node $0 entitiesFromFile my-bucket file.txt', '') .example('node $0 syntaxFromString "President Obama is speaking at the White House."', '') .example('node $0 syntaxFromFile my-bucket es_file.txt -l es', '') - .wrap(100) + .wrap(120) .recommendCommands() .epilogue('For more information, see https://cloud.google.com/natural-language/docs'); diff --git a/language/samples.json b/language/samples.json new file mode 100644 index 0000000000..edf5bc4065 --- /dev/null +++ b/language/samples.json @@ -0,0 +1,12 @@ +{ + "id": "nl", + "samples": [ + { + "id": "analyze", + "name": "Analyze", + "file": "analyze.js", + "docs_link": "https://cloud.google.com/natural-language/docs/", + "usage": "node analyze --help" + } + ] +} diff --git a/logging/README.md b/logging/README.md index 249281de6d..4b05a4cb45 100644 --- a/logging/README.md +++ b/logging/README.md @@ -1,6 +1,6 @@ Google Cloud Platform logo -# Stackdriver Logging Node.js samples +# Stackdriver Logging Node.js Samples [Stackdriver Logging][logging_docs] allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon @@ -15,7 +15,6 @@ Web Services. * [Logs](#logs) * [Sinks](#sinks) * [Error Reporting on Compute Engine](#error-reporting-on-compute-engine) - * [Logging to Google Cloud with Winston](https://github.com/GoogleCloudPlatform/winston-gae) ## Setup @@ -31,37 +30,37 @@ Web Services. ### Logs -View the [documentation][logs_docs] or the [source code][logs_code]. +View the [documentation][logs_0_docs] or the [source code][logs_0_code]. __Usage:__ `node logs --help` ``` Commands: - list List log entries in the authenticated project. + list List log entries. write Write a log entry. delete Delete a Log. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: - node logs list List all log entires. - node logs list -f "severity = ERROR" -s List up to 2 error entries, sorted by - "timestamp" -l 2 timestamp ascending. - node logs write my-log Write a log entry. - '{"type":"gae_app","labels":{"module_id":"default" - }}' '{"message":"Hello World!"}' - node logs delete my-log Delete "my-log". + node logs list List all log entries. + node logs list -f "severity = ERROR" -s "timestamp" -l 2 List up to 2 error entries, sorted by timestamp + ascending. + node logs write my-log Write a log entry. + '{"type":"gae_app","labels":{"module_id":"default"}}' + '{"message":"Hello World!"}' + node logs delete my-log Delete "my-log". For more information, see https://cloud.google.com/logging/docs ``` -[logs_docs]: https://cloud.google.com/logging/docs -[logs_code]: logs.js +[logs_0_docs]: https://cloud.google.com/logging/docs +[logs_0_code]: logs.js ### Sinks -View the [documentation][sinks_docs] or the [source code][sinks_code]. +View the [documentation][sinks_1_docs] or the [source code][sinks_1_code]. __Usage:__ `node sinks --help` @@ -74,30 +73,27 @@ Commands: delete Delete the specified sink. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: - node sinks create my-sink my-bucket --type bucket Create a new sink named "my-sink" that exports - logs to a Cloud Storage bucket. - node sinks create my-sink my-dataset --type Create a new sink named "my-sink" that exports - dataset logs to a BigQuery dataset. - node sinks create my-sink my-topic --type topic Create a new sink named "my-sink" that exports - logs to a Cloud Pub/Sub topic. - node sinks get my-sink Get the metadata for "my-sink". - node sinks list List all sinks in the authenticated project. - node sinks update my-sink '{"filter":"severity > Update the specified sink. - ALERT"}' - node sinks delete my-sink Delete "my-sink". + node sinks create my-sink my-bucket --type bucket Create a new sink named "my-sink" that exports logs to a + Cloud Storage bucket. + node sinks create my-sink my-dataset --type dataset Create a new sink named "my-sink" that exports logs to a + BigQuery dataset. + node sinks create my-sink my-topic --type topic Create a new sink named "my-sink" that exports logs to a + Cloud Pub/Sub topic. + node sinks get my-sink Get the metadata for "my-sink". + node sinks list List all sinks in the authenticated project. + node sinks update my-sink '{"filter":"severity > ALERT"}' Update the specified sink. + node sinks delete my-sink Delete "my-sink". For more information, see https://cloud.google.com/logging/docs ``` -[sinks_docs]: https://cloud.google.com/logging/docs -[sinks_code]: sinks.js +[sinks_1_docs]: https://cloud.google.com/logging/docs +[sinks_1_code]: sinks.js ### Error Reporting on Compute Engine -View the [documentation][error_docs] or the [source code][error_code]. - -[error_docs]: https://cloud.google.com/error-reporting/docs/setup/compute-engine -[error_code]: fluent.js +View the [documentation][fluent_2_docs] or the [source code][fluent_2_code].[fluent_2_docs]: https://cloud.google.com/error-reporting/docs/setup/compute-engine +[fluent_2_code]: fluent.js diff --git a/logging/logs.js b/logging/logs.js index 1fded8498d..9c8255400a 100644 --- a/logging/logs.js +++ b/logging/logs.js @@ -172,7 +172,7 @@ cli .example('node $0 list -f "severity = ERROR" -s "timestamp" -l 2', 'List up to 2 error entries, sorted by timestamp ascending.') .example('node $0 write my-log \'{"type":"gae_app","labels":{"module_id":"default"}}\' \'{"message":"Hello World!"}\'', 'Write a log entry.') .example('node $0 delete my-log', 'Delete "my-log".') - .wrap(100) + .wrap(120) .recommendCommands() .epilogue('For more information, see https://cloud.google.com/logging/docs'); diff --git a/logging/samples.json b/logging/samples.json new file mode 100644 index 0000000000..261ca2825f --- /dev/null +++ b/logging/samples.json @@ -0,0 +1,25 @@ +{ + "id": "logging", + "samples": [ + { + "id": "logs", + "name": "Logs", + "file": "logs.js", + "docs_link": "https://cloud.google.com/logging/docs", + "usage": "node logs --help" + }, + { + "id": "sinks", + "name": "Sinks", + "file": "sinks.js", + "docs_link": "https://cloud.google.com/logging/docs", + "usage": "node sinks --help" + }, + { + "id": "fluent", + "name": "Error Reporting on Compute Engine", + "file": "fluent.js", + "docs_link": "https://cloud.google.com/error-reporting/docs/setup/compute-engine" + } + ] +} diff --git a/logging/sinks.js b/logging/sinks.js index f739f3edec..d4bdf72b4c 100644 --- a/logging/sinks.js +++ b/logging/sinks.js @@ -208,7 +208,7 @@ cli .example('node $0 list', 'List all sinks in the authenticated project.') .example('node $0 update my-sink \'{"filter":"severity > ALERT"}\'', 'Update the specified sink.') .example('node $0 delete my-sink', 'Delete "my-sink".') - .wrap(100) + .wrap(120) .recommendCommands() .epilogue('For more information, see https://cloud.google.com/logging/docs'); diff --git a/monitoring/README.md b/monitoring/README.md index 445f9ede86..3527f0486c 100644 --- a/monitoring/README.md +++ b/monitoring/README.md @@ -1,6 +1,6 @@ Google Cloud Platform logo -# Stackdriver Monitoring Node.js samples +# Stackdriver Monitoring Node.js Samples [Stackdriver Monitoring][monitoring_docs] collects metrics, events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), hosted uptime probes, @@ -28,30 +28,34 @@ including Cassandra, Nginx, Apache Web Server, Elasticsearch and many others. ## Samples -### List resources +### Listing resources -`list_resources.js` is a command-line program to demonstrate connecting to the Google -Monitoring API to retrieve API data. +View the [documentation][list_0_docs] or the [source code][list_0_code]. -View the [documentation][list_docs] or the [source code][list_code]. +`list_resources.js` is a command-line program to demonstrate connecting to the +Google Monitoring API to retrieve API data. -__Run the sample:__ +__Usage:__ `node list_resources ` - node list_resources +``` +node list_resources my-cool-project +``` -[list_docs]: https://cloud.google.com/monitoring/demos/#hello-world -[list_code]: list_resources.js +[list_0_docs]: https://cloud.google.com/monitoring/demos/#hello-world +[list_0_code]: list_resources.js -### Custom metric +### Custom metrics -`create_custom_metric.js` demonstrates how to create a custom metric, write a timeseries value to it, -and read it back. +View the [documentation][metrics_1_docs] or the [source code][metrics_1_code]. -View the [documentation][custom_docs] or the [source code][custom_code]. +`create_custom_metric.js` demonstrates how to create a custom metric, write a +timeseries value to it, and read it back. -__Run the sample:__ +__Usage:__ `node create_custom_metric ` - node create_custom_metric +``` +node create_custom_metric my-cool-project +``` -[custom_docs]: https://cloud.google.com/monitoring/demos/#custom_metrics -[custom_code]: create_custom_metric.js +[metrics_1_docs]: https://cloud.google.com/monitoring/demos/#custom_metrics +[metrics_1_code]: create_custom_metric.js diff --git a/monitoring/samples.json b/monitoring/samples.json new file mode 100644 index 0000000000..3318ade409 --- /dev/null +++ b/monitoring/samples.json @@ -0,0 +1,27 @@ +{ + "id": "monitoring", + "samples": [ + { + "id": "list", + "name": "Listing resources", + "file": "list_resources.js", + "docs_link": "https://cloud.google.com/monitoring/demos/#hello-world", + "description": "`list_resources.js` is a command-line program to demonstrate connecting to the\nGoogle Monitoring API to retrieve API data.", + "usage": { + "text": "node list_resources " + }, + "help": "node list_resources my-cool-project" + }, + { + "id": "metrics", + "name": "Custom metrics", + "file": "create_custom_metric.js", + "docs_link": "https://cloud.google.com/monitoring/demos/#custom_metrics", + "description": "`create_custom_metric.js` demonstrates how to create a custom metric, write a\ntimeseries value to it, and read it back.", + "usage": { + "text": "node create_custom_metric " + }, + "help": "node create_custom_metric my-cool-project" + } + ] +} diff --git a/package.json b/package.json index 3e4a8fc8d4..a31bdde796 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ }, "scripts": { "lint": "semistandard", + "gen-readmes": "./scripts/gen-readmes", "pretest": "npm run lint && ./scripts/clean", "mocha": "mocha -R spec -t 120000 --require intelli-espower-loader ./test/_setup.js ./test/*.test.js '{*,appengine/*,functions/*}/test/*.test.js'", "test": "npm run mocha", diff --git a/prediction/README.md b/prediction/README.md index 7afcf0d9f5..30b45c637b 100644 --- a/prediction/README.md +++ b/prediction/README.md @@ -11,7 +11,7 @@ Machine Learning models. * [Setup](#setup) * [Samples](#samples) - * [Hosted Models](#hosted-models) + * [Models](#models) ## Setup @@ -25,17 +25,15 @@ Machine Learning models. ## Samples -### Hosted Models +### Models -View the [documentation][hostedmodels_docs] or the [source code][hostedmodels_code]. +View the [documentation][models_0_docs] or the [source code][models_0_code]. -__Run the sample:__ +__Usage:__ `node hostedmodels ` -Usage: `node hostedmodels "some phrase"` +``` +node hostedmodels "Hello world" +``` -Example: - - node hostedmodels "Hello world" - -[hostedmodels_docs]: https://cloud.google.com/prediction/docs/developer-guide#predictionfromappengine -[hostedmodels_code]: hostedmodels.js +[models_0_docs]: https://cloud.google.com/prediction/docs/developer-guide#predictionfromappengine +[models_0_code]: hostedmodels.js diff --git a/prediction/samples.json b/prediction/samples.json new file mode 100644 index 0000000000..95addc6faf --- /dev/null +++ b/prediction/samples.json @@ -0,0 +1,15 @@ +{ + "id": "prediction", + "samples": [ + { + "id": "models", + "name": "Models", + "file": "hostedmodels.js", + "docs_link": "https://cloud.google.com/prediction/docs/developer-guide#predictionfromappengine", + "usage": { + "text": "node hostedmodels " + }, + "help": "node hostedmodels \"Hello world\"" + } + ] +} diff --git a/pubsub/README.md b/pubsub/README.md index a4c6d6e925..857a8aacdc 100644 --- a/pubsub/README.md +++ b/pubsub/README.md @@ -13,7 +13,7 @@ allows you to send and receive messages between independent applications. * [Samples](#samples) * [Topics](#topics) * [Subscriptions](#subscriptions) - * [IAM](#iam) + * [IAM (Identity and Access Management)](#iam-identity-and-access-management) ## Setup @@ -29,7 +29,7 @@ allows you to send and receive messages between independent applications. ### Topics -View the [documentation][topics_docs] or the [source code][topics_code]. +View the [documentation][topics_0_docs] or the [source code][topics_0_code]. __Usage:__ `node topics --help` @@ -53,12 +53,12 @@ Examples: For more information, see https://cloud.google.com/pubsub/docs ``` -[topics_docs]: https://cloud.google.com/pubsub/publisher -[topics_code]: topics.js +[topics_0_docs]: https://cloud.google.com/pubsub/publisher +[topics_0_code]: topics.js ### Subscriptions -View the [documentation][subscriptions_docs] or the [source code][subscriptions_code]. +View the [documentation][subscriptions_1_docs] or the [source code][subscriptions_1_code]. __Usage:__ `node subscriptions --help` @@ -70,7 +70,7 @@ Commands: delete Delete the specified subscription. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: node subscriptions create my-topic my-subscription Create a new subscription. @@ -82,12 +82,12 @@ Examples: For more information, see https://cloud.google.com/pubsub/docs ``` -[subscriptions_docs]: https://cloud.google.com/pubsub/subscriber -[subscriptions_code]: subscriptions.js +[subscriptions_1_docs]: https://cloud.google.com/pubsub/subscriber +[subscriptions_1_code]: subscriptions.js -### IAM +### IAM (Identity and Access Management) -View the [documentation][iam_docs] or the [source code][iam_code]. +View the [documentation][iam_2_docs] or the [source code][iam_2_code]. __Usage:__ `node iam --help` @@ -96,24 +96,24 @@ Usage: node iam RESOURCE COMMAND [ARGS...] Resources: - topics - subscriptions + topics + subscriptions Commands: - get NAME - set NAME - test NAME + get NAME + set NAME + test NAME Examples: - node iam topics get my-topic - node iam topics set my-topic - node iam topics test my-topic - node iam subscriptions get my-subscription - node iam subscriptions set my-subscription - node iam subscriptions test my-subscription + node iam topics get my-topic + node iam topics set my-topic + node iam topics test my-topic + node iam subscriptions get my-subscription + node iam subscriptions set my-subscription + node iam subscriptions test my-subscription ``` -[iam_docs]: https://cloud.google.com/pubsub/access_control -[iam_code]: iam.js +[iam_2_docs]: https://cloud.google.com/pubsub/docs +[iam_2_code]: iam.js diff --git a/pubsub/samples.json b/pubsub/samples.json new file mode 100644 index 0000000000..68829318ef --- /dev/null +++ b/pubsub/samples.json @@ -0,0 +1,26 @@ +{ + "id": "pubsub", + "samples": [ + { + "id": "topics", + "name": "Topics", + "file": "topics.js", + "docs_link": "https://cloud.google.com/pubsub/publisher", + "usage": "node topics --help" + }, + { + "id": "subscriptions", + "name": "Subscriptions", + "file": "subscriptions.js", + "docs_link": "https://cloud.google.com/pubsub/subscriber", + "usage": "node subscriptions --help" + }, + { + "id": "iam", + "name": "IAM (Identity and Access Management)", + "file": "iam.js", + "docs_link": "https://cloud.google.com/pubsub/docs", + "usage": "node iam --help" + } + ] +} diff --git a/pubsub/subscriptions.js b/pubsub/subscriptions.js index 42c883d8d6..a87a2d3a0e 100644 --- a/pubsub/subscriptions.js +++ b/pubsub/subscriptions.js @@ -191,7 +191,7 @@ cli .example('node $0 pull my-subscription', 'Pull messages from "my-subscription".') .example('node $0 list', 'List all subscriptions.') .example('node $0 list my-topic', 'List subscriptions to topic "my-topic".') - .wrap(100) + .wrap(120) .recommendCommands() .epilogue('For more information, see https://cloud.google.com/pubsub/docs'); diff --git a/resource/README.md b/resource/README.md index 9a75a28b28..2ed4739184 100644 --- a/resource/README.md +++ b/resource/README.md @@ -1,6 +1,6 @@ Google Cloud Platform logo -# Google Cloud Resource Manager Node.js Samples +# Google Cloud Resource Manager API Node.js Samples Google Cloud Platform provides container resources such as Organizations and Projects, that allow you to group and hierarchically organize other Cloud @@ -31,7 +31,7 @@ programmatically manage these container resources. ### Projects -View the [documentation][projects_docs] or the [source code][projects_code]. +View the [documentation][projects_0_docs] or the [source code][projects_0_code]. __Usage:__ `node projects --help` @@ -40,7 +40,7 @@ Commands: list List all projects the authenticated user has access to. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: node projects list List projects. @@ -48,5 +48,5 @@ Examples: For more information, see https://cloud.google.com/resource-manager/docs/ ``` -[projects_docs]: https://cloud.google.com/resource-manager/docs/ -[projects_code]: projects.js +[projects_0_docs]: https://cloud.google.com/resource-manager/docs/ +[projects_0_code]: projects.js diff --git a/resource/projects.js b/resource/projects.js index 6d6b17d01a..9bbbcf51ff 100644 --- a/resource/projects.js +++ b/resource/projects.js @@ -63,7 +63,7 @@ cli program.listProjects(makeHandler(true, 'id')); }) .example('node $0 list', 'List projects.') - .wrap(80) + .wrap(120) .recommendCommands() .epilogue('For more information, see https://cloud.google.com/resource-manager/docs/'); diff --git a/resource/samples.json b/resource/samples.json new file mode 100644 index 0000000000..6a7469264d --- /dev/null +++ b/resource/samples.json @@ -0,0 +1,12 @@ +{ + "id": "resource", + "samples": [ + { + "id": "projects", + "name": "Projects", + "file": "projects.js", + "docs_link": "https://cloud.google.com/resource-manager/docs/", + "usage": "node projects --help" + } + ] +} diff --git a/scripts/gen-readmes b/scripts/gen-readmes new file mode 100755 index 0000000000..2865d5b596 --- /dev/null +++ b/scripts/gen-readmes @@ -0,0 +1,54 @@ +#!/usr/bin/env node + +// Copyright 2016, Google, Inc. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var async = require('async'); +var path = require('path'); + +require('shelljs/global'); + +// Generate README.md files, in up to 5 directories at a time +var queue = async.queue(function (directory, callback) { + generateForDirectory(directory, callback); +}, 5); + +queue.push('bigquery'); +queue.push('datastore'); +queue.push('language'); +queue.push('logging'); +queue.push('monitoring'); +queue.push('prediction'); +queue.push('pubsub'); +queue.push('resource'); +queue.push('speech'); +queue.push('storage'); +queue.push('translate'); +queue.push('vision'); + +/** + * Generate the README.md file within a single directory. + * + * @param {string} directory The name of the directory in which to generate the file. + * @param {function} callback The callback function. + */ +function generateForDirectory(directory, callback) { + console.log(directory + '...generating README.md'); + exec('samples generate', { + async: true, + cwd: path.join(__dirname, '../', directory) + }, function (err) { + console.log(directory + '...done'); + callback(err); + }); +} diff --git a/speech/README.md b/speech/README.md index dcc90673ae..7f87a861fd 100644 --- a/speech/README.md +++ b/speech/README.md @@ -2,19 +2,17 @@ # Google Cloud Speech API Node.js Samples -[Sign up for the Alpha][speech_signup]. - The [Cloud Speech API][speech_docs] enables easy integration of Google speech recognition technologies into developer applications. -[speech_signup]: https://services.google.com/fb/forms/speech-api-alpha/ [speech_docs]: https://cloud.google.com/speech/ ## Table of Contents * [Setup](#setup) * [Samples](#samples) - * [Recognition](#recognition) + * [Sync Recognize](#sync-recognize) + * [Streaming Recognition](#streaming-recognition) ## Setup @@ -28,32 +26,28 @@ recognition technologies into developer applications. ## Samples -### Recognition - -View the [documentation][recognition_docs] or the [source code][recognition_code]. - -__Run the sample:__ - -Usage: `node recognize ` - -Example: +### Sync Recognize - node recognize resources/audio.raw +View the [documentation][recognize_0_docs] or the [source code][recognize_0_code]. -[recognition_docs]: https://cloud.google.com/speech/ -[recognition_code]: recognize.js +__Usage:__ `node recognize ` -### Recognition (Streaming) +``` +node recognize resources/audio.raw +``` -View the [documentation][recognition_streaming_docs] or the [source code][recognition_streaming_code]. +[recognize_0_docs]: https://cloud.google.com/speech/docs/ +[recognize_0_code]: recognize.js -__Run the sample:__ +### Streaming Recognition -Usage: `node recognize_streaming ` +View the [documentation][recognize_1_docs] or the [source code][recognize_1_code]. -Example: +__Usage:__ `node recognize_streaming ` - node recognize_streaming resources/audio.raw +``` +node recognize_streaming resources/audio.raw +``` -[recognition_streaming_docs]: https://cloud.google.com/speech/ -[recognition_streaming_code]: recognize_streaming.js +[recognize_1_docs]: https://cloud.google.com/speech/docs/ +[recognize_1_code]: recognize_streaming.js diff --git a/speech/recognize_streaming.js b/speech/recognize_streaming.js index cf4afd59ad..25f41bb177 100644 --- a/speech/recognize_streaming.js +++ b/speech/recognize_streaming.js @@ -13,6 +13,7 @@ 'use strict'; +// [START all] var async = require('async'); var fs = require('fs'); var path = require('path'); @@ -123,5 +124,6 @@ if (module === require.main) { main(inputFile, host || 'speech.googleapis.com', console.log); } // [END run_application] +// [END all] exports.main = main; diff --git a/speech/samples.json b/speech/samples.json new file mode 100644 index 0000000000..c6f9579093 --- /dev/null +++ b/speech/samples.json @@ -0,0 +1,25 @@ +{ + "id": "speech", + "samples": [ + { + "id": "recognize", + "name": "Sync Recognize", + "file": "recognize.js", + "docs_link": "https://cloud.google.com/speech/docs/", + "usage": { + "text": "node recognize " + }, + "help": "node recognize resources/audio.raw" + }, + { + "id": "recognize", + "name": "Streaming Recognition", + "file": "recognize_streaming.js", + "docs_link": "https://cloud.google.com/speech/docs/", + "usage": { + "text": "node recognize_streaming " + }, + "help": "node recognize_streaming resources/audio.raw" + } + ] +} diff --git a/storage/README.md b/storage/README.md index 3af203b46b..6d1c8a0d34 100644 --- a/storage/README.md +++ b/storage/README.md @@ -15,7 +15,8 @@ amount of data at any time. * [Buckets](#buckets) * [Encryption](#encryption) * [Files](#files) - * [Storage Transfer API](#storage-transfer-api) + * [Storage Transfer API (Jobs)](#storage-transfer-api-jobs) + * [Storage Transfer API (Operations)](#storage-transfer-api-operations) ## Setup @@ -31,7 +32,7 @@ amount of data at any time. ### ACL (Access Control Lists) -View the [documentation][acl_docs] or the [source code][acl_code]. +View the [documentation][acl_0_docs] or the [source code][acl_0_code]. __Usage:__ `node acl --help` @@ -42,32 +43,28 @@ Commands: delete Delete access controls from a bucket or file. Options: - --bucket, -b The target storage bucket. [string] [required] - --default, -d Whether to set default access - controls. Only valid when setting - access controls on a bucket. [boolean] - --file, -f The target file. [string] - --help Show help [boolean] + --bucket, -b The target storage bucket. [string] [required] + --default, -d Whether to set default access controls. Only valid when setting access controls on a bucket. [boolean] + --file, -f The target file. [string] + --help Show help [boolean] Examples: - node acl add user-bob@domain.com OWNER -b mybucket Add OWNER access controls for - "user-bob@domain.com" to "mybucket". - node acl add viewers-2256 WRITER -b mybucket -d Add default WRITER access controls to - "mybucket" for "viewers-2256". - node acl get editors-1234 -b mybucket Get access controls for "editors-1234" in + node acl add user-bob@domain.com OWNER -b mybucket Add OWNER access controls for "user-bob@domain.com" to "mybucket". + node acl add viewers-2256 WRITER -b mybucket -d Add default WRITER access controls to "mybucket" for + "viewers-2256". + node acl get editors-1234 -b mybucket Get access controls for "editors-1234" in "mybucket". + node acl delete -b mybucket -f file.txt Delete all access controls for all entities from "file.txt" in "mybucket". - node acl delete -b mybucket -f file.txt Delete all access controls for all entities - from "file.txt" in "mybucket". For more information, see https://cloud.google.com/storage/docs/access-control/create-manage-lists ``` -[acl_docs]: https://cloud.google.com/storage/docs/access-control/create-manage-lists -[acl_code]: acl.js +[acl_0_docs]: https://cloud.google.com/storage/docs/access-control/create-manage-lists +[acl_0_code]: acl.js ### Buckets -View the [documentation][buckets_docs] or the [source code][buckets_code]. +View the [documentation][buckets_1_docs] or the [source code][buckets_1_code]. __Usage:__ `node buckets --help` @@ -78,7 +75,7 @@ Commands: delete Delete the specified bucket. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: node buckets create my-bucket Create a new bucket named "my-bucket". @@ -88,12 +85,12 @@ Examples: For more information, see https://cloud.google.com/storage/docs ``` -[buckets_docs]: https://cloud.google.com/storage/docs -[buckets_code]: buckets.js +[buckets_1_docs]: https://cloud.google.com/storage/docs +[buckets_1_code]: buckets.js ### Encryption -View the [documentation][encryption_docs] or the [source code][encryption_code]. +View the [documentation][encryption_2_docs] or the [source code][encryption_2_code]. __Usage:__ `node encryption --help` @@ -105,7 +102,7 @@ Commands: rotate Rotate encryption keys for a file. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: node encryption generate-encryption-key Generate a sample encryption key. @@ -119,100 +116,87 @@ Examples: For more information, see https://cloud.google.com/storage/docs ``` -[encryption_docs]: https://cloud.google.com/storage/docs -[encryption_code]: encryption.js +[encryption_2_docs]: https://cloud.google.com/storage/docs +[encryption_2_code]: encryption.js ### Files -View the [documentation][files_docs] or the [source code][files_code]. +View the [documentation][files_3_docs] or the [source code][files_3_code]. __Usage:__ `node files --help` ``` Commands: - list [options] List files in a bucket, optionally filtering - by a prefix. + list [options] List files in a bucket, optionally filtering by a prefix. upload Upload a local file to a bucket. download Download a file from a bucket. delete Delete a file from a bucket. getMetadata Get metadata for a file in a bucket. makePublic Make a file public in a bucket. - move Rename a file in a bucket. + move Move a file to a new location within the same bucket, i.e. rename + the file. copy Copy a file in a bucket to another bucket. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: - node files list my-bucket List files in "my-bucket". - node files list my-bucket -p public/ List files in "my-bucket" filtered by prefix - "public/". - node files upload my-bucket ./file.txt Upload "./file.txt" to "my-bucket". - node files download my-bucket file.txt ./file.txt Download "gs://my-bucket/file.txt" to - "./file.txt". - node files delete my-bucket file.txt Delete "gs://my-bucket/file.txt". - node files getMetadata my-bucket file.txt Get metadata for "gs://my-bucket/file.txt". - node files makePublic my-bucket file.txt Make "gs://my-bucket/file.txt" public. - node files move my-bucket file.txt file2.txt Rename "gs://my-bucket/file.txt" to - "gs://my-bucket/file2.txt". - node files copy my-bucket file.txt my-other-bucket Copy "gs://my-bucket/file.txt" to - file.txt "gs://my-other-bucket/file.txt". + node files list my-bucket List files in "my-bucket". + node files list my-bucket -p public/ List files in "my-bucket" filtered by prefix "public/". + node files upload my-bucket ./file.txt Upload "./file.txt" to "my-bucket". + node files download my-bucket file.txt ./file.txt Download "gs://my-bucket/file.txt" to "./file.txt". + node files delete my-bucket file.txt Delete "gs://my-bucket/file.txt". + node files getMetadata my-bucket file.txt Get metadata for "gs://my-bucket/file.txt". + node files makePublic my-bucket file.txt Make "gs://my-bucket/file.txt" public. + node files move my-bucket file.txt file2.txt Rename "gs://my-bucket/file.txt" to + "gs://my-bucket/file2.txt". + node files copy my-bucket file.txt my-other-bucket file.txt Copy "gs://my-bucket/file.txt" to + "gs://my-other-bucket/file.txt". For more information, see https://cloud.google.com/storage/docs ``` -[files_docs]: https://cloud.google.com/storage/docs -[files_code]: files.js +[files_3_docs]: https://cloud.google.com/storage/docs +[files_3_code]: files.js -### Storage Transfer API +### Storage Transfer API (Jobs) -View the [documentation][storagetransfer_docs] or the [source code][storagetransfer_code]. +View the [documentation][transfer_4_docs] or the [source code][transfer_4_code]. -__Usage:__ `node transfer --help` +__Usage:__ `node transfer jobs --help` ``` +transfer jobs [args] + Commands: - jobs [args] Run a job command. - operations [args] Run an operation command. + create