Skip to content

Commit 88763bb

Browse files
feat: Trusted Private Cloud support, use the universeDomain parameter (#5027)
* feat: Trusted Private Cloud support, use the universeDomain parameter PiperOrigin-RevId: 604765466 Source-Link: googleapis/googleapis@40203ca Source-Link: googleapis/googleapis-gen@07b7f3d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYWVudGVycHJpc2UvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY29tbWVuZGVyLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlZGlzLWNsdXN0ZXIvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlZGlzLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlbWFuYWdlci8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlc2V0dGluZ3MvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja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xlLWNsb3VkLXNlcnZpY2VkaXJlY3RvcnkvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2VoZWFsdGgvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNoZWxsLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNwZWVjaC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNxbC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN0b3JhZ2VpbnNpZ2h0cy8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN1cHBvcnQvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== * 🦉 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 7244cab commit 88763bb

296 files changed

Lines changed: 10069 additions & 1397 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/google-cloud-recaptchaenterprise/samples/generated/v1/recaptcha_enterprise_service.list_firewall_policies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function main(parent) {
5757
};
5858

5959
// Run request
60-
const iterable = await recaptchaenterpriseClient.listFirewallPoliciesAsync(request);
60+
const iterable = recaptchaenterpriseClient.listFirewallPoliciesAsync(request);
6161
for await (const response of iterable) {
6262
console.log(response);
6363
}

packages/google-cloud-recaptchaenterprise/samples/generated/v1/recaptcha_enterprise_service.list_keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function main(parent) {
5757
};
5858

5959
// Run request
60-
const iterable = await recaptchaenterpriseClient.listKeysAsync(request);
60+
const iterable = recaptchaenterpriseClient.listKeysAsync(request);
6161
for await (const response of iterable) {
6262
console.log(response);
6363
}

packages/google-cloud-recaptchaenterprise/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function main(parent) {
6161
};
6262

6363
// Run request
64-
const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request);
64+
const iterable = recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request);
6565
for await (const response of iterable) {
6666
console.log(response);
6767
}

packages/google-cloud-recaptchaenterprise/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function main(parent) {
6161
};
6262

6363
// Run request
64-
const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request);
64+
const iterable = recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request);
6565
for await (const response of iterable) {
6666
console.log(response);
6767
}

packages/google-cloud-recaptchaenterprise/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function main(project) {
7070
};
7171

7272
// Run request
73-
const iterable = await recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request);
73+
const iterable = recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request);
7474
for await (const response of iterable) {
7575
console.log(response);
7676
}

packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
import {Transform} from 'stream';
3030
import * as protos from '../../protos/protos';
3131
import jsonProtos = require('../../protos/protos.json');
32+
3233
/**
3334
* Client JSON configuration object, loaded from
3435
* `src/v1/recaptcha_enterprise_service_client_config.json`.
@@ -50,6 +51,8 @@ export class RecaptchaEnterpriseServiceClient {
5051
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
5152
private _protos: {};
5253
private _defaults: {[method: string]: gax.CallSettings};
54+
private _universeDomain: string;
55+
private _servicePath: string;
5356
auth: gax.GoogleAuth;
5457
descriptors: Descriptors = {
5558
page: {},
@@ -108,8 +111,20 @@ export class RecaptchaEnterpriseServiceClient {
108111
// Ensure that options include all the required fields.
109112
const staticMembers = this
110113
.constructor as typeof RecaptchaEnterpriseServiceClient;
114+
if (
115+
opts?.universe_domain &&
116+
opts?.universeDomain &&
117+
opts?.universe_domain !== opts?.universeDomain
118+
) {
119+
throw new Error(
120+
'Please set either universe_domain or universeDomain, but not both.'
121+
);
122+
}
123+
this._universeDomain =
124+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
125+
this._servicePath = 'recaptchaenterprise.' + this._universeDomain;
111126
const servicePath =
112-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
127+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
113128
this._providedCustomServicePath = !!(
114129
opts?.servicePath || opts?.apiEndpoint
115130
);
@@ -124,7 +139,7 @@ export class RecaptchaEnterpriseServiceClient {
124139
opts.numericEnums = true;
125140

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

@@ -149,10 +164,10 @@ export class RecaptchaEnterpriseServiceClient {
149164
this.auth.useJWTAccessWithScope = true;
150165

151166
// Set defaultServicePath on the auth object.
152-
this.auth.defaultServicePath = staticMembers.servicePath;
167+
this.auth.defaultServicePath = this._servicePath;
153168

154169
// Set the default scopes in auth client if needed.
155-
if (servicePath === staticMembers.servicePath) {
170+
if (servicePath === this._servicePath) {
156171
this.auth.defaultScopes = staticMembers.scopes;
157172
}
158173

@@ -334,21 +349,52 @@ export class RecaptchaEnterpriseServiceClient {
334349

335350
/**
336351
* The DNS address for this API service.
352+
* @deprecated Use the apiEndpoint method of the client instance.
337353
* @returns {string} The DNS address for this service.
338354
*/
339355
static get servicePath() {
356+
if (
357+
typeof process !== undefined &&
358+
typeof process.emitWarning === 'function'
359+
) {
360+
process.emitWarning(
361+
'Static servicePath is deprecated, please use the instance method instead.',
362+
'DeprecationWarning'
363+
);
364+
}
340365
return 'recaptchaenterprise.googleapis.com';
341366
}
342367

343368
/**
344-
* The DNS address for this API service - same as servicePath(),
345-
* exists for compatibility reasons.
369+
* The DNS address for this API service - same as servicePath.
370+
* @deprecated Use the apiEndpoint method of the client instance.
346371
* @returns {string} The DNS address for this service.
347372
*/
348373
static get apiEndpoint() {
374+
if (
375+
typeof process !== undefined &&
376+
typeof process.emitWarning === 'function'
377+
) {
378+
process.emitWarning(
379+
'Static apiEndpoint is deprecated, please use the instance method instead.',
380+
'DeprecationWarning'
381+
);
382+
}
349383
return 'recaptchaenterprise.googleapis.com';
350384
}
351385

386+
/**
387+
* The DNS address for this API service.
388+
* @returns {string} The DNS address for this service.
389+
*/
390+
get apiEndpoint() {
391+
return this._servicePath;
392+
}
393+
394+
get universeDomain() {
395+
return this._universeDomain;
396+
}
397+
352398
/**
353399
* The port for this API service.
354400
* @returns {number} The default port for this service.

packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type {
2727

2828
import * as protos from '../../protos/protos';
2929
import jsonProtos = require('../../protos/protos.json');
30+
3031
/**
3132
* Client JSON configuration object, loaded from
3233
* `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`.
@@ -48,6 +49,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
4849
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
4950
private _protos: {};
5051
private _defaults: {[method: string]: gax.CallSettings};
52+
private _universeDomain: string;
53+
private _servicePath: string;
5154
auth: gax.GoogleAuth;
5255
descriptors: Descriptors = {
5356
page: {},
@@ -106,8 +109,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
106109
// Ensure that options include all the required fields.
107110
const staticMembers = this
108111
.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client;
112+
if (
113+
opts?.universe_domain &&
114+
opts?.universeDomain &&
115+
opts?.universe_domain !== opts?.universeDomain
116+
) {
117+
throw new Error(
118+
'Please set either universe_domain or universeDomain, but not both.'
119+
);
120+
}
121+
this._universeDomain =
122+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
123+
this._servicePath = 'recaptchaenterprise.' + this._universeDomain;
109124
const servicePath =
110-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
125+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
111126
this._providedCustomServicePath = !!(
112127
opts?.servicePath || opts?.apiEndpoint
113128
);
@@ -122,7 +137,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
122137
opts.numericEnums = true;
123138

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

@@ -147,10 +162,10 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
147162
this.auth.useJWTAccessWithScope = true;
148163

149164
// Set defaultServicePath on the auth object.
150-
this.auth.defaultServicePath = staticMembers.servicePath;
165+
this.auth.defaultServicePath = this._servicePath;
151166

152167
// Set the default scopes in auth client if needed.
153-
if (servicePath === staticMembers.servicePath) {
168+
if (servicePath === this._servicePath) {
154169
this.auth.defaultScopes = staticMembers.scopes;
155170
}
156171

@@ -269,21 +284,52 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
269284

270285
/**
271286
* The DNS address for this API service.
287+
* @deprecated Use the apiEndpoint method of the client instance.
272288
* @returns {string} The DNS address for this service.
273289
*/
274290
static get servicePath() {
291+
if (
292+
typeof process !== undefined &&
293+
typeof process.emitWarning === 'function'
294+
) {
295+
process.emitWarning(
296+
'Static servicePath is deprecated, please use the instance method instead.',
297+
'DeprecationWarning'
298+
);
299+
}
275300
return 'recaptchaenterprise.googleapis.com';
276301
}
277302

278303
/**
279-
* The DNS address for this API service - same as servicePath(),
280-
* exists for compatibility reasons.
304+
* The DNS address for this API service - same as servicePath.
305+
* @deprecated Use the apiEndpoint method of the client instance.
281306
* @returns {string} The DNS address for this service.
282307
*/
283308
static get apiEndpoint() {
309+
if (
310+
typeof process !== undefined &&
311+
typeof process.emitWarning === 'function'
312+
) {
313+
process.emitWarning(
314+
'Static apiEndpoint is deprecated, please use the instance method instead.',
315+
'DeprecationWarning'
316+
);
317+
}
284318
return 'recaptchaenterprise.googleapis.com';
285319
}
286320

321+
/**
322+
* The DNS address for this API service.
323+
* @returns {string} The DNS address for this service.
324+
*/
325+
get apiEndpoint() {
326+
return this._servicePath;
327+
}
328+
329+
get universeDomain() {
330+
return this._universeDomain;
331+
}
332+
287333
/**
288334
* The port for this API service.
289335
* @returns {number} The default port for this service.

packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,67 @@ function stubAsyncIterationCall<ResponseType>(
129129

130130
describe('v1.RecaptchaEnterpriseServiceClient', () => {
131131
describe('Common methods', () => {
132-
it('has servicePath', () => {
133-
const servicePath =
134-
recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient
135-
.servicePath;
136-
assert(servicePath);
132+
it('has apiEndpoint', () => {
133+
const client =
134+
new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient();
135+
const apiEndpoint = client.apiEndpoint;
136+
assert.strictEqual(apiEndpoint, 'recaptchaenterprise.googleapis.com');
137137
});
138138

139-
it('has apiEndpoint', () => {
140-
const apiEndpoint =
141-
recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient
142-
.apiEndpoint;
143-
assert(apiEndpoint);
139+
it('has universeDomain', () => {
140+
const client =
141+
new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient();
142+
const universeDomain = client.universeDomain;
143+
assert.strictEqual(universeDomain, 'googleapis.com');
144+
});
145+
146+
if (
147+
typeof process !== 'undefined' &&
148+
typeof process.emitWarning === 'function'
149+
) {
150+
it('throws DeprecationWarning if static servicePath is used', () => {
151+
const stub = sinon.stub(process, 'emitWarning');
152+
const servicePath =
153+
recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient
154+
.servicePath;
155+
assert.strictEqual(servicePath, 'recaptchaenterprise.googleapis.com');
156+
assert(stub.called);
157+
stub.restore();
158+
});
159+
160+
it('throws DeprecationWarning if static apiEndpoint is used', () => {
161+
const stub = sinon.stub(process, 'emitWarning');
162+
const apiEndpoint =
163+
recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient
164+
.apiEndpoint;
165+
assert.strictEqual(apiEndpoint, 'recaptchaenterprise.googleapis.com');
166+
assert(stub.called);
167+
stub.restore();
168+
});
169+
}
170+
it('sets apiEndpoint according to universe domain camelCase', () => {
171+
const client =
172+
new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(
173+
{universeDomain: 'example.com'}
174+
);
175+
const servicePath = client.apiEndpoint;
176+
assert.strictEqual(servicePath, 'recaptchaenterprise.example.com');
177+
});
178+
179+
it('sets apiEndpoint according to universe domain snakeCase', () => {
180+
const client =
181+
new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(
182+
{universe_domain: 'example.com'}
183+
);
184+
const servicePath = client.apiEndpoint;
185+
assert.strictEqual(servicePath, 'recaptchaenterprise.example.com');
186+
});
187+
it('does not allow setting both universeDomain and universe_domain', () => {
188+
assert.throws(() => {
189+
new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(
190+
{universe_domain: 'example.com', universeDomain: 'example.net'}
191+
);
192+
});
144193
});
145194

146195
it('has port', () => {

0 commit comments

Comments
 (0)