diff --git a/samples/generated/v2/config_service_v2.list_buckets.js b/samples/generated/v2/config_service_v2.list_buckets.js index a6d2011f..eecf0604 100644 --- a/samples/generated/v2/config_service_v2.list_buckets.js +++ b/samples/generated/v2/config_service_v2.list_buckets.js @@ -64,7 +64,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listBucketsAsync(request); + const iterable = loggingClient.listBucketsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/config_service_v2.list_exclusions.js b/samples/generated/v2/config_service_v2.list_exclusions.js index a44a08be..213a30bb 100644 --- a/samples/generated/v2/config_service_v2.list_exclusions.js +++ b/samples/generated/v2/config_service_v2.list_exclusions.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listExclusionsAsync(request); + const iterable = loggingClient.listExclusionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/config_service_v2.list_links.js b/samples/generated/v2/config_service_v2.list_links.js index 17f59224..09b94f34 100644 --- a/samples/generated/v2/config_service_v2.list_links.js +++ b/samples/generated/v2/config_service_v2.list_links.js @@ -58,7 +58,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listLinksAsync(request); + const iterable = loggingClient.listLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/config_service_v2.list_sinks.js b/samples/generated/v2/config_service_v2.list_sinks.js index 0c437016..e48139c6 100644 --- a/samples/generated/v2/config_service_v2.list_sinks.js +++ b/samples/generated/v2/config_service_v2.list_sinks.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listSinksAsync(request); + const iterable = loggingClient.listSinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/config_service_v2.list_views.js b/samples/generated/v2/config_service_v2.list_views.js index 89137ca8..c6858370 100644 --- a/samples/generated/v2/config_service_v2.list_views.js +++ b/samples/generated/v2/config_service_v2.list_views.js @@ -58,7 +58,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listViewsAsync(request); + const iterable = loggingClient.listViewsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/logging_service_v2.list_log_entries.js b/samples/generated/v2/logging_service_v2.list_log_entries.js index 86720a00..1857cae3 100644 --- a/samples/generated/v2/logging_service_v2.list_log_entries.js +++ b/samples/generated/v2/logging_service_v2.list_log_entries.js @@ -87,7 +87,7 @@ function main(resourceNames) { }; // Run request - const iterable = await loggingClient.listLogEntriesAsync(request); + const iterable = loggingClient.listLogEntriesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/logging_service_v2.list_logs.js b/samples/generated/v2/logging_service_v2.list_logs.js index f336977c..688d137a 100644 --- a/samples/generated/v2/logging_service_v2.list_logs.js +++ b/samples/generated/v2/logging_service_v2.list_logs.js @@ -75,7 +75,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listLogsAsync(request); + const iterable = loggingClient.listLogsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/logging_service_v2.list_monitored_resource_descriptors.js b/samples/generated/v2/logging_service_v2.list_monitored_resource_descriptors.js index 10190de9..60a67502 100644 --- a/samples/generated/v2/logging_service_v2.list_monitored_resource_descriptors.js +++ b/samples/generated/v2/logging_service_v2.list_monitored_resource_descriptors.js @@ -52,7 +52,7 @@ function main() { // Run request const iterable = - await loggingClient.listMonitoredResourceDescriptorsAsync(request); + loggingClient.listMonitoredResourceDescriptorsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/samples/generated/v2/metrics_service_v2.list_log_metrics.js b/samples/generated/v2/metrics_service_v2.list_log_metrics.js index 52cf25ea..4ffff33a 100644 --- a/samples/generated/v2/metrics_service_v2.list_log_metrics.js +++ b/samples/generated/v2/metrics_service_v2.list_log_metrics.js @@ -58,7 +58,7 @@ function main(parent) { }; // Run request - const iterable = await loggingClient.listLogMetricsAsync(request); + const iterable = loggingClient.listLogMetricsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/src/v2/config_service_v2_client.ts b/src/v2/config_service_v2_client.ts index 0e1541a1..8ea15a66 100644 --- a/src/v2/config_service_v2_client.ts +++ b/src/v2/config_service_v2_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/config_service_v2_client_config.json`. @@ -52,6 +53,8 @@ export class ConfigServiceV2Client { 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: {}, @@ -110,8 +113,20 @@ export class ConfigServiceV2Client { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ConfigServiceV2Client; + 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 = 'logging.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ConfigServiceV2Client { 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; } @@ -151,10 +166,10 @@ export class ConfigServiceV2Client { 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; } @@ -558,21 +573,52 @@ export class ConfigServiceV2Client { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } + /** + * The DNS address for this API service. + * @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/logging_service_v2_client.ts b/src/v2/logging_service_v2_client.ts index 8eb4873e..b807e9e7 100644 --- a/src/v2/logging_service_v2_client.ts +++ b/src/v2/logging_service_v2_client.ts @@ -29,6 +29,7 @@ import type { import {Transform, PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/logging_service_v2_client_config.json`. @@ -50,6 +51,8 @@ export class LoggingServiceV2Client { 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: {}, @@ -107,8 +110,20 @@ export class LoggingServiceV2Client { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof LoggingServiceV2Client; + 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 = 'logging.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class LoggingServiceV2Client { 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; } @@ -148,10 +163,10 @@ export class LoggingServiceV2Client { 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; } @@ -313,7 +328,7 @@ export class LoggingServiceV2Client { tailLogEntries: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), }; @@ -437,21 +452,52 @@ export class LoggingServiceV2Client { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } + /** + * The DNS address for this API service. + * @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/metrics_service_v2_client.ts b/src/v2/metrics_service_v2_client.ts index 904312dc..46899baa 100644 --- a/src/v2/metrics_service_v2_client.ts +++ b/src/v2/metrics_service_v2_client.ts @@ -29,6 +29,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/metrics_service_v2_client_config.json`. @@ -50,6 +51,8 @@ export class MetricsServiceV2Client { 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: {}, @@ -107,8 +110,20 @@ export class MetricsServiceV2Client { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MetricsServiceV2Client; + 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 = 'logging.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class MetricsServiceV2Client { 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; } @@ -148,10 +163,10 @@ export class MetricsServiceV2Client { 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; } @@ -384,21 +399,52 @@ export class MetricsServiceV2Client { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @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 'logging.googleapis.com'; } + /** + * The DNS address for this API service. + * @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_config_service_v2_v2.ts b/test/gapic_config_service_v2_v2.ts index 741d1e20..86567af3 100644 --- a/test/gapic_config_service_v2_v2.ts +++ b/test/gapic_config_service_v2_v2.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v2.ConfigServiceV2Client', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - configservicev2Module.v2.ConfigServiceV2Client.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - configservicev2Module.v2.ConfigServiceV2Client.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client(); + 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 = + configservicev2Module.v2.ConfigServiceV2Client.servicePath; + assert.strictEqual(servicePath, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + configservicev2Module.v2.ConfigServiceV2Client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new configservicev2Module.v2.ConfigServiceV2Client({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/test/gapic_logging_service_v2_v2.ts b/test/gapic_logging_service_v2_v2.ts index cd81094c..9d7246e8 100644 --- a/test/gapic_logging_service_v2_v2.ts +++ b/test/gapic_logging_service_v2_v2.ts @@ -143,16 +143,62 @@ function stubAsyncIterationCall( describe('v2.LoggingServiceV2Client', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - loggingservicev2Module.v2.LoggingServiceV2Client.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - loggingservicev2Module.v2.LoggingServiceV2Client.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client(); + 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 = + loggingservicev2Module.v2.LoggingServiceV2Client.servicePath; + assert.strictEqual(servicePath, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + loggingservicev2Module.v2.LoggingServiceV2Client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new loggingservicev2Module.v2.LoggingServiceV2Client({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/test/gapic_metrics_service_v2_v2.ts b/test/gapic_metrics_service_v2_v2.ts index 45c8ea1c..4124f150 100644 --- a/test/gapic_metrics_service_v2_v2.ts +++ b/test/gapic_metrics_service_v2_v2.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v2.MetricsServiceV2Client', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - metricsservicev2Module.v2.MetricsServiceV2Client.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - metricsservicev2Module.v2.MetricsServiceV2Client.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client(); + 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 = + metricsservicev2Module.v2.MetricsServiceV2Client.servicePath; + assert.strictEqual(servicePath, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + metricsservicev2Module.v2.MetricsServiceV2Client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'logging.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new metricsservicev2Module.v2.MetricsServiceV2Client({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => {