Skip to content

Commit d89fd1d

Browse files
feat: Trusted Private Cloud support, use the universeDomain parameter (#1878)
* feat: Trusted Private Cloud support, use the universeDomain parameter feat: auto populate UUID fields where needed fix: revert changes to streaming retries Use gapic-generator-typescript v4.4.0. PiperOrigin-RevId: 603757799 Source-Link: googleapis/googleapis@1a45bf7 Source-Link: googleapis/googleapis-gen@19ca4b4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTljYTRiNDVhNTNkMDBjYjdiZGQ5NGI0NDJiNjBiZDIzN2RmZTEyMyJ9 * 🦉 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 84df422 commit d89fd1d

File tree

7 files changed

+351
-31
lines changed

7 files changed

+351
-31
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ system-test/*key.json
1212
.DS_Store
1313
package-lock.json
1414
__pycache__
15-
samples/build/

src/v1/publisher_client.ts

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
import {Transform} from 'stream';
3232
import * as protos from '../../protos/protos';
3333
import jsonProtos = require('../../protos/protos.json');
34+
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1/publisher_client_config.json`.
@@ -53,6 +54,8 @@ export class PublisherClient {
5354
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
5455
private _protos: {};
5556
private _defaults: {[method: string]: gax.CallSettings};
57+
private _universeDomain: string;
58+
private _servicePath: string;
5659
auth: gax.GoogleAuth;
5760
descriptors: Descriptors = {
5861
page: {},
@@ -111,8 +114,20 @@ export class PublisherClient {
111114
) {
112115
// Ensure that options include all the required fields.
113116
const staticMembers = this.constructor as typeof PublisherClient;
117+
if (
118+
opts?.universe_domain &&
119+
opts?.universeDomain &&
120+
opts?.universe_domain !== opts?.universeDomain
121+
) {
122+
throw new Error(
123+
'Please set either universe_domain or universeDomain, but not both.'
124+
);
125+
}
126+
this._universeDomain =
127+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
128+
this._servicePath = 'pubsub.' + this._universeDomain;
114129
const servicePath =
115-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
130+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
116131
this._providedCustomServicePath = !!(
117132
opts?.servicePath || opts?.apiEndpoint
118133
);
@@ -127,7 +142,7 @@ export class PublisherClient {
127142
opts.numericEnums = true;
128143

129144
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
130-
if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
145+
if (servicePath !== this._servicePath && !('scopes' in opts)) {
131146
opts['scopes'] = staticMembers.scopes;
132147
}
133148

@@ -152,10 +167,10 @@ export class PublisherClient {
152167
this.auth.useJWTAccessWithScope = true;
153168

154169
// Set defaultServicePath on the auth object.
155-
this.auth.defaultServicePath = staticMembers.servicePath;
170+
this.auth.defaultServicePath = this._servicePath;
156171

157172
// Set the default scopes in auth client if needed.
158-
if (servicePath === staticMembers.servicePath) {
173+
if (servicePath === this._servicePath) {
159174
this.auth.defaultScopes = staticMembers.scopes;
160175
}
161176
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts);
@@ -330,21 +345,61 @@ export class PublisherClient {
330345

331346
/**
332347
* The DNS address for this API service.
348+
* @deprecated
333349
* @returns {string} The DNS address for this service.
334350
*/
335351
static get servicePath() {
352+
if (
353+
typeof process !== undefined &&
354+
typeof process.emitWarning === 'function'
355+
) {
356+
process.emitWarning(
357+
'Static servicePath is deprecated, please use the instance method instead.',
358+
'DeprecationWarning'
359+
);
360+
}
336361
return 'pubsub.googleapis.com';
337362
}
338363

339364
/**
340-
* The DNS address for this API service - same as servicePath(),
365+
* The DNS address for this API service - same as servicePath,
341366
* exists for compatibility reasons.
367+
* @deprecated
342368
* @returns {string} The DNS address for this service.
343369
*/
344370
static get apiEndpoint() {
371+
if (
372+
typeof process !== undefined &&
373+
typeof process.emitWarning === 'function'
374+
) {
375+
process.emitWarning(
376+
'Static apiEndpoint is deprecated, please use the instance method instead.',
377+
'DeprecationWarning'
378+
);
379+
}
345380
return 'pubsub.googleapis.com';
346381
}
347382

383+
/**
384+
* The DNS address for this API service.
385+
* @returns {string} The DNS address for this service.
386+
*/
387+
get servicePath() {
388+
return this._servicePath;
389+
}
390+
391+
/**
392+
* The DNS address for this API service - same as servicePath().
393+
* @returns {string} The DNS address for this service.
394+
*/
395+
get apiEndpoint() {
396+
return this._servicePath;
397+
}
398+
399+
get universeDomain() {
400+
return this._universeDomain;
401+
}
402+
348403
/**
349404
* The port for this API service.
350405
* @returns {number} The default port for this service.

src/v1/schema_service_client.ts

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
import {Transform} from 'stream';
3232
import * as protos from '../../protos/protos';
3333
import jsonProtos = require('../../protos/protos.json');
34+
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1/schema_service_client_config.json`.
@@ -52,6 +53,8 @@ export class SchemaServiceClient {
5253
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
5354
private _protos: {};
5455
private _defaults: {[method: string]: gax.CallSettings};
56+
private _universeDomain: string;
57+
private _servicePath: string;
5558
auth: gax.GoogleAuth;
5659
descriptors: Descriptors = {
5760
page: {},
@@ -110,8 +113,20 @@ export class SchemaServiceClient {
110113
) {
111114
// Ensure that options include all the required fields.
112115
const staticMembers = this.constructor as typeof SchemaServiceClient;
116+
if (
117+
opts?.universe_domain &&
118+
opts?.universeDomain &&
119+
opts?.universe_domain !== opts?.universeDomain
120+
) {
121+
throw new Error(
122+
'Please set either universe_domain or universeDomain, but not both.'
123+
);
124+
}
125+
this._universeDomain =
126+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
127+
this._servicePath = 'pubsub.' + this._universeDomain;
113128
const servicePath =
114-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
129+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
115130
this._providedCustomServicePath = !!(
116131
opts?.servicePath || opts?.apiEndpoint
117132
);
@@ -126,7 +141,7 @@ export class SchemaServiceClient {
126141
opts.numericEnums = true;
127142

128143
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
129-
if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
144+
if (servicePath !== this._servicePath && !('scopes' in opts)) {
130145
opts['scopes'] = staticMembers.scopes;
131146
}
132147

@@ -151,10 +166,10 @@ export class SchemaServiceClient {
151166
this.auth.useJWTAccessWithScope = true;
152167

153168
// Set defaultServicePath on the auth object.
154-
this.auth.defaultServicePath = staticMembers.servicePath;
169+
this.auth.defaultServicePath = this._servicePath;
155170

156171
// Set the default scopes in auth client if needed.
157-
if (servicePath === staticMembers.servicePath) {
172+
if (servicePath === this._servicePath) {
158173
this.auth.defaultScopes = staticMembers.scopes;
159174
}
160175
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts);
@@ -306,21 +321,61 @@ export class SchemaServiceClient {
306321

307322
/**
308323
* The DNS address for this API service.
324+
* @deprecated
309325
* @returns {string} The DNS address for this service.
310326
*/
311327
static get servicePath() {
328+
if (
329+
typeof process !== undefined &&
330+
typeof process.emitWarning === 'function'
331+
) {
332+
process.emitWarning(
333+
'Static servicePath is deprecated, please use the instance method instead.',
334+
'DeprecationWarning'
335+
);
336+
}
312337
return 'pubsub.googleapis.com';
313338
}
314339

315340
/**
316-
* The DNS address for this API service - same as servicePath(),
341+
* The DNS address for this API service - same as servicePath,
317342
* exists for compatibility reasons.
343+
* @deprecated
318344
* @returns {string} The DNS address for this service.
319345
*/
320346
static get apiEndpoint() {
347+
if (
348+
typeof process !== undefined &&
349+
typeof process.emitWarning === 'function'
350+
) {
351+
process.emitWarning(
352+
'Static apiEndpoint is deprecated, please use the instance method instead.',
353+
'DeprecationWarning'
354+
);
355+
}
321356
return 'pubsub.googleapis.com';
322357
}
323358

359+
/**
360+
* The DNS address for this API service.
361+
* @returns {string} The DNS address for this service.
362+
*/
363+
get servicePath() {
364+
return this._servicePath;
365+
}
366+
367+
/**
368+
* The DNS address for this API service - same as servicePath().
369+
* @returns {string} The DNS address for this service.
370+
*/
371+
get apiEndpoint() {
372+
return this._servicePath;
373+
}
374+
375+
get universeDomain() {
376+
return this._universeDomain;
377+
}
378+
324379
/**
325380
* The port for this API service.
326381
* @returns {number} The default port for this service.

src/v1/subscriber_client.ts

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
import {Transform, PassThrough} from 'stream';
3232
import * as protos from '../../protos/protos';
3333
import jsonProtos = require('../../protos/protos.json');
34+
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1/subscriber_client_config.json`.
@@ -54,6 +55,8 @@ export class SubscriberClient {
5455
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
5556
private _protos: {};
5657
private _defaults: {[method: string]: gax.CallSettings};
58+
private _universeDomain: string;
59+
private _servicePath: string;
5760
auth: gax.GoogleAuth;
5861
descriptors: Descriptors = {
5962
page: {},
@@ -112,8 +115,20 @@ export class SubscriberClient {
112115
) {
113116
// Ensure that options include all the required fields.
114117
const staticMembers = this.constructor as typeof SubscriberClient;
118+
if (
119+
opts?.universe_domain &&
120+
opts?.universeDomain &&
121+
opts?.universe_domain !== opts?.universeDomain
122+
) {
123+
throw new Error(
124+
'Please set either universe_domain or universeDomain, but not both.'
125+
);
126+
}
127+
this._universeDomain =
128+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
129+
this._servicePath = 'pubsub.' + this._universeDomain;
115130
const servicePath =
116-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
131+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
117132
this._providedCustomServicePath = !!(
118133
opts?.servicePath || opts?.apiEndpoint
119134
);
@@ -128,7 +143,7 @@ export class SubscriberClient {
128143
opts.numericEnums = true;
129144

130145
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
131-
if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
146+
if (servicePath !== this._servicePath && !('scopes' in opts)) {
132147
opts['scopes'] = staticMembers.scopes;
133148
}
134149

@@ -153,10 +168,10 @@ export class SubscriberClient {
153168
this.auth.useJWTAccessWithScope = true;
154169

155170
// Set defaultServicePath on the auth object.
156-
this.auth.defaultServicePath = staticMembers.servicePath;
171+
this.auth.defaultServicePath = this._servicePath;
157172

158173
// Set the default scopes in auth client if needed.
159-
if (servicePath === staticMembers.servicePath) {
174+
if (servicePath === this._servicePath) {
160175
this.auth.defaultScopes = staticMembers.scopes;
161176
}
162177
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts);
@@ -222,7 +237,7 @@ export class SubscriberClient {
222237
streamingPull: new this._gaxModule.StreamDescriptor(
223238
this._gaxModule.StreamType.BIDI_STREAMING,
224239
!!opts.fallback,
225-
/* gaxStreamingRetries: */ true
240+
/* gaxStreamingRetries: */ false
226241
),
227242
};
228243

@@ -339,21 +354,61 @@ export class SubscriberClient {
339354

340355
/**
341356
* The DNS address for this API service.
357+
* @deprecated
342358
* @returns {string} The DNS address for this service.
343359
*/
344360
static get servicePath() {
361+
if (
362+
typeof process !== undefined &&
363+
typeof process.emitWarning === 'function'
364+
) {
365+
process.emitWarning(
366+
'Static servicePath is deprecated, please use the instance method instead.',
367+
'DeprecationWarning'
368+
);
369+
}
345370
return 'pubsub.googleapis.com';
346371
}
347372

348373
/**
349-
* The DNS address for this API service - same as servicePath(),
374+
* The DNS address for this API service - same as servicePath,
350375
* exists for compatibility reasons.
376+
* @deprecated
351377
* @returns {string} The DNS address for this service.
352378
*/
353379
static get apiEndpoint() {
380+
if (
381+
typeof process !== undefined &&
382+
typeof process.emitWarning === 'function'
383+
) {
384+
process.emitWarning(
385+
'Static apiEndpoint is deprecated, please use the instance method instead.',
386+
'DeprecationWarning'
387+
);
388+
}
354389
return 'pubsub.googleapis.com';
355390
}
356391

392+
/**
393+
* The DNS address for this API service.
394+
* @returns {string} The DNS address for this service.
395+
*/
396+
get servicePath() {
397+
return this._servicePath;
398+
}
399+
400+
/**
401+
* The DNS address for this API service - same as servicePath().
402+
* @returns {string} The DNS address for this service.
403+
*/
404+
get apiEndpoint() {
405+
return this._servicePath;
406+
}
407+
408+
get universeDomain() {
409+
return this._universeDomain;
410+
}
411+
357412
/**
358413
* The port for this API service.
359414
* @returns {number} The default port for this service.

0 commit comments

Comments
 (0)