Skip to content

Commit

Permalink
fix: do not require projectId for samples (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Dec 27, 2018
1 parent f2ebd4a commit 946aa96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
12 changes: 1 addition & 11 deletions packages/google-cloud-bigquery-datatransfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,12 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
### Using the client library

```javascript

if (
!process.env.GCLOUD_PROJECT ||
!process.env.GOOGLE_APPLICATION_CREDENTIALS
) {
throw new Error(
'Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
);
}

const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer');

const client = new bigqueryDataTransfer.v1.DataTransferServiceClient({
// optional auth parameters.
});
const projectId = process.env.GCLOUD_PROJECT;
const projectId = await client.getProjectId();

// Iterate over all elements.
const formattedParent = client.locationPath(projectId, 'us-central1');
Expand Down
25 changes: 6 additions & 19 deletions packages/google-cloud-bigquery-datatransfer/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,12 @@
// limitations under the License.

'use strict';
async function main() {
// [START bigquerydatatransfer_quickstart]

if (
!process.env.GCLOUD_PROJECT ||
!process.env.GOOGLE_APPLICATION_CREDENTIALS
) {
throw new Error(
'Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
);
}

// [START bigquerydatatransfer_quickstart]
async function quickstart() {
const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer');

const client = new bigqueryDataTransfer.v1.DataTransferServiceClient({
// optional auth parameters.
});
const projectId = process.env.GCLOUD_PROJECT;
const client = new bigqueryDataTransfer.v1.DataTransferServiceClient();
const projectId = await client.getProjectId();

// Iterate over all elements.
const formattedParent = client.projectPath(projectId, 'us-central1');
Expand Down Expand Up @@ -59,7 +47,6 @@ async function main() {
.on('data', element => {
console.log(` ${element.name}`);
});
// [END bigquerydatatransfer_quickstart]
}

main().catch(console.error);
quickstart().catch(console.error);
// [END bigquerydatatransfer_quickstart]

0 comments on commit 946aa96

Please sign in to comment.