Skip to content

Commit 4137f7b

Browse files
feat: add several fields to manage state of database encryption update (#1495)
* feat: add several fields to manage state of database encryption update PiperOrigin-RevId: 619289281 Source-Link: googleapis/googleapis@3a7c334 Source-Link: googleapis/googleapis-gen@6a8c733 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 <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent cee3b46 commit 4137f7b

6 files changed

+132
-15
lines changed

src/v2/config_service_v2_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@ export class ConfigServiceV2Client {
122122
'Please set either universe_domain or universeDomain, but not both.'
123123
);
124124
}
125+
const universeDomainEnvVar =
126+
typeof process === 'object' && typeof process.env === 'object'
127+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
128+
: undefined;
125129
this._universeDomain =
126-
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
130+
opts?.universeDomain ??
131+
opts?.universe_domain ??
132+
universeDomainEnvVar ??
133+
'googleapis.com';
127134
this._servicePath = 'logging.' + this._universeDomain;
128135
const servicePath =
129136
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -175,7 +182,7 @@ export class ConfigServiceV2Client {
175182

176183
// Determine the client header string.
177184
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
178-
if (typeof process !== 'undefined' && 'versions' in process) {
185+
if (typeof process === 'object' && 'versions' in process) {
179186
clientHeader.push(`gl-node/${process.versions.node}`);
180187
} else {
181188
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -578,7 +585,7 @@ export class ConfigServiceV2Client {
578585
*/
579586
static get servicePath() {
580587
if (
581-
typeof process !== undefined &&
588+
typeof process === 'object' &&
582589
typeof process.emitWarning === 'function'
583590
) {
584591
process.emitWarning(
@@ -596,7 +603,7 @@ export class ConfigServiceV2Client {
596603
*/
597604
static get apiEndpoint() {
598605
if (
599-
typeof process !== undefined &&
606+
typeof process === 'object' &&
600607
typeof process.emitWarning === 'function'
601608
) {
602609
process.emitWarning(

src/v2/logging_service_v2_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ export class LoggingServiceV2Client {
119119
'Please set either universe_domain or universeDomain, but not both.'
120120
);
121121
}
122+
const universeDomainEnvVar =
123+
typeof process === 'object' && typeof process.env === 'object'
124+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
125+
: undefined;
122126
this._universeDomain =
123-
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
127+
opts?.universeDomain ??
128+
opts?.universe_domain ??
129+
universeDomainEnvVar ??
130+
'googleapis.com';
124131
this._servicePath = 'logging.' + this._universeDomain;
125132
const servicePath =
126133
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -172,7 +179,7 @@ export class LoggingServiceV2Client {
172179

173180
// Determine the client header string.
174181
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
175-
if (typeof process !== 'undefined' && 'versions' in process) {
182+
if (typeof process === 'object' && 'versions' in process) {
176183
clientHeader.push(`gl-node/${process.versions.node}`);
177184
} else {
178185
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -457,7 +464,7 @@ export class LoggingServiceV2Client {
457464
*/
458465
static get servicePath() {
459466
if (
460-
typeof process !== undefined &&
467+
typeof process === 'object' &&
461468
typeof process.emitWarning === 'function'
462469
) {
463470
process.emitWarning(
@@ -475,7 +482,7 @@ export class LoggingServiceV2Client {
475482
*/
476483
static get apiEndpoint() {
477484
if (
478-
typeof process !== undefined &&
485+
typeof process === 'object' &&
479486
typeof process.emitWarning === 'function'
480487
) {
481488
process.emitWarning(

src/v2/metrics_service_v2_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ export class MetricsServiceV2Client {
119119
'Please set either universe_domain or universeDomain, but not both.'
120120
);
121121
}
122+
const universeDomainEnvVar =
123+
typeof process === 'object' && typeof process.env === 'object'
124+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
125+
: undefined;
122126
this._universeDomain =
123-
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
127+
opts?.universeDomain ??
128+
opts?.universe_domain ??
129+
universeDomainEnvVar ??
130+
'googleapis.com';
124131
this._servicePath = 'logging.' + this._universeDomain;
125132
const servicePath =
126133
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -172,7 +179,7 @@ export class MetricsServiceV2Client {
172179

173180
// Determine the client header string.
174181
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
175-
if (typeof process !== 'undefined' && 'versions' in process) {
182+
if (typeof process === 'object' && 'versions' in process) {
176183
clientHeader.push(`gl-node/${process.versions.node}`);
177184
} else {
178185
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -404,7 +411,7 @@ export class MetricsServiceV2Client {
404411
*/
405412
static get servicePath() {
406413
if (
407-
typeof process !== undefined &&
414+
typeof process === 'object' &&
408415
typeof process.emitWarning === 'function'
409416
) {
410417
process.emitWarning(
@@ -422,7 +429,7 @@ export class MetricsServiceV2Client {
422429
*/
423430
static get apiEndpoint() {
424431
if (
425-
typeof process !== undefined &&
432+
typeof process === 'object' &&
426433
typeof process.emitWarning === 'function'
427434
) {
428435
process.emitWarning(

test/gapic_config_service_v2_v2.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('v2.ConfigServiceV2Client', () => {
174174
});
175175

176176
if (
177-
typeof process !== 'undefined' &&
177+
typeof process === 'object' &&
178178
typeof process.emitWarning === 'function'
179179
) {
180180
it('throws DeprecationWarning if static servicePath is used', () => {
@@ -210,6 +210,38 @@ describe('v2.ConfigServiceV2Client', () => {
210210
const servicePath = client.apiEndpoint;
211211
assert.strictEqual(servicePath, 'logging.example.com');
212212
});
213+
214+
if (typeof process === 'object' && 'env' in process) {
215+
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
216+
it('sets apiEndpoint from environment variable', () => {
217+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
218+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
219+
const client = new configservicev2Module.v2.ConfigServiceV2Client();
220+
const servicePath = client.apiEndpoint;
221+
assert.strictEqual(servicePath, 'logging.example.com');
222+
if (saved) {
223+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
224+
} else {
225+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
226+
}
227+
});
228+
229+
it('value configured in code has priority over environment variable', () => {
230+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
231+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
232+
const client = new configservicev2Module.v2.ConfigServiceV2Client({
233+
universeDomain: 'configured.example.com',
234+
});
235+
const servicePath = client.apiEndpoint;
236+
assert.strictEqual(servicePath, 'logging.configured.example.com');
237+
if (saved) {
238+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
239+
} else {
240+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
241+
}
242+
});
243+
});
244+
}
213245
it('does not allow setting both universeDomain and universe_domain', () => {
214246
assert.throws(() => {
215247
new configservicev2Module.v2.ConfigServiceV2Client({

test/gapic_logging_service_v2_v2.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('v2.LoggingServiceV2Client', () => {
156156
});
157157

158158
if (
159-
typeof process !== 'undefined' &&
159+
typeof process === 'object' &&
160160
typeof process.emitWarning === 'function'
161161
) {
162162
it('throws DeprecationWarning if static servicePath is used', () => {
@@ -192,6 +192,38 @@ describe('v2.LoggingServiceV2Client', () => {
192192
const servicePath = client.apiEndpoint;
193193
assert.strictEqual(servicePath, 'logging.example.com');
194194
});
195+
196+
if (typeof process === 'object' && 'env' in process) {
197+
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
198+
it('sets apiEndpoint from environment variable', () => {
199+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
200+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
201+
const client = new loggingservicev2Module.v2.LoggingServiceV2Client();
202+
const servicePath = client.apiEndpoint;
203+
assert.strictEqual(servicePath, 'logging.example.com');
204+
if (saved) {
205+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
206+
} else {
207+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
208+
}
209+
});
210+
211+
it('value configured in code has priority over environment variable', () => {
212+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
213+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
214+
const client = new loggingservicev2Module.v2.LoggingServiceV2Client({
215+
universeDomain: 'configured.example.com',
216+
});
217+
const servicePath = client.apiEndpoint;
218+
assert.strictEqual(servicePath, 'logging.configured.example.com');
219+
if (saved) {
220+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
221+
} else {
222+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
223+
}
224+
});
225+
});
226+
}
195227
it('does not allow setting both universeDomain and universe_domain', () => {
196228
assert.throws(() => {
197229
new loggingservicev2Module.v2.LoggingServiceV2Client({

test/gapic_metrics_service_v2_v2.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('v2.MetricsServiceV2Client', () => {
142142
});
143143

144144
if (
145-
typeof process !== 'undefined' &&
145+
typeof process === 'object' &&
146146
typeof process.emitWarning === 'function'
147147
) {
148148
it('throws DeprecationWarning if static servicePath is used', () => {
@@ -178,6 +178,38 @@ describe('v2.MetricsServiceV2Client', () => {
178178
const servicePath = client.apiEndpoint;
179179
assert.strictEqual(servicePath, 'logging.example.com');
180180
});
181+
182+
if (typeof process === 'object' && 'env' in process) {
183+
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
184+
it('sets apiEndpoint from environment variable', () => {
185+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
186+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
187+
const client = new metricsservicev2Module.v2.MetricsServiceV2Client();
188+
const servicePath = client.apiEndpoint;
189+
assert.strictEqual(servicePath, 'logging.example.com');
190+
if (saved) {
191+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
192+
} else {
193+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
194+
}
195+
});
196+
197+
it('value configured in code has priority over environment variable', () => {
198+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
199+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
200+
const client = new metricsservicev2Module.v2.MetricsServiceV2Client({
201+
universeDomain: 'configured.example.com',
202+
});
203+
const servicePath = client.apiEndpoint;
204+
assert.strictEqual(servicePath, 'logging.configured.example.com');
205+
if (saved) {
206+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
207+
} else {
208+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
209+
}
210+
});
211+
});
212+
}
181213
it('does not allow setting both universeDomain and universe_domain', () => {
182214
assert.throws(() => {
183215
new metricsservicev2Module.v2.MetricsServiceV2Client({

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy