File tree Expand file tree Collapse file tree
packages/google-cloud-bigquery-datatransfer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,22 +61,12 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
6161### Using the client library
6262
6363``` javascript
64-
65- if (
66- ! process .env .GCLOUD_PROJECT ||
67- ! process .env .GOOGLE_APPLICATION_CREDENTIALS
68- ) {
69- throw new Error (
70- ' Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
71- );
72- }
73-
7464const bigqueryDataTransfer = require (' @google-cloud/bigquery-data-transfer' );
7565
7666const client = new bigqueryDataTransfer.v1.DataTransferServiceClient ({
7767 // optional auth parameters.
7868});
79- const projectId = process . env . GCLOUD_PROJECT ;
69+ const projectId = await client . getProjectId () ;
8070
8171// Iterate over all elements.
8272const formattedParent = client .locationPath (projectId, ' us-central1' );
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515'use strict' ;
16- async function main ( ) {
17- // [START bigquerydatatransfer_quickstart]
18-
19- if (
20- ! process . env . GCLOUD_PROJECT ||
21- ! process . env . GOOGLE_APPLICATION_CREDENTIALS
22- ) {
23- throw new Error (
24- 'Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
25- ) ;
26- }
2716
17+ // [START bigquerydatatransfer_quickstart]
18+ async function quickstart ( ) {
2819 const bigqueryDataTransfer = require ( '@google-cloud/bigquery-data-transfer' ) ;
29-
30- const client = new bigqueryDataTransfer . v1 . DataTransferServiceClient ( {
31- // optional auth parameters.
32- } ) ;
33- const projectId = process . env . GCLOUD_PROJECT ;
20+ const client = new bigqueryDataTransfer . v1 . DataTransferServiceClient ( ) ;
21+ const projectId = await client . getProjectId ( ) ;
3422
3523 // Iterate over all elements.
3624 const formattedParent = client . projectPath ( projectId , 'us-central1' ) ;
@@ -59,7 +47,6 @@ async function main() {
5947 . on ( 'data' , element => {
6048 console . log ( ` ${ element . name } ` ) ;
6149 } ) ;
62- // [END bigquerydatatransfer_quickstart]
6350}
64-
65- main ( ) . catch ( console . error ) ;
51+ quickstart ( ) . catch ( console . error ) ;
52+ // [END bigquerydatatransfer_quickstart]
You can’t perform that action at this time.
0 commit comments