Skip to content

Commit

Permalink
feat: add several fields to manage state of database encryption update (
Browse files Browse the repository at this point in the history
googleapis#1904)

* feat: add custom datetime format for Cloud Storage subscriptions

PiperOrigin-RevId: 619178723

Source-Link: googleapis/googleapis@811a857

Source-Link: https://github.com/googleapis/googleapis-gen/commit/768fb44d4daaea946a291f6795a50af26a515488
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: 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

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Apr 2, 2024
1 parent 9589e9f commit aba9aee
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 16 deletions.
7 changes: 6 additions & 1 deletion protos/google/pubsub/v1/pubsub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions src/v1/publisher_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -350,7 +357,7 @@ export class PublisherClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -368,7 +375,7 @@ export class PublisherClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
15 changes: 11 additions & 4 deletions src/v1/schema_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -326,7 +333,7 @@ export class SchemaServiceClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -344,7 +351,7 @@ export class SchemaServiceClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
15 changes: 11 additions & 4 deletions src/v1/subscriber_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -359,7 +366,7 @@ export class SubscriberClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -377,7 +384,7 @@ export class SubscriberClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
34 changes: 33 additions & 1 deletion test/gapic_publisher_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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({
Expand Down
34 changes: 33 additions & 1 deletion test/gapic_schema_service_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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({
Expand Down
Loading

0 comments on commit aba9aee

Please sign in to comment.