diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index 93e1e84a7..c3a90cd40 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -203,7 +203,7 @@ message IngestionDataSourceSettings { KINESIS_PERMISSION_DENIED = 2; // Permission denied encountered while publishing to the topic. This can - // happen due to Pub/Sub SA has not been granted the [appropriate publish + // happen if the Pub/Sub SA has not been granted the [appropriate publish // permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher) PUBLISH_PERMISSION_DENIED = 3; @@ -1197,6 +1197,11 @@ message CloudStorageConfig { // Must not end in "/". string filename_suffix = 3 [(google.api.field_behavior) = OPTIONAL]; + // Optional. User-provided format string specifying how to represent datetimes + // in Cloud Storage filenames. See the [datetime format + // guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names). + string filename_datetime_format = 10 [(google.api.field_behavior) = OPTIONAL]; + // Defaults to text format. oneof output_format { // Optional. If set, message data will be written to Cloud Storage in text diff --git a/protos/protos.d.ts b/protos/protos.d.ts index dda11424e..9346f23a8 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -3733,6 +3733,9 @@ export namespace google { /** CloudStorageConfig filenameSuffix */ filenameSuffix?: (string|null); + /** CloudStorageConfig filenameDatetimeFormat */ + filenameDatetimeFormat?: (string|null); + /** CloudStorageConfig textConfig */ textConfig?: (google.pubsub.v1.CloudStorageConfig.ITextConfig|null); @@ -3767,6 +3770,9 @@ export namespace google { /** CloudStorageConfig filenameSuffix. */ public filenameSuffix: string; + /** CloudStorageConfig filenameDatetimeFormat. */ + public filenameDatetimeFormat: string; + /** CloudStorageConfig textConfig. */ public textConfig?: (google.pubsub.v1.CloudStorageConfig.ITextConfig|null); diff --git a/protos/protos.js b/protos/protos.js index fa620f8e5..29e7fa666 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -8644,6 +8644,7 @@ * @property {string|null} [bucket] CloudStorageConfig bucket * @property {string|null} [filenamePrefix] CloudStorageConfig filenamePrefix * @property {string|null} [filenameSuffix] CloudStorageConfig filenameSuffix + * @property {string|null} [filenameDatetimeFormat] CloudStorageConfig filenameDatetimeFormat * @property {google.pubsub.v1.CloudStorageConfig.ITextConfig|null} [textConfig] CloudStorageConfig textConfig * @property {google.pubsub.v1.CloudStorageConfig.IAvroConfig|null} [avroConfig] CloudStorageConfig avroConfig * @property {google.protobuf.IDuration|null} [maxDuration] CloudStorageConfig maxDuration @@ -8690,6 +8691,14 @@ */ CloudStorageConfig.prototype.filenameSuffix = ""; + /** + * CloudStorageConfig filenameDatetimeFormat. + * @member {string} filenameDatetimeFormat + * @memberof google.pubsub.v1.CloudStorageConfig + * @instance + */ + CloudStorageConfig.prototype.filenameDatetimeFormat = ""; + /** * CloudStorageConfig textConfig. * @member {google.pubsub.v1.CloudStorageConfig.ITextConfig|null|undefined} textConfig @@ -8784,6 +8793,8 @@ writer.uint32(/* id 7, wireType 0 =*/56).int64(message.maxBytes); if (message.state != null && Object.hasOwnProperty.call(message, "state")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.state); + if (message.filenameDatetimeFormat != null && Object.hasOwnProperty.call(message, "filenameDatetimeFormat")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.filenameDatetimeFormat); return writer; }; @@ -8830,6 +8841,10 @@ message.filenameSuffix = reader.string(); break; } + case 10: { + message.filenameDatetimeFormat = reader.string(); + break; + } case 4: { message.textConfig = $root.google.pubsub.v1.CloudStorageConfig.TextConfig.decode(reader, reader.uint32()); break; @@ -8895,6 +8910,9 @@ if (message.filenameSuffix != null && message.hasOwnProperty("filenameSuffix")) if (!$util.isString(message.filenameSuffix)) return "filenameSuffix: string expected"; + if (message.filenameDatetimeFormat != null && message.hasOwnProperty("filenameDatetimeFormat")) + if (!$util.isString(message.filenameDatetimeFormat)) + return "filenameDatetimeFormat: string expected"; if (message.textConfig != null && message.hasOwnProperty("textConfig")) { properties.outputFormat = 1; { @@ -8953,6 +8971,8 @@ message.filenamePrefix = String(object.filenamePrefix); if (object.filenameSuffix != null) message.filenameSuffix = String(object.filenameSuffix); + if (object.filenameDatetimeFormat != null) + message.filenameDatetimeFormat = String(object.filenameDatetimeFormat); if (object.textConfig != null) { if (typeof object.textConfig !== "object") throw TypeError(".google.pubsub.v1.CloudStorageConfig.textConfig: object expected"); @@ -9032,6 +9052,7 @@ } else object.maxBytes = options.longs === String ? "0" : 0; object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.filenameDatetimeFormat = ""; } if (message.bucket != null && message.hasOwnProperty("bucket")) object.bucket = message.bucket; @@ -9058,6 +9079,8 @@ object.maxBytes = options.longs === String ? $util.Long.prototype.toString.call(message.maxBytes) : options.longs === Number ? new $util.LongBits(message.maxBytes.low >>> 0, message.maxBytes.high >>> 0).toNumber() : message.maxBytes; if (message.state != null && message.hasOwnProperty("state")) object.state = options.enums === String ? $root.google.pubsub.v1.CloudStorageConfig.State[message.state] === undefined ? message.state : $root.google.pubsub.v1.CloudStorageConfig.State[message.state] : message.state; + if (message.filenameDatetimeFormat != null && message.hasOwnProperty("filenameDatetimeFormat")) + object.filenameDatetimeFormat = message.filenameDatetimeFormat; return object; }; diff --git a/protos/protos.json b/protos/protos.json index 9fecd46b3..04ec87360 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1320,6 +1320,13 @@ "(google.api.field_behavior)": "OPTIONAL" } }, + "filenameDatetimeFormat": { + "type": "string", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, "textConfig": { "type": "TextConfig", "id": 4, diff --git a/src/v1/publisher_client.ts b/src/v1/publisher_client.ts index d12bf10cc..d281e1f0e 100644 --- a/src/v1/publisher_client.ts +++ b/src/v1/publisher_client.ts @@ -123,8 +123,15 @@ export class PublisherClient { '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 = 'pubsub.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -177,7 +184,7 @@ export class PublisherClient { // 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}`); @@ -350,7 +357,7 @@ export class PublisherClient { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -368,7 +375,7 @@ export class PublisherClient { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/src/v1/schema_service_client.ts b/src/v1/schema_service_client.ts index 2e42e4633..068b0a247 100644 --- a/src/v1/schema_service_client.ts +++ b/src/v1/schema_service_client.ts @@ -122,8 +122,15 @@ export class SchemaServiceClient { '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 = 'pubsub.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -176,7 +183,7 @@ export class SchemaServiceClient { // 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}`); @@ -326,7 +333,7 @@ export class SchemaServiceClient { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -344,7 +351,7 @@ export class SchemaServiceClient { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index 09b8aee5c..2c0e820f7 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -124,8 +124,15 @@ export class SubscriberClient { '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 = 'pubsub.' + this._universeDomain; const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; @@ -178,7 +185,7 @@ export class SubscriberClient { // 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}`); @@ -359,7 +366,7 @@ export class SubscriberClient { */ static get servicePath() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( @@ -377,7 +384,7 @@ export class SubscriberClient { */ static get apiEndpoint() { if ( - typeof process !== undefined && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { process.emitWarning( diff --git a/test/gapic_publisher_v1.ts b/test/gapic_publisher_v1.ts index d1ded0f7f..f2254a188 100644 --- a/test/gapic_publisher_v1.ts +++ b/test/gapic_publisher_v1.ts @@ -142,7 +142,7 @@ describe('v1.PublisherClient', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -176,6 +176,38 @@ describe('v1.PublisherClient', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'pubsub.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 publisherModule.v1.PublisherClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 publisherModule.v1.PublisherClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 publisherModule.v1.PublisherClient({ diff --git a/test/gapic_schema_service_v1.ts b/test/gapic_schema_service_v1.ts index cf463b46c..cd96d3d23 100644 --- a/test/gapic_schema_service_v1.ts +++ b/test/gapic_schema_service_v1.ts @@ -142,7 +142,7 @@ describe('v1.SchemaServiceClient', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -178,6 +178,38 @@ describe('v1.SchemaServiceClient', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 schemaserviceModule.v1.SchemaServiceClient({ diff --git a/test/gapic_subscriber_v1.ts b/test/gapic_subscriber_v1.ts index a266bc046..18c097733 100644 --- a/test/gapic_subscriber_v1.ts +++ b/test/gapic_subscriber_v1.ts @@ -156,7 +156,7 @@ describe('v1.SubscriberClient', () => { }); if ( - typeof process !== 'undefined' && + typeof process === 'object' && typeof process.emitWarning === 'function' ) { it('throws DeprecationWarning if static servicePath is used', () => { @@ -190,6 +190,38 @@ describe('v1.SubscriberClient', () => { const servicePath = client.apiEndpoint; assert.strictEqual(servicePath, 'pubsub.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 subscriberModule.v1.SubscriberClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 subscriberModule.v1.SubscriberClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'pubsub.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 subscriberModule.v1.SubscriberClient({