From c0c287e2d386758609f57f3efee78b18fc9d8b7d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:50:39 -0500 Subject: [PATCH] feat: Trusted Private Cloud support, use the universeDomain parameter (#1386) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Trusted Private Cloud support, use the universeDomain parameter feat: auto populate UUID fields where needed fix: revert changes to streaming retries Use gapic-generator-typescript v4.4.0. PiperOrigin-RevId: 603757799 Source-Link: https://github.com/googleapis/googleapis/commit/1a45bf7393b52407188c82e63101db7dc9c72026 Source-Link: https://github.com/googleapis/googleapis-gen/commit/19ca4b45a53d00cb7bdd94b442b60bd237dfe123 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTljYTRiNDVhNTNkMDBjYjdiZGQ5NGI0NDJiNjBiZDIzN2RmZTEyMyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- ...gtable_instance_admin.list_app_profiles.js | 2 +- ...igtable_instance_admin.list_hot_tablets.js | 2 +- .../v2/bigtable_table_admin.list_backups.js | 2 +- .../v2/bigtable_table_admin.list_snapshots.js | 2 +- .../v2/bigtable_table_admin.list_tables.js | 2 +- src/v2/bigtable_client.ts | 75 +++++++++++++--- src/v2/bigtable_instance_admin_client.ts | 65 ++++++++++++-- src/v2/bigtable_table_admin_client.ts | 65 ++++++++++++-- test/gapic_bigtable_instance_admin_v2.ts | 71 +++++++++++++-- test/gapic_bigtable_table_admin_v2.ts | 64 +++++++++++-- test/gapic_bigtable_v2.ts | 90 +++++++++++++------ 11 files changed, 374 insertions(+), 66 deletions(-) diff --git a/samples/generated/v2/bigtable_instance_admin.list_app_profiles.js b/samples/generated/v2/bigtable_instance_admin.list_app_profiles.js index 1c030307b..409c049d6 100644 --- a/samples/generated/v2/bigtable_instance_admin.list_app_profiles.js +++ b/samples/generated/v2/bigtable_instance_admin.list_app_profiles.js @@ -64,7 +64,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listAppProfilesAsync(request); + const iterable = adminClient.listAppProfilesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js b/samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js index d165be90a..73eb76242 100644 --- a/samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js +++ b/samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js @@ -75,7 +75,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listHotTabletsAsync(request); + const iterable = adminClient.listHotTabletsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/bigtable_table_admin.list_backups.js b/samples/generated/v2/bigtable_table_admin.list_backups.js index fcdbbe861..1a6c3f296 100644 --- a/samples/generated/v2/bigtable_table_admin.list_backups.js +++ b/samples/generated/v2/bigtable_table_admin.list_backups.js @@ -114,7 +114,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listBackupsAsync(request); + const iterable = adminClient.listBackupsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/bigtable_table_admin.list_snapshots.js b/samples/generated/v2/bigtable_table_admin.list_snapshots.js index 2880f5be9..169a77cb2 100644 --- a/samples/generated/v2/bigtable_table_admin.list_snapshots.js +++ b/samples/generated/v2/bigtable_table_admin.list_snapshots.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listSnapshotsAsync(request); + const iterable = adminClient.listSnapshotsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/bigtable_table_admin.list_tables.js b/samples/generated/v2/bigtable_table_admin.list_tables.js index 74552adbb..d50bbd024 100644 --- a/samples/generated/v2/bigtable_table_admin.list_tables.js +++ b/samples/generated/v2/bigtable_table_admin.list_tables.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listTablesAsync(request); + const iterable = adminClient.listTablesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/src/v2/bigtable_client.ts b/src/v2/bigtable_client.ts index af08c7551..d0012edb2 100644 --- a/src/v2/bigtable_client.ts +++ b/src/v2/bigtable_client.ts @@ -27,6 +27,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/bigtable_client_config.json`. @@ -48,6 +49,8 @@ export class BigtableClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -105,8 +108,20 @@ export class BigtableClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BigtableClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'bigtable.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -121,7 +136,7 @@ export class BigtableClient { opts.numericEnums = true; // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -146,10 +161,10 @@ export class BigtableClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -189,28 +204,28 @@ export class BigtableClient { readRows: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), sampleRowKeys: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), mutateRows: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), generateInitialChangeStreamPartitions: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), readChangeStream: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), }; @@ -317,21 +332,61 @@ export class BigtableClient { /** * The DNS address for this API service. + * @deprecated * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtable.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), + * The DNS address for this API service - same as servicePath, * exists for compatibility reasons. + * @deprecated * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtable.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get servicePath() { + return this._servicePath; + } + + /** + * The DNS address for this API service - same as servicePath(). + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/src/v2/bigtable_instance_admin_client.ts b/src/v2/bigtable_instance_admin_client.ts index eb44d7581..1e4fb9b05 100644 --- a/src/v2/bigtable_instance_admin_client.ts +++ b/src/v2/bigtable_instance_admin_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/bigtable_instance_admin_client_config.json`. @@ -54,6 +55,8 @@ export class BigtableInstanceAdminClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -113,8 +116,20 @@ export class BigtableInstanceAdminClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof BigtableInstanceAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'bigtableadmin.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -129,7 +144,7 @@ export class BigtableInstanceAdminClient { opts.numericEnums = true; // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -154,10 +169,10 @@ export class BigtableInstanceAdminClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -435,21 +450,61 @@ export class BigtableInstanceAdminClient { /** * The DNS address for this API service. + * @deprecated * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtableadmin.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), + * The DNS address for this API service - same as servicePath, * exists for compatibility reasons. + * @deprecated * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtableadmin.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get servicePath() { + return this._servicePath; + } + + /** + * The DNS address for this API service - same as servicePath(). + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/src/v2/bigtable_table_admin_client.ts b/src/v2/bigtable_table_admin_client.ts index 46940c6f9..9e6132174 100644 --- a/src/v2/bigtable_table_admin_client.ts +++ b/src/v2/bigtable_table_admin_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/bigtable_table_admin_client_config.json`. @@ -56,6 +57,8 @@ export class BigtableTableAdminClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -114,8 +117,20 @@ export class BigtableTableAdminClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BigtableTableAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'bigtableadmin.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -130,7 +145,7 @@ export class BigtableTableAdminClient { opts.numericEnums = true; // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -155,10 +170,10 @@ export class BigtableTableAdminClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -455,21 +470,61 @@ export class BigtableTableAdminClient { /** * The DNS address for this API service. + * @deprecated * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtableadmin.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), + * The DNS address for this API service - same as servicePath, * exists for compatibility reasons. + * @deprecated * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'bigtableadmin.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get servicePath() { + return this._servicePath; + } + + /** + * The DNS address for this API service - same as servicePath(). + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/test/gapic_bigtable_instance_admin_v2.ts b/test/gapic_bigtable_instance_admin_v2.ts index 25b31106d..cf8180226 100644 --- a/test/gapic_bigtable_instance_admin_v2.ts +++ b/test/gapic_bigtable_instance_admin_v2.ts @@ -162,15 +162,74 @@ function stubAsyncIterationCall( describe('v2.BigtableInstanceAdminClient', () => { describe('Common methods', () => { it('has servicePath', () => { - const servicePath = - bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.servicePath; - assert(servicePath); + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient(); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.googleapis.com'); }); it('has apiEndpoint', () => { - const apiEndpoint = - bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.apiEndpoint; - assert(apiEndpoint); + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtableadmin.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + bigtableinstanceadminModule.v2.BigtableInstanceAdminClient + .servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + bigtableinstanceadminModule.v2.BigtableInstanceAdminClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtableadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets servicePath according to universe domain camelCase', () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.example.com'); + }); + + it('sets servicePath according to universe domain snakeCase', () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/test/gapic_bigtable_table_admin_v2.ts b/test/gapic_bigtable_table_admin_v2.ts index fe44c03d2..2c7094a47 100644 --- a/test/gapic_bigtable_table_admin_v2.ts +++ b/test/gapic_bigtable_table_admin_v2.ts @@ -162,15 +162,67 @@ function stubAsyncIterationCall( describe('v2.BigtableTableAdminClient', () => { describe('Common methods', () => { it('has servicePath', () => { - const servicePath = - bigtabletableadminModule.v2.BigtableTableAdminClient.servicePath; - assert(servicePath); + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient(); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.googleapis.com'); }); it('has apiEndpoint', () => { - const apiEndpoint = - bigtabletableadminModule.v2.BigtableTableAdminClient.apiEndpoint; - assert(apiEndpoint); + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtableadmin.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + bigtabletableadminModule.v2.BigtableTableAdminClient.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + bigtabletableadminModule.v2.BigtableTableAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtableadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets servicePath according to universe domain camelCase', () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.example.com'); + }); + + it('sets servicePath according to universe domain snakeCase', () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtableadmin.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new bigtabletableadminModule.v2.BigtableTableAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/test/gapic_bigtable_v2.ts b/test/gapic_bigtable_v2.ts index 1914bd0da..06cc456ea 100644 --- a/test/gapic_bigtable_v2.ts +++ b/test/gapic_bigtable_v2.ts @@ -90,13 +90,65 @@ function stubServerStreamingCall( describe('v2.BigtableClient', () => { describe('Common methods', () => { it('has servicePath', () => { - const servicePath = bigtableModule.v2.BigtableClient.servicePath; - assert(servicePath); + const client = new bigtableModule.v2.BigtableClient(); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtable.googleapis.com'); }); it('has apiEndpoint', () => { - const apiEndpoint = bigtableModule.v2.BigtableClient.apiEndpoint; - assert(apiEndpoint); + const client = new bigtableModule.v2.BigtableClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtable.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new bigtableModule.v2.BigtableClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = bigtableModule.v2.BigtableClient.servicePath; + assert.strictEqual(servicePath, 'bigtable.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = bigtableModule.v2.BigtableClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'bigtable.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets servicePath according to universe domain camelCase', () => { + const client = new bigtableModule.v2.BigtableClient({ + universeDomain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtable.example.com'); + }); + + it('sets servicePath according to universe domain snakeCase', () => { + const client = new bigtableModule.v2.BigtableClient({ + universe_domain: 'example.com', + }); + const servicePath = client.servicePath; + assert.strictEqual(servicePath, 'bigtable.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new bigtableModule.v2.BigtableClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { @@ -750,11 +802,7 @@ describe('v2.BigtableClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.readRows(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( @@ -867,11 +915,7 @@ describe('v2.BigtableClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.sampleRowKeys(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( @@ -984,11 +1028,7 @@ describe('v2.BigtableClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.mutateRows(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( @@ -1112,11 +1152,7 @@ describe('v2.BigtableClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.generateInitialChangeStreamPartitions(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( @@ -1240,11 +1276,7 @@ describe('v2.BigtableClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.readChangeStream(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on(