Skip to content

Add (missing) sample parameter values #428

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

Merged
merged 5 commits into from
Jul 24, 2017
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
33 changes: 21 additions & 12 deletions bigquery/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
'use strict';

// [START bigquery_simple_app_all]
// [START bigquery_simple_app_print]
function printResult (rows) {
// [START bigquery_simple_app_print]
console.log('Query Results:');
rows.forEach(function (row) {
let str = '';
Expand All @@ -29,25 +29,26 @@ function printResult (rows) {
}
console.log(str);
});
// [END bigquery_simple_app_print]
}
// [END bigquery_simple_app_print]

// [START bigquery_simple_app_query]
const sqlQuery = `SELECT
corpus, COUNT(*) as unique_words
FROM publicdata.samples.shakespeare
GROUP BY
corpus
ORDER BY
unique_words DESC LIMIT 10;`;

function queryShakespeare (projectId) {
// [START bigquery_simple_app_query]
// Imports the Google Cloud client library
const BigQuery = require('@google-cloud/bigquery');

// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The SQL query to run
const sqlQuery = `SELECT
corpus, COUNT(*) as unique_words
FROM publicdata.samples.shakespeare
GROUP BY
corpus
ORDER BY
unique_words DESC LIMIT 10;`;

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand All @@ -69,8 +70,8 @@ function queryShakespeare (projectId) {
.catch((err) => {
console.error('ERROR:', err);
});
// [END bigquery_simple_app_query]
}
// [END bigquery_simple_app_query]
// [END bigquery_simple_app_all]

function syncQuery (sqlQuery, projectId) {
Expand All @@ -81,6 +82,9 @@ function syncQuery (sqlQuery, projectId) {
// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The SQL query to run, e.g. "SELECT * FROM publicdata.samples.natality LIMIT 5;"
// const sqlQuery = "SELECT * FROM publicdata.samples.natality LIMIT 5;";

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down Expand Up @@ -109,6 +113,7 @@ function syncQuery (sqlQuery, projectId) {

function asyncQuery (sqlQuery, projectId) {
// [START bigquery_async_query]
// [START bigquery_build_client]
// Imports the Google Cloud client library
const BigQuery = require('@google-cloud/bigquery');

Expand All @@ -119,6 +124,10 @@ function asyncQuery (sqlQuery, projectId) {
const bigquery = BigQuery({
projectId: projectId
});
// [END bigquery_build_client]

// The SQL query to run, e.g. "SELECT * FROM publicdata.samples.natality LIMIT 5;"
// const sqlQuery = "SELECT * FROM publicdata.samples.natality LIMIT 5;";

// Query options list: https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
const options = {
Expand Down
7 changes: 7 additions & 0 deletions bigquery/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ function listTables (datasetId, projectId) {
// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The ID of the dataset to list tables in, e.g. "my_dataset"
// const datasetId = "my_dataset";

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down Expand Up @@ -401,6 +404,10 @@ function insertRowsAsStream (datasetId, tableId, rows, projectId) {
// The ID of the table into which data should be inserted, e.g. "my_table"
// const tableId = "my_table";

// The rows to insert into the table
// Customize this object to match your table's schema
// const rows = [{name: "Tom", age: 30}, {name: "Jane", age: 32}];

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down
70 changes: 40 additions & 30 deletions iot/manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,43 @@ Run the following command to install the library dependencies for NodeJS:

# Running the sample

The following command summarizes the sample usage:

Usage: cloudiot_device_manager_example [options]

Example Google Cloud IoT device manager integration

Options:

-h, --help output usage information
--project_id <project_id> GCP cloud project name.
--pubsub_topic <pubsub_topic> Cloud Pub/Sub topic to use.
--api_key <api_key> Your API key.
--ec_public_key_file <ec_public_key_file> Path to EC public key.
--rsa_certificate_file <rsa_certificate_file> Path to RSA certificate file.
--cloud_region <cloud_region> GCP cloud region.
--service_account_json <service_account_json> Path to service account JSON file.
--registry_id <registry_id> Custom registry id. If not provided, a unique registry id will be generated.

For example, if your project ID is `blue-jet-123`, your service account
credentials are stored in your home folder in creds.json and you have generated
your credentials using the shell script provided in the parent folder, you can
run the sample as:

node cloudiot_device_manager_example.js \
--service_account_json=$HOME/creds.json \
--api_key=YOUR_CLIENT_ID \
--project_id=blue-jet-123 \
--pubsub_topic=projects/blue-jet-123/topics/device-events \
--ec_public_key_file=../ec_public.pem \
--rsa_certificate_file=../rsa_cert.pem
Commands:
createRsa256Device <deviceId> <registryId> <rsaPath> Creates an RSA256 device.
createEs256Device <deviceId> <registryId> <esPath> Creates an ES256 device.
createUnauthDevice <deviceId> <registryId> Creates a device without authorization.
createRegistry <registryId> <pubsubTopic> Creates a device registry.
createIotTopic <pubsubTopic> Creates and configures a PubSub topic for Cloud IoT Core.
setupIotTopic <pubsubTopic> Configures the PubSub topic for Cloud IoT Core.
deleteDevice <deviceId> <registryId> Deletes a device from the device registry.
clearRegistry <registryId> !!Be careful! Removes all devices and then deletes a device
registry!!
deleteRegistry <registryId> Deletes a device registry.
getDevice <deviceId> <registryId> Retrieves device info given a device ID.
listDevices <registryId> Lists the devices in a given registry.
patchEs256 <deviceId> <registryId> <es256Path> Patches a device with ES256 authorization credentials.
patchRsa256 <deviceId> <registryId> <rsa256Path> Patches a device with RSA256 authentication credentials.

Options:
--apiKey, -a The API key used for discoverying the API. [string]
--projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT
environment variables. [string]
--serviceAccount, -s The path to your service credentials JSON. [string]
--help Show help [boolean]
--cloudRegion, -c [string] [default: "us-central1"]

Examples:
node manager.js createEs256Device my-es-device my-registry ../ec_public.pem --apiKey=abc123zz
node manager.js createRegistry my-registry my-iot-topic --service_account_json=$HOME/creds_iot.json
--api_key=abc123zz --project_id=my-project-id
node manager.js createRsa256Device my-rsa-device my-registry ../rsa_cert.pem --apiKey=abc123zz
node manager.js createUnauthDevice my-device my-registry
node manager.js deleteDevice my-device my-registry
node manager.js deleteRegistry my-device my-registry
node manager.js getDevice my-device my-registry
node manager.js listDevices my-node-registry
node manager.js patchRsa256 my-device my-registry ../rsa_cert.pem
node manager.js patchEs256 my-device my-registry ../ec_public.pem
node manager.js setupTopic my-iot-topic --service_account_json=$HOME/creds_iot.json --api_key=abc123zz
--project_id=my-project-id

For more information, see https://cloud.google.com/iot-core/docs
23 changes: 21 additions & 2 deletions iot/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@
"name": "nodejs-docs-samples-iot-manager",
"version": "0.0.1",
"description": "Example of Cloud IoT device administration",
"main": "cloudiot-device-manager-example.js",
"main": "manager.js",
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">=4.3.2"
},
"scripts": {
"lint": "samples lint",
"pretest": "npm run lint",
"system-test": "ava -T 3m --verbose system-test/*.test.js",
"test": "npm run system-test"
},
"dependencies": {
"@google-cloud/nodejs-repo-tools": "^1.4.15",
"@google-cloud/pubsub": "0.12.0",
"ava": "^0.20.0",
"googleapis": "19.0.0",
"yargs": "^8.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.15",
"ava": "0.20.0",
"uuid": "3.1.0"
}
}