From 4137f7b276aaf419125de2f913bf0d61afc7cde7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:00:23 -0400 Subject: [PATCH] feat: add several fields to manage state of database encryption update (#1495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add several fields to manage state of database encryption update PiperOrigin-RevId: 619289281 Source-Link: https://github.com/googleapis/googleapis/commit/3a7c33486ca758b180c6d11dd4705fa9a22e8576 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6a8c733062d833d11c5245eda50f5108e0e55324 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmE4YzczMzA2MmQ4MzNkMTFjNTI0NWVkYTUwZjUxMDhlMGU1NTMyNCJ9 * 🦉 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 --- src/v2/config_service_v2_client.ts | 15 +++++++++---- src/v2/logging_service_v2_client.ts | 15 +++++++++---- src/v2/metrics_service_v2_client.ts | 15 +++++++++---- test/gapic_config_service_v2_v2.ts | 34 ++++++++++++++++++++++++++++- test/gapic_logging_service_v2_v2.ts | 34 ++++++++++++++++++++++++++++- test/gapic_metrics_service_v2_v2.ts | 34 ++++++++++++++++++++++++++++- 6 files changed, 132 insertions(+), 15 deletions(-) diff --git a/src/v2/config_service_v2_client.ts b/src/v2/config_service_v2_client.ts index 8ea15a66..de78feb5 100644 --- a/src/v2/config_service_v2_client.ts +++ b/src/v2/config_service_v2_client.ts @@ -122,8 +122,15 @@ export class ConfigServiceV2Client { 'Please set either universe_domain or universeDomain, but not both.' ); } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; this._universeDomain = - opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'logging.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -175,7 +182,7 @@ export class ConfigServiceV2Client { // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; - if (typeof process !== 'undefined' && 'versions' in process) { + if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { clientHeader.push(`gl-web/${this._gaxModule.version}`); @@ -578,7 +585,7 @@ export class ConfigServiceV2Client { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -596,7 +603,7 @@ export class ConfigServiceV2Client { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/src/v2/logging_service_v2_client.ts b/src/v2/logging_service_v2_client.ts index b807e9e7..8283d392 100644 --- a/src/v2/logging_service_v2_client.ts +++ b/src/v2/logging_service_v2_client.ts @@ -119,8 +119,15 @@ export class LoggingServiceV2Client { 'Please set either universe_domain or universeDomain, but not both.' ); } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; this._universeDomain = - opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'logging.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -172,7 +179,7 @@ export class LoggingServiceV2Client { // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; - if (typeof process !== 'undefined' && 'versions' in process) { + if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { clientHeader.push(`gl-web/${this._gaxModule.version}`); @@ -457,7 +464,7 @@ export class LoggingServiceV2Client { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -475,7 +482,7 @@ export class LoggingServiceV2Client { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/src/v2/metrics_service_v2_client.ts b/src/v2/metrics_service_v2_client.ts index 46899baa..aae4b7e3 100644 --- a/src/v2/metrics_service_v2_client.ts +++ b/src/v2/metrics_service_v2_client.ts @@ -119,8 +119,15 @@ export class MetricsServiceV2Client { 'Please set either universe_domain or universeDomain, but not both.' ); } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; this._universeDomain = - opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'logging.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -172,7 +179,7 @@ export class MetricsServiceV2Client { // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; - if (typeof process !== 'undefined' && 'versions' in process) { + if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { clientHeader.push(`gl-web/${this._gaxModule.version}`); @@ -404,7 +411,7 @@ export class MetricsServiceV2Client { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -422,7 +429,7 @@ export class MetricsServiceV2Client { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/test/gapic_config_service_v2_v2.ts b/test/gapic_config_service_v2_v2.ts index 86567af3..431eaaa7 100644 --- a/test/gapic_config_service_v2_v2.ts +++ b/test/gapic_config_service_v2_v2.ts @@ -174,7 +174,7 @@ describe('v2.ConfigServiceV2Client', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -210,6 +210,38 @@ describe('v2.ConfigServiceV2Client', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'logging.example.com'); }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new configservicev2Module.v2.ConfigServiceV2Client(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } it('does not allow setting both universeDomain and universe_domain', () => { assert.throws(() => { new configservicev2Module.v2.ConfigServiceV2Client({ diff --git a/test/gapic_logging_service_v2_v2.ts b/test/gapic_logging_service_v2_v2.ts index 9d7246e8..ba8b6519 100644 --- a/test/gapic_logging_service_v2_v2.ts +++ b/test/gapic_logging_service_v2_v2.ts @@ -156,7 +156,7 @@ describe('v2.LoggingServiceV2Client', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -192,6 +192,38 @@ describe('v2.LoggingServiceV2Client', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'logging.example.com'); }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new loggingservicev2Module.v2.LoggingServiceV2Client(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } it('does not allow setting both universeDomain and universe_domain', () => { assert.throws(() => { new loggingservicev2Module.v2.LoggingServiceV2Client({ diff --git a/test/gapic_metrics_service_v2_v2.ts b/test/gapic_metrics_service_v2_v2.ts index 4124f150..cc9eba4c 100644 --- a/test/gapic_metrics_service_v2_v2.ts +++ b/test/gapic_metrics_service_v2_v2.ts @@ -142,7 +142,7 @@ describe('v2.MetricsServiceV2Client', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -178,6 +178,38 @@ describe('v2.MetricsServiceV2Client', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'logging.example.com'); }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new metricsservicev2Module.v2.MetricsServiceV2Client(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'logging.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } it('does not allow setting both universeDomain and universe_domain', () => { assert.throws(() => { new metricsservicev2Module.v2.MetricsServiceV2Client({