diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 74883698..788f7a9f 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:bb493bf01d28519e82ab61c490c20122c85a7119c03a978ad0c34b4239fbad15 -# created: 2022-08-23T18:40:55.597313991Z + digest: sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8 diff --git a/.kokoro/continuous/node12/samples-test.cfg b/.kokoro/continuous/node12/samples-test.cfg index 3fa1edf7..54748bab 100644 --- a/.kokoro/continuous/node12/samples-test.cfg +++ b/.kokoro/continuous/node12/samples-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-bigquery/.kokoro/samples-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/continuous/node12/system-test.cfg b/.kokoro/continuous/node12/system-test.cfg index 95e3a84f..c89e9937 100644 --- a/.kokoro/continuous/node12/system-test.cfg +++ b/.kokoro/continuous/node12/system-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-bigquery/.kokoro/system-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/samples-test.cfg b/.kokoro/presubmit/node12/samples-test.cfg index 3fa1edf7..54748bab 100644 --- a/.kokoro/presubmit/node12/samples-test.cfg +++ b/.kokoro/presubmit/node12/samples-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-bigquery/.kokoro/samples-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/system-test.cfg b/.kokoro/presubmit/node12/system-test.cfg index 95e3a84f..c89e9937 100644 --- a/.kokoro/presubmit/node12/system-test.cfg +++ b/.kokoro/presubmit/node12/system-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-bigquery/.kokoro/system-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index fbc058a4..806c0082 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -19,7 +19,7 @@ set -eo pipefail export NPM_CONFIG_PREFIX=${HOME}/.npm-global # Setup service account credentials. -export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account export GCLOUD_PROJECT=long-door-651 cd $(dirname $0)/.. diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 87fa0653..0201e9df 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -19,7 +19,7 @@ set -eo pipefail export NPM_CONFIG_PREFIX=${HOME}/.npm-global # Setup service account credentials. -export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account export GCLOUD_PROJECT=long-door-651 cd $(dirname $0)/.. diff --git a/CHANGELOG.md b/CHANGELOG.md index d1023d14..c58ec3fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/bigquery?activeTab=versions +## [6.1.0](https://github.com/googleapis/nodejs-bigquery/compare/v6.0.3...v6.1.0) (2023-01-25) + + +### Features + +* Add set client endpoint sample ([#1170](https://github.com/googleapis/nodejs-bigquery/issues/1170)) ([df1dcd3](https://github.com/googleapis/nodejs-bigquery/commit/df1dcd3899dd10f20988b938b31ac571c997bffd)) + ## [6.0.3](https://github.com/googleapis/nodejs-bigquery/compare/v6.0.2...v6.0.3) (2022-08-23) diff --git a/README.md b/README.md index 3961a512..72801ad4 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-bigquery/tr | Relax Column Load Append | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/relaxColumnLoadAppend.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/relaxColumnLoadAppend.js,samples/README.md) | | Relax Column Query Append | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/relaxColumnQueryAppend.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/relaxColumnQueryAppend.js,samples/README.md) | | Remove Table Clustering | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/removeTableClustering.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/removeTableClustering.js,samples/README.md) | +| Set Client Endpoint | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/setClientEndpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/setClientEndpoint.js,samples/README.md) | | Set User Agent | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/setUserAgent.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/setUserAgent.js,samples/README.md) | | Table Exists | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/tableExists.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/tableExists.js,samples/README.md) | | Undelete Table | [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/undeleteTable.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/undeleteTable.js,samples/README.md) | diff --git a/package.json b/package.json index 6a31455c..be0f696f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/bigquery", "description": "Google BigQuery Client Library for Node.js", - "version": "6.0.3", + "version": "6.1.0", "license": "Apache-2.0", "author": "Google LLC", "engines": { @@ -59,7 +59,7 @@ "p-event": "^4.1.0", "readable-stream": "^4.0.0", "stream-events": "^1.0.5", - "uuid": "^8.0.0" + "uuid": "^9.0.0" }, "devDependencies": { "@google-cloud/storage": "^6.0.0", @@ -70,17 +70,17 @@ "@types/mocha": "^9.0.0", "@types/mv": "^2.1.0", "@types/ncp": "^2.0.1", - "@types/node": "^16.0.0", + "@types/node": "^18.0.0", "@types/proxyquire": "^1.3.28", "@types/sinon": "^10.0.0", "@types/tmp": "0.2.3", - "@types/uuid": "^8.0.0", + "@types/uuid": "^9.0.0", "c8": "^7.0.0", "codecov": "^3.5.0", "discovery-tsd": "^0.3.0", "execa": "^5.0.0", "gts": "^3.1.0", - "jsdoc": "^3.6.3", + "jsdoc": "^4.0.0", "jsdoc-fresh": "^2.0.0", "jsdoc-region-tag": "^2.0.0", "linkinator": "^4.0.0", @@ -88,7 +88,7 @@ "mv": "^2.1.1", "ncp": "^2.0.0", "proxyquire": "^2.1.0", - "sinon": "^14.0.0", + "sinon": "^15.0.0", "tmp": "0.2.1", "typescript": "^4.6.4" } diff --git a/samples/README.md b/samples/README.md index 88cdbd52..71ad7f52 100644 --- a/samples/README.md +++ b/samples/README.md @@ -102,6 +102,7 @@ * [Relax Column Load Append](#relax-column-load-append) * [Relax Column Query Append](#relax-column-query-append) * [Remove Table Clustering](#remove-table-clustering) + * [Set Client Endpoint](#set-client-endpoint) * [Set User Agent](#set-user-agent) * [Table Exists](#table-exists) * [Undelete Table](#undelete-table) @@ -1678,6 +1679,23 @@ __Usage:__ +### Set Client Endpoint + +View the [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/setClientEndpoint.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigquery&page=editor&open_in_editor=samples/setClientEndpoint.js,samples/README.md) + +__Usage:__ + + +`node samples/setClientEndpoint.js` + + +----- + + + + ### Set User Agent View the [source code](https://github.com/googleapis/nodejs-bigquery/blob/main/samples/setUserAgent.js). diff --git a/samples/createView.js b/samples/createView.js index 546c3df9..f4bffb06 100644 --- a/samples/createView.js +++ b/samples/createView.js @@ -32,7 +32,7 @@ function main( /** * TODO(developer): Uncomment the following lines before running the sample. */ - // const myDatasetId = "my_table" + // const myDatasetId = "my_dataset" // const myTableId = "my_table" // const projectId = "bigquery-public-data"; // const sourceDatasetId = "usa_names" diff --git a/samples/insertingDataTypes.js b/samples/insertingDataTypes.js index 55e286dc..e2b005dc 100644 --- a/samples/insertingDataTypes.js +++ b/samples/insertingDataTypes.js @@ -20,7 +20,7 @@ function main(datasetId = 'my_dataset', tableId = 'my_table') { const {BigQuery} = require('@google-cloud/bigquery'); const bigquery = new BigQuery(); - async function instertingDataTypes() { + async function insertingDataTypes() { // Inserts data of various BigQuery-supported types into a table. /** @@ -140,6 +140,6 @@ function main(datasetId = 'my_dataset', tableId = 'my_table') { console.log(`Inserted ${rows.length} rows`); } // [END bigquery_inserting_data_types] - instertingDataTypes(); + insertingDataTypes(); } main(...process.argv.slice(2)); diff --git a/samples/package.json b/samples/package.json index c949ec2e..bbff3f46 100644 --- a/samples/package.json +++ b/samples/package.json @@ -16,7 +16,7 @@ "test": "mocha --timeout 200000" }, "dependencies": { - "@google-cloud/bigquery": "^6.0.3", + "@google-cloud/bigquery": "^6.1.0", "@google-cloud/storage": "^6.0.0", "google-auth-library": "^7.0.0", "readline-promise": "^1.0.4", @@ -27,7 +27,7 @@ "chai": "^4.2.0", "mocha": "^8.0.0", "proxyquire": "^2.1.3", - "sinon": "^14.0.0", - "uuid": "^8.0.0" + "sinon": "^15.0.0", + "uuid": "^9.0.0" } } \ No newline at end of file diff --git a/samples/setClientEndpoint.js b/samples/setClientEndpoint.js new file mode 100644 index 00000000..5ec8575d --- /dev/null +++ b/samples/setClientEndpoint.js @@ -0,0 +1,40 @@ +// Copyright 2023 Google LLC +// +// 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. + +'use strict'; + +function main(region = 'my-region') { + // [START bigquery_set_client_endpoint] + // Import the Google Cloud client library + const {BigQuery} = require('@google-cloud/bigquery'); + + function setClientEndpoint() { + // Create a bigquery client pointing to a specific endpoint + + /** + * TODO(developer): Uncomment the following line of code and fill in your region before running the sample. + */ + // const region = 'my-region'; + + const bigquery = new BigQuery({ + apiEndpoint: `${region}-bigquery.googleapis.com`, + }); + + console.log('API Endpoint:'); + console.log(bigquery.apiEndpoint); + } + // [END bigquery_set_client_endpoint] + setClientEndpoint(); +} +main(...process.argv.slice(2)); diff --git a/samples/test/clients.test.js b/samples/test/clients.test.js index a81e5a7e..cb6f1aeb 100644 --- a/samples/test/clients.test.js +++ b/samples/test/clients.test.js @@ -26,4 +26,13 @@ describe('Client', () => { assert.match(output, /User agent:/); assert.match(output, /my-user-agent/); }); + it('should should set client endpoint', async () => { + let output = execSync('node setClientEndpoint.js us-east4'); + assert.match(output, /API Endpoint:/); + assert.match(output, /https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/us-east4-bigquery.googleapis.com/); + + output = execSync('node setClientEndpoint.js eu'); + assert.match(output, /API Endpoint:/); + assert.match(output, /https:\/\/blue-sea-697d.quartiers047.workers.dev:443\/https\/eu-bigquery.googleapis.com/); + }); }); diff --git a/samples/test/datasets.test.js b/samples/test/datasets.test.js index 93cf2011..66f56c46 100644 --- a/samples/test/datasets.test.js +++ b/samples/test/datasets.test.js @@ -49,6 +49,35 @@ describe('Datasets', () => { assert.ok(exists); }); + it('should create a dataset using a regional endpoint', async () => { + const euBigquery = new BigQuery({ + apiEndpoint: 'eu-bigquery.googleapis.com', + }); + const euDatasetId = datasetId + '_eu'; + await euBigquery.createDataset(euDatasetId, { + location: 'eu', + }); + const [exists] = await euBigquery.dataset(euDatasetId).exists(); + assert.ok(exists); + }); + + it('should fail to create a dataset using a different region from the client endpoint', async () => { + const usEast4Bigquery = new BigQuery({ + apiEndpoint: 'us-east4-bigquery.googleapis.com', + }); + const usDatasetId = datasetId + '_us'; + let error; + try { + await usEast4Bigquery.createDataset(usDatasetId, { + location: 'us-central1', + }); + } catch (err) { + error = err; + } + assert.isNotNull(error); + assert.equal(error.message, 'Invalid storage region'); + }); + it('should list datasets', async () => { const output = execSync('node listDatasets.js'); assert.match(output, /Datasets:/); diff --git a/system-test/fixtures/kitchen/package.json b/system-test/fixtures/kitchen/package.json index a9f5788f..4439ec90 100644 --- a/system-test/fixtures/kitchen/package.json +++ b/system-test/fixtures/kitchen/package.json @@ -16,7 +16,7 @@ "@google-cloud/bigquery": "file:./google-cloud-bigquery.tgz" }, "devDependencies": { - "@types/node": "^16.0.0", + "@types/node": "^18.0.0", "typescript": "^3.0.0", "gts": "^3.0.0" }