Skip to content

Commit 43acd89

Browse files
feat: Trusted Private Cloud support, use the universeDomain parameter (#5026)
* build: update gapic-generator-typescript to v4.4.1 PiperOrigin-RevId: 604765466 Source-Link: googleapis/googleapis@40203ca Source-Link: googleapis/googleapis-gen@07b7f3d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1lbWNhY2hlLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1ldGFzdG9yZS8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1pZ3JhdGlvbmNlbnRlci8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldGFwcC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmtjb25uZWN0aXZpdHkvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmttYW5hZ2VtZW50Ly5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjo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Y2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 * 🦉 Updates from OwlBot post-processor * feat: Trusted Private Cloud support, use the universeDomain parameter 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> Co-authored-by: sofisl <[email protected]>
1 parent 09e59ad commit 43acd89

184 files changed

Lines changed: 4727 additions & 702 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-memcache/samples/generated/v1/cloud_memcache.list_instances.js

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

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

packages/google-cloud-memcache/samples/generated/v1beta2/cloud_memcache.list_instances.js

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

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

packages/google-cloud-memcache/src/v1/cloud_memcache_client.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
import {Transform} from 'stream';
3434
import * as protos from '../../protos/protos';
3535
import jsonProtos = require('../../protos/protos.json');
36+
3637
/**
3738
* Client JSON configuration object, loaded from
3839
* `src/v1/cloud_memcache_client_config.json`.
@@ -68,6 +69,8 @@ export class CloudMemcacheClient {
6869
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
6970
private _protos: {};
7071
private _defaults: {[method: string]: gax.CallSettings};
72+
private _universeDomain: string;
73+
private _servicePath: string;
7174
auth: gax.GoogleAuth;
7275
descriptors: Descriptors = {
7376
page: {},
@@ -127,8 +130,20 @@ export class CloudMemcacheClient {
127130
) {
128131
// Ensure that options include all the required fields.
129132
const staticMembers = this.constructor as typeof CloudMemcacheClient;
133+
if (
134+
opts?.universe_domain &&
135+
opts?.universeDomain &&
136+
opts?.universe_domain !== opts?.universeDomain
137+
) {
138+
throw new Error(
139+
'Please set either universe_domain or universeDomain, but not both.'
140+
);
141+
}
142+
this._universeDomain =
143+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
144+
this._servicePath = 'memcache.' + this._universeDomain;
130145
const servicePath =
131-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
146+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
132147
this._providedCustomServicePath = !!(
133148
opts?.servicePath || opts?.apiEndpoint
134149
);
@@ -143,7 +158,7 @@ export class CloudMemcacheClient {
143158
opts.numericEnums = true;
144159

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

@@ -168,10 +183,10 @@ export class CloudMemcacheClient {
168183
this.auth.useJWTAccessWithScope = true;
169184

170185
// Set defaultServicePath on the auth object.
171-
this.auth.defaultServicePath = staticMembers.servicePath;
186+
this.auth.defaultServicePath = this._servicePath;
172187

173188
// Set the default scopes in auth client if needed.
174-
if (servicePath === staticMembers.servicePath) {
189+
if (servicePath === this._servicePath) {
175190
this.auth.defaultScopes = staticMembers.scopes;
176191
}
177192
this.locationsClient = new this._gaxModule.LocationsClient(
@@ -426,21 +441,52 @@ export class CloudMemcacheClient {
426441

427442
/**
428443
* The DNS address for this API service.
444+
* @deprecated Use the apiEndpoint method of the client instance.
429445
* @returns {string} The DNS address for this service.
430446
*/
431447
static get servicePath() {
448+
if (
449+
typeof process !== undefined &&
450+
typeof process.emitWarning === 'function'
451+
) {
452+
process.emitWarning(
453+
'Static servicePath is deprecated, please use the instance method instead.',
454+
'DeprecationWarning'
455+
);
456+
}
432457
return 'memcache.googleapis.com';
433458
}
434459

435460
/**
436-
* The DNS address for this API service - same as servicePath(),
437-
* exists for compatibility reasons.
461+
* The DNS address for this API service - same as servicePath.
462+
* @deprecated Use the apiEndpoint method of the client instance.
438463
* @returns {string} The DNS address for this service.
439464
*/
440465
static get apiEndpoint() {
466+
if (
467+
typeof process !== undefined &&
468+
typeof process.emitWarning === 'function'
469+
) {
470+
process.emitWarning(
471+
'Static apiEndpoint is deprecated, please use the instance method instead.',
472+
'DeprecationWarning'
473+
);
474+
}
441475
return 'memcache.googleapis.com';
442476
}
443477

478+
/**
479+
* The DNS address for this API service.
480+
* @returns {string} The DNS address for this service.
481+
*/
482+
get apiEndpoint() {
483+
return this._servicePath;
484+
}
485+
486+
get universeDomain() {
487+
return this._universeDomain;
488+
}
489+
444490
/**
445491
* The port for this API service.
446492
* @returns {number} The default port for this service.

packages/google-cloud-memcache/src/v1beta2/cloud_memcache_client.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
import {Transform} from 'stream';
3434
import * as protos from '../../protos/protos';
3535
import jsonProtos = require('../../protos/protos.json');
36+
3637
/**
3738
* Client JSON configuration object, loaded from
3839
* `src/v1beta2/cloud_memcache_client_config.json`.
@@ -68,6 +69,8 @@ export class CloudMemcacheClient {
6869
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
6970
private _protos: {};
7071
private _defaults: {[method: string]: gax.CallSettings};
72+
private _universeDomain: string;
73+
private _servicePath: string;
7174
auth: gax.GoogleAuth;
7275
descriptors: Descriptors = {
7376
page: {},
@@ -127,8 +130,20 @@ export class CloudMemcacheClient {
127130
) {
128131
// Ensure that options include all the required fields.
129132
const staticMembers = this.constructor as typeof CloudMemcacheClient;
133+
if (
134+
opts?.universe_domain &&
135+
opts?.universeDomain &&
136+
opts?.universe_domain !== opts?.universeDomain
137+
) {
138+
throw new Error(
139+
'Please set either universe_domain or universeDomain, but not both.'
140+
);
141+
}
142+
this._universeDomain =
143+
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
144+
this._servicePath = 'memcache.' + this._universeDomain;
130145
const servicePath =
131-
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
146+
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
132147
this._providedCustomServicePath = !!(
133148
opts?.servicePath || opts?.apiEndpoint
134149
);
@@ -143,7 +158,7 @@ export class CloudMemcacheClient {
143158
opts.numericEnums = true;
144159

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

@@ -168,10 +183,10 @@ export class CloudMemcacheClient {
168183
this.auth.useJWTAccessWithScope = true;
169184

170185
// Set defaultServicePath on the auth object.
171-
this.auth.defaultServicePath = staticMembers.servicePath;
186+
this.auth.defaultServicePath = this._servicePath;
172187

173188
// Set the default scopes in auth client if needed.
174-
if (servicePath === staticMembers.servicePath) {
189+
if (servicePath === this._servicePath) {
175190
this.auth.defaultScopes = staticMembers.scopes;
176191
}
177192
this.locationsClient = new this._gaxModule.LocationsClient(
@@ -438,21 +453,52 @@ export class CloudMemcacheClient {
438453

439454
/**
440455
* The DNS address for this API service.
456+
* @deprecated Use the apiEndpoint method of the client instance.
441457
* @returns {string} The DNS address for this service.
442458
*/
443459
static get servicePath() {
460+
if (
461+
typeof process !== undefined &&
462+
typeof process.emitWarning === 'function'
463+
) {
464+
process.emitWarning(
465+
'Static servicePath is deprecated, please use the instance method instead.',
466+
'DeprecationWarning'
467+
);
468+
}
444469
return 'memcache.googleapis.com';
445470
}
446471

447472
/**
448-
* The DNS address for this API service - same as servicePath(),
449-
* exists for compatibility reasons.
473+
* The DNS address for this API service - same as servicePath.
474+
* @deprecated Use the apiEndpoint method of the client instance.
450475
* @returns {string} The DNS address for this service.
451476
*/
452477
static get apiEndpoint() {
478+
if (
479+
typeof process !== undefined &&
480+
typeof process.emitWarning === 'function'
481+
) {
482+
process.emitWarning(
483+
'Static apiEndpoint is deprecated, please use the instance method instead.',
484+
'DeprecationWarning'
485+
);
486+
}
453487
return 'memcache.googleapis.com';
454488
}
455489

490+
/**
491+
* The DNS address for this API service.
492+
* @returns {string} The DNS address for this service.
493+
*/
494+
get apiEndpoint() {
495+
return this._servicePath;
496+
}
497+
498+
get universeDomain() {
499+
return this._universeDomain;
500+
}
501+
456502
/**
457503
* The port for this API service.
458504
* @returns {number} The default port for this service.

packages/google-cloud-memcache/test/gapic_cloud_memcache_v1.ts

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,62 @@ function stubAsyncIterationCall<ResponseType>(
166166

167167
describe('v1.CloudMemcacheClient', () => {
168168
describe('Common methods', () => {
169-
it('has servicePath', () => {
170-
const servicePath =
171-
cloudmemcacheModule.v1.CloudMemcacheClient.servicePath;
172-
assert(servicePath);
169+
it('has apiEndpoint', () => {
170+
const client = new cloudmemcacheModule.v1.CloudMemcacheClient();
171+
const apiEndpoint = client.apiEndpoint;
172+
assert.strictEqual(apiEndpoint, 'memcache.googleapis.com');
173173
});
174174

175-
it('has apiEndpoint', () => {
176-
const apiEndpoint =
177-
cloudmemcacheModule.v1.CloudMemcacheClient.apiEndpoint;
178-
assert(apiEndpoint);
175+
it('has universeDomain', () => {
176+
const client = new cloudmemcacheModule.v1.CloudMemcacheClient();
177+
const universeDomain = client.universeDomain;
178+
assert.strictEqual(universeDomain, 'googleapis.com');
179+
});
180+
181+
if (
182+
typeof process !== 'undefined' &&
183+
typeof process.emitWarning === 'function'
184+
) {
185+
it('throws DeprecationWarning if static servicePath is used', () => {
186+
const stub = sinon.stub(process, 'emitWarning');
187+
const servicePath =
188+
cloudmemcacheModule.v1.CloudMemcacheClient.servicePath;
189+
assert.strictEqual(servicePath, 'memcache.googleapis.com');
190+
assert(stub.called);
191+
stub.restore();
192+
});
193+
194+
it('throws DeprecationWarning if static apiEndpoint is used', () => {
195+
const stub = sinon.stub(process, 'emitWarning');
196+
const apiEndpoint =
197+
cloudmemcacheModule.v1.CloudMemcacheClient.apiEndpoint;
198+
assert.strictEqual(apiEndpoint, 'memcache.googleapis.com');
199+
assert(stub.called);
200+
stub.restore();
201+
});
202+
}
203+
it('sets apiEndpoint according to universe domain camelCase', () => {
204+
const client = new cloudmemcacheModule.v1.CloudMemcacheClient({
205+
universeDomain: 'example.com',
206+
});
207+
const servicePath = client.apiEndpoint;
208+
assert.strictEqual(servicePath, 'memcache.example.com');
209+
});
210+
211+
it('sets apiEndpoint according to universe domain snakeCase', () => {
212+
const client = new cloudmemcacheModule.v1.CloudMemcacheClient({
213+
universe_domain: 'example.com',
214+
});
215+
const servicePath = client.apiEndpoint;
216+
assert.strictEqual(servicePath, 'memcache.example.com');
217+
});
218+
it('does not allow setting both universeDomain and universe_domain', () => {
219+
assert.throws(() => {
220+
new cloudmemcacheModule.v1.CloudMemcacheClient({
221+
universe_domain: 'example.com',
222+
universeDomain: 'example.net',
223+
});
224+
});
179225
});
180226

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

packages/google-cloud-memcache/test/gapic_cloud_memcache_v1beta2.ts

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,62 @@ function stubAsyncIterationCall<ResponseType>(
166166

167167
describe('v1beta2.CloudMemcacheClient', () => {
168168
describe('Common methods', () => {
169-
it('has servicePath', () => {
170-
const servicePath =
171-
cloudmemcacheModule.v1beta2.CloudMemcacheClient.servicePath;
172-
assert(servicePath);
169+
it('has apiEndpoint', () => {
170+
const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient();
171+
const apiEndpoint = client.apiEndpoint;
172+
assert.strictEqual(apiEndpoint, 'memcache.googleapis.com');
173173
});
174174

175-
it('has apiEndpoint', () => {
176-
const apiEndpoint =
177-
cloudmemcacheModule.v1beta2.CloudMemcacheClient.apiEndpoint;
178-
assert(apiEndpoint);
175+
it('has universeDomain', () => {
176+
const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient();
177+
const universeDomain = client.universeDomain;
178+
assert.strictEqual(universeDomain, 'googleapis.com');
179+
});
180+
181+
if (
182+
typeof process !== 'undefined' &&
183+
typeof process.emitWarning === 'function'
184+
) {
185+
it('throws DeprecationWarning if static servicePath is used', () => {
186+
const stub = sinon.stub(process, 'emitWarning');
187+
const servicePath =
188+
cloudmemcacheModule.v1beta2.CloudMemcacheClient.servicePath;
189+
assert.strictEqual(servicePath, 'memcache.googleapis.com');
190+
assert(stub.called);
191+
stub.restore();
192+
});
193+
194+
it('throws DeprecationWarning if static apiEndpoint is used', () => {
195+
const stub = sinon.stub(process, 'emitWarning');
196+
const apiEndpoint =
197+
cloudmemcacheModule.v1beta2.CloudMemcacheClient.apiEndpoint;
198+
assert.strictEqual(apiEndpoint, 'memcache.googleapis.com');
199+
assert(stub.called);
200+
stub.restore();
201+
});
202+
}
203+
it('sets apiEndpoint according to universe domain camelCase', () => {
204+
const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({
205+
universeDomain: 'example.com',
206+
});
207+
const servicePath = client.apiEndpoint;
208+
assert.strictEqual(servicePath, 'memcache.example.com');
209+
});
210+
211+
it('sets apiEndpoint according to universe domain snakeCase', () => {
212+
const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({
213+
universe_domain: 'example.com',
214+
});
215+
const servicePath = client.apiEndpoint;
216+
assert.strictEqual(servicePath, 'memcache.example.com');
217+
});
218+
it('does not allow setting both universeDomain and universe_domain', () => {
219+
assert.throws(() => {
220+
new cloudmemcacheModule.v1beta2.CloudMemcacheClient({
221+
universe_domain: 'example.com',
222+
universeDomain: 'example.net',
223+
});
224+
});
179225
});
180226

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

0 commit comments

Comments
 (0)