Skip to content

Commit aba9aee

Browse files
feat: add several fields to manage state of database encryption update (#1904)
* feat: add custom datetime format for Cloud Storage subscriptions PiperOrigin-RevId: 619178723 Source-Link: googleapis/googleapis@811a857 Source-Link: googleapis/googleapis-gen@768fb44 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzY4ZmI0NGQ0ZGFhZWE5NDZhMjkxZjY3OTVhNTBhZjI2YTUxNTQ4OCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 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 * 🦉 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 9589e9f commit aba9aee

File tree

10 files changed

+174
-16
lines changed

10 files changed

+174
-16
lines changed

protos/google/pubsub/v1/pubsub.proto

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ message IngestionDataSourceSettings {
203203
KINESIS_PERMISSION_DENIED = 2;
204204

205205
// Permission denied encountered while publishing to the topic. This can
206-
// happen due to Pub/Sub SA has not been granted the [appropriate publish
206+
// happen if the Pub/Sub SA has not been granted the [appropriate publish
207207
// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
208208
PUBLISH_PERMISSION_DENIED = 3;
209209

@@ -1197,6 +1197,11 @@ message CloudStorageConfig {
11971197
// Must not end in "/".
11981198
string filename_suffix = 3 [(google.api.field_behavior) = OPTIONAL];
11991199

1200+
// Optional. User-provided format string specifying how to represent datetimes
1201+
// in Cloud Storage filenames. See the [datetime format
1202+
// guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
1203+
string filename_datetime_format = 10 [(google.api.field_behavior) = OPTIONAL];
1204+
12001205
// Defaults to text format.
12011206
oneof output_format {
12021207
// Optional. If set, message data will be written to Cloud Storage in text

protos/protos.d.ts

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/protos.js

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/protos.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/v1/publisher_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,15 @@ export class PublisherClient {
123123
'Please set either universe_domain or universeDomain, but not both.'
124124
);
125125
}
126+
const universeDomainEnvVar =
127+
typeof process === 'object' && typeof process.env === 'object'
128+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
129+
: undefined;
126130
this._universeDomain =
127-
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
131+
opts?.universeDomain ??
132+
opts?.universe_domain ??
133+
universeDomainEnvVar ??
134+
'googleapis.com';
128135
this._servicePath = 'pubsub.' + this._universeDomain;
129136
const servicePath =
130137
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -177,7 +184,7 @@ export class PublisherClient {
177184

178185
// Determine the client header string.
179186
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
180-
if (typeof process !== 'undefined' && 'versions' in process) {
187+
if (typeof process === 'object' && 'versions' in process) {
181188
clientHeader.push(`gl-node/${process.versions.node}`);
182189
} else {
183190
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -350,7 +357,7 @@ export class PublisherClient {
350357
*/
351358
static get servicePath() {
352359
if (
353-
typeof process !== undefined &&
360+
typeof process === 'object' &&
354361
typeof process.emitWarning === 'function'
355362
) {
356363
process.emitWarning(
@@ -368,7 +375,7 @@ export class PublisherClient {
368375
*/
369376
static get apiEndpoint() {
370377
if (
371-
typeof process !== undefined &&
378+
typeof process === 'object' &&
372379
typeof process.emitWarning === 'function'
373380
) {
374381
process.emitWarning(

src/v1/schema_service_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@ export class SchemaServiceClient {
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 = 'pubsub.' + this._universeDomain;
128135
const servicePath =
129136
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -176,7 +183,7 @@ export class SchemaServiceClient {
176183

177184
// Determine the client header string.
178185
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
179-
if (typeof process !== 'undefined' && 'versions' in process) {
186+
if (typeof process === 'object' && 'versions' in process) {
180187
clientHeader.push(`gl-node/${process.versions.node}`);
181188
} else {
182189
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -326,7 +333,7 @@ export class SchemaServiceClient {
326333
*/
327334
static get servicePath() {
328335
if (
329-
typeof process !== undefined &&
336+
typeof process === 'object' &&
330337
typeof process.emitWarning === 'function'
331338
) {
332339
process.emitWarning(
@@ -344,7 +351,7 @@ export class SchemaServiceClient {
344351
*/
345352
static get apiEndpoint() {
346353
if (
347-
typeof process !== undefined &&
354+
typeof process === 'object' &&
348355
typeof process.emitWarning === 'function'
349356
) {
350357
process.emitWarning(

src/v1/subscriber_client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,15 @@ export class SubscriberClient {
124124
'Please set either universe_domain or universeDomain, but not both.'
125125
);
126126
}
127+
const universeDomainEnvVar =
128+
typeof process === 'object' && typeof process.env === 'object'
129+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
130+
: undefined;
127131
this._universeDomain =
128-
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
132+
opts?.universeDomain ??
133+
opts?.universe_domain ??
134+
universeDomainEnvVar ??
135+
'googleapis.com';
129136
this._servicePath = 'pubsub.' + this._universeDomain;
130137
const servicePath =
131138
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
@@ -178,7 +185,7 @@ export class SubscriberClient {
178185

179186
// Determine the client header string.
180187
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
181-
if (typeof process !== 'undefined' && 'versions' in process) {
188+
if (typeof process === 'object' && 'versions' in process) {
182189
clientHeader.push(`gl-node/${process.versions.node}`);
183190
} else {
184191
clientHeader.push(`gl-web/${this._gaxModule.version}`);
@@ -359,7 +366,7 @@ export class SubscriberClient {
359366
*/
360367
static get servicePath() {
361368
if (
362-
typeof process !== undefined &&
369+
typeof process === 'object' &&
363370
typeof process.emitWarning === 'function'
364371
) {
365372
process.emitWarning(
@@ -377,7 +384,7 @@ export class SubscriberClient {
377384
*/
378385
static get apiEndpoint() {
379386
if (
380-
typeof process !== undefined &&
387+
typeof process === 'object' &&
381388
typeof process.emitWarning === 'function'
382389
) {
383390
process.emitWarning(

test/gapic_publisher_v1.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('v1.PublisherClient', () => {
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', () => {
@@ -176,6 +176,38 @@ describe('v1.PublisherClient', () => {
176176
const servicePath = client.apiEndpoint;
177177
assert.strictEqual(servicePath, 'pubsub.example.com');
178178
});
179+
180+
if (typeof process === 'object' && 'env' in process) {
181+
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
182+
it('sets apiEndpoint from environment variable', () => {
183+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
184+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
185+
const client = new publisherModule.v1.PublisherClient();
186+
const servicePath = client.apiEndpoint;
187+
assert.strictEqual(servicePath, 'pubsub.example.com');
188+
if (saved) {
189+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
190+
} else {
191+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
192+
}
193+
});
194+
195+
it('value configured in code has priority over environment variable', () => {
196+
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
197+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
198+
const client = new publisherModule.v1.PublisherClient({
199+
universeDomain: 'configured.example.com',
200+
});
201+
const servicePath = client.apiEndpoint;
202+
assert.strictEqual(servicePath, 'pubsub.configured.example.com');
203+
if (saved) {
204+
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
205+
} else {
206+
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
207+
}
208+
});
209+
});
210+
}
179211
it('does not allow setting both universeDomain and universe_domain', () => {
180212
assert.throws(() => {
181213
new publisherModule.v1.PublisherClient({

test/gapic_schema_service_v1.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('v1.SchemaServiceClient', () => {
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('v1.SchemaServiceClient', () => {
178178
const servicePath = client.apiEndpoint;
179179
assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient();
188+
const servicePath = client.apiEndpoint;
189+
assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient({
201+
universeDomain: 'configured.example.com',
202+
});
203+
const servicePath = client.apiEndpoint;
204+
assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient({

0 commit comments

Comments
 (0)