Skip to content

Commit eccee7d

Browse files
fix: better support for fallback mode (#105)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 468790263 Source-Link: googleapis/googleapis@873ab45 Source-Link: googleapis/googleapis-gen@cb6f37a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2I2ZjM3YWVmZjJhMzQ3MmU0MGE3YmJhY2U4YzY3ZDc1ZTI0YmVlNSJ9
1 parent 2c55ebe commit eccee7d

10 files changed

+126
-103
lines changed

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.compute_contacts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(parent) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_ComputeContacts_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.create_contact.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(parent, contact) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_CreateContact_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.delete_contact.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(name) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_DeleteContact_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.get_contact.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(name) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_GetContact_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.list_contacts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(parent) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_ListContacts_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.send_test_message.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(contacts, resource, notificationCategory) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_SendTestMessage_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/essential_contacts_service.update_contact.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
function main(contact) {
2424
// [START essentialcontacts_v1_generated_EssentialContactsService_UpdateContact_async]
2525
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
2629
* TODO(developer): Uncomment these variables before running the sample.
2730
*/
2831
/**

packages/google-cloud-essentialcontacts/samples/generated/v1/snippet_metadata.google.cloud.essentialcontacts.v1.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"segments": [
2323
{
2424
"start": 25,
25-
"end": 58,
25+
"end": 61,
2626
"type": "FULL"
2727
}
2828
],
@@ -66,7 +66,7 @@
6666
"segments": [
6767
{
6868
"start": 25,
69-
"end": 57,
69+
"end": 60,
7070
"type": "FULL"
7171
}
7272
],
@@ -110,7 +110,7 @@
110110
"segments": [
111111
{
112112
"start": 25,
113-
"end": 68,
113+
"end": 71,
114114
"type": "FULL"
115115
}
116116
],
@@ -158,7 +158,7 @@
158158
"segments": [
159159
{
160160
"start": 25,
161-
"end": 53,
161+
"end": 56,
162162
"type": "FULL"
163163
}
164164
],
@@ -198,7 +198,7 @@
198198
"segments": [
199199
{
200200
"start": 25,
201-
"end": 53,
201+
"end": 56,
202202
"type": "FULL"
203203
}
204204
],
@@ -238,7 +238,7 @@
238238
"segments": [
239239
{
240240
"start": 25,
241-
"end": 74,
241+
"end": 77,
242242
"type": "FULL"
243243
}
244244
],
@@ -290,7 +290,7 @@
290290
"segments": [
291291
{
292292
"start": 25,
293-
"end": 68,
293+
"end": 71,
294294
"type": "FULL"
295295
}
296296
],

packages/google-cloud-essentialcontacts/src/v1/essential_contacts_service_client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
} from 'google-gax';
2929

3030
import {Transform} from 'stream';
31-
import {RequestType} from 'google-gax/build/src/apitypes';
3231
import * as protos from '../../protos/protos';
3332
import jsonProtos = require('../../protos/protos.json');
3433
/**
@@ -272,7 +271,8 @@ export class EssentialContactsServiceClient {
272271
const apiCall = this._gaxModule.createApiCall(
273272
callPromise,
274273
this._defaults[methodName],
275-
descriptor
274+
descriptor,
275+
this._opts.fallback
276276
);
277277

278278
this.innerApiCalls[methodName] = apiCall;
@@ -997,7 +997,7 @@ export class EssentialContactsServiceClient {
997997
const callSettings = defaultCallSettings.merge(options);
998998
this.initialize();
999999
return this.descriptors.page.listContacts.createStream(
1000-
this.innerApiCalls.listContacts as gax.GaxCall,
1000+
this.innerApiCalls.listContacts as GaxCall,
10011001
request,
10021002
callSettings
10031003
);
@@ -1053,7 +1053,7 @@ export class EssentialContactsServiceClient {
10531053
this.initialize();
10541054
return this.descriptors.page.listContacts.asyncIterate(
10551055
this.innerApiCalls['listContacts'] as GaxCall,
1056-
request as unknown as RequestType,
1056+
request as {},
10571057
callSettings
10581058
) as AsyncIterable<protos.google.cloud.essentialcontacts.v1.IContact>;
10591059
}
@@ -1220,7 +1220,7 @@ export class EssentialContactsServiceClient {
12201220
const callSettings = defaultCallSettings.merge(options);
12211221
this.initialize();
12221222
return this.descriptors.page.computeContacts.createStream(
1223-
this.innerApiCalls.computeContacts as gax.GaxCall,
1223+
this.innerApiCalls.computeContacts as GaxCall,
12241224
request,
12251225
callSettings
12261226
);
@@ -1280,7 +1280,7 @@ export class EssentialContactsServiceClient {
12801280
this.initialize();
12811281
return this.descriptors.page.computeContacts.asyncIterate(
12821282
this.innerApiCalls['computeContacts'] as GaxCall,
1283-
request as unknown as RequestType,
1283+
request as {},
12841284
callSettings
12851285
) as AsyncIterable<protos.google.cloud.essentialcontacts.v1.IContact>;
12861286
}

packages/google-cloud-essentialcontacts/test/gapic_essential_contacts_service_v1.ts

Lines changed: 92 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -113,111 +113,113 @@ function stubAsyncIterationCall<ResponseType>(
113113
}
114114

115115
describe('v1.EssentialContactsServiceClient', () => {
116-
it('has servicePath', () => {
117-
const servicePath =
118-
essentialcontactsserviceModule.v1.EssentialContactsServiceClient
119-
.servicePath;
120-
assert(servicePath);
121-
});
116+
describe('Common methods', () => {
117+
it('has servicePath', () => {
118+
const servicePath =
119+
essentialcontactsserviceModule.v1.EssentialContactsServiceClient
120+
.servicePath;
121+
assert(servicePath);
122+
});
122123

123-
it('has apiEndpoint', () => {
124-
const apiEndpoint =
125-
essentialcontactsserviceModule.v1.EssentialContactsServiceClient
126-
.apiEndpoint;
127-
assert(apiEndpoint);
128-
});
124+
it('has apiEndpoint', () => {
125+
const apiEndpoint =
126+
essentialcontactsserviceModule.v1.EssentialContactsServiceClient
127+
.apiEndpoint;
128+
assert(apiEndpoint);
129+
});
129130

130-
it('has port', () => {
131-
const port =
132-
essentialcontactsserviceModule.v1.EssentialContactsServiceClient.port;
133-
assert(port);
134-
assert(typeof port === 'number');
135-
});
131+
it('has port', () => {
132+
const port =
133+
essentialcontactsserviceModule.v1.EssentialContactsServiceClient.port;
134+
assert(port);
135+
assert(typeof port === 'number');
136+
});
136137

137-
it('should create a client with no option', () => {
138-
const client =
139-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient();
140-
assert(client);
141-
});
138+
it('should create a client with no option', () => {
139+
const client =
140+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient();
141+
assert(client);
142+
});
142143

143-
it('should create a client with gRPC fallback', () => {
144-
const client =
145-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
146-
fallback: true,
147-
});
148-
assert(client);
149-
});
144+
it('should create a client with gRPC fallback', () => {
145+
const client =
146+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
147+
fallback: true,
148+
});
149+
assert(client);
150+
});
150151

151-
it('has initialize method and supports deferred initialization', async () => {
152-
const client =
153-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
154-
credentials: {client_email: 'bogus', private_key: 'bogus'},
155-
projectId: 'bogus',
156-
});
157-
assert.strictEqual(client.essentialContactsServiceStub, undefined);
158-
await client.initialize();
159-
assert(client.essentialContactsServiceStub);
160-
});
152+
it('has initialize method and supports deferred initialization', async () => {
153+
const client =
154+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
155+
credentials: {client_email: 'bogus', private_key: 'bogus'},
156+
projectId: 'bogus',
157+
});
158+
assert.strictEqual(client.essentialContactsServiceStub, undefined);
159+
await client.initialize();
160+
assert(client.essentialContactsServiceStub);
161+
});
161162

162-
it('has close method for the initialized client', done => {
163-
const client =
164-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
165-
credentials: {client_email: 'bogus', private_key: 'bogus'},
166-
projectId: 'bogus',
163+
it('has close method for the initialized client', done => {
164+
const client =
165+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
166+
credentials: {client_email: 'bogus', private_key: 'bogus'},
167+
projectId: 'bogus',
168+
});
169+
client.initialize();
170+
assert(client.essentialContactsServiceStub);
171+
client.close().then(() => {
172+
done();
167173
});
168-
client.initialize();
169-
assert(client.essentialContactsServiceStub);
170-
client.close().then(() => {
171-
done();
172174
});
173-
});
174175

175-
it('has close method for the non-initialized client', done => {
176-
const client =
177-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
178-
credentials: {client_email: 'bogus', private_key: 'bogus'},
179-
projectId: 'bogus',
176+
it('has close method for the non-initialized client', done => {
177+
const client =
178+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
179+
credentials: {client_email: 'bogus', private_key: 'bogus'},
180+
projectId: 'bogus',
181+
});
182+
assert.strictEqual(client.essentialContactsServiceStub, undefined);
183+
client.close().then(() => {
184+
done();
180185
});
181-
assert.strictEqual(client.essentialContactsServiceStub, undefined);
182-
client.close().then(() => {
183-
done();
184186
});
185-
});
186187

187-
it('has getProjectId method', async () => {
188-
const fakeProjectId = 'fake-project-id';
189-
const client =
190-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
191-
credentials: {client_email: 'bogus', private_key: 'bogus'},
192-
projectId: 'bogus',
193-
});
194-
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
195-
const result = await client.getProjectId();
196-
assert.strictEqual(result, fakeProjectId);
197-
assert((client.auth.getProjectId as SinonStub).calledWithExactly());
198-
});
188+
it('has getProjectId method', async () => {
189+
const fakeProjectId = 'fake-project-id';
190+
const client =
191+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
192+
credentials: {client_email: 'bogus', private_key: 'bogus'},
193+
projectId: 'bogus',
194+
});
195+
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
196+
const result = await client.getProjectId();
197+
assert.strictEqual(result, fakeProjectId);
198+
assert((client.auth.getProjectId as SinonStub).calledWithExactly());
199+
});
199200

200-
it('has getProjectId method with callback', async () => {
201-
const fakeProjectId = 'fake-project-id';
202-
const client =
203-
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
204-
credentials: {client_email: 'bogus', private_key: 'bogus'},
205-
projectId: 'bogus',
206-
});
207-
client.auth.getProjectId = sinon
208-
.stub()
209-
.callsArgWith(0, null, fakeProjectId);
210-
const promise = new Promise((resolve, reject) => {
211-
client.getProjectId((err?: Error | null, projectId?: string | null) => {
212-
if (err) {
213-
reject(err);
214-
} else {
215-
resolve(projectId);
216-
}
201+
it('has getProjectId method with callback', async () => {
202+
const fakeProjectId = 'fake-project-id';
203+
const client =
204+
new essentialcontactsserviceModule.v1.EssentialContactsServiceClient({
205+
credentials: {client_email: 'bogus', private_key: 'bogus'},
206+
projectId: 'bogus',
207+
});
208+
client.auth.getProjectId = sinon
209+
.stub()
210+
.callsArgWith(0, null, fakeProjectId);
211+
const promise = new Promise((resolve, reject) => {
212+
client.getProjectId((err?: Error | null, projectId?: string | null) => {
213+
if (err) {
214+
reject(err);
215+
} else {
216+
resolve(projectId);
217+
}
218+
});
217219
});
220+
const result = await promise;
221+
assert.strictEqual(result, fakeProjectId);
218222
});
219-
const result = await promise;
220-
assert.strictEqual(result, fakeProjectId);
221223
});
222224

223225
describe('createContact', () => {

0 commit comments

Comments
 (0)