diff --git a/src/v1/publisher_client.ts b/src/v1/publisher_client.ts index eb1c56df4..6dcab350b 100644 --- a/src/v1/publisher_client.ts +++ b/src/v1/publisher_client.ts @@ -30,7 +30,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -304,7 +303,8 @@ export class PublisherClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1044,7 +1044,7 @@ export class PublisherClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTopics.createStream( - this.innerApiCalls.listTopics as gax.GaxCall, + this.innerApiCalls.listTopics as GaxCall, request, callSettings ); @@ -1093,7 +1093,7 @@ export class PublisherClient { this.initialize(); return this.descriptors.page.listTopics.asyncIterate( this.innerApiCalls['listTopics'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1244,7 +1244,7 @@ export class PublisherClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTopicSubscriptions.createStream( - this.innerApiCalls.listTopicSubscriptions as gax.GaxCall, + this.innerApiCalls.listTopicSubscriptions as GaxCall, request, callSettings ); @@ -1293,7 +1293,7 @@ export class PublisherClient { this.initialize(); return this.descriptors.page.listTopicSubscriptions.asyncIterate( this.innerApiCalls['listTopicSubscriptions'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1438,7 +1438,7 @@ export class PublisherClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTopicSnapshots.createStream( - this.innerApiCalls.listTopicSnapshots as gax.GaxCall, + this.innerApiCalls.listTopicSnapshots as GaxCall, request, callSettings ); @@ -1487,7 +1487,7 @@ export class PublisherClient { this.initialize(); return this.descriptors.page.listTopicSnapshots.asyncIterate( this.innerApiCalls['listTopicSnapshots'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/schema_service_client.ts b/src/v1/schema_service_client.ts index 37c9c2b97..c8170bd63 100644 --- a/src/v1/schema_service_client.ts +++ b/src/v1/schema_service_client.ts @@ -30,7 +30,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -271,7 +270,8 @@ export class SchemaServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -918,7 +918,7 @@ export class SchemaServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listSchemas.createStream( - this.innerApiCalls.listSchemas as gax.GaxCall, + this.innerApiCalls.listSchemas as GaxCall, request, callSettings ); @@ -971,7 +971,7 @@ export class SchemaServiceClient { this.initialize(); return this.descriptors.page.listSchemas.asyncIterate( this.innerApiCalls['listSchemas'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index 730e64935..aa7b24780 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -31,7 +31,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -312,7 +311,8 @@ export class SubscriberClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1862,7 +1862,7 @@ export class SubscriberClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listSubscriptions.createStream( - this.innerApiCalls.listSubscriptions as gax.GaxCall, + this.innerApiCalls.listSubscriptions as GaxCall, request, callSettings ); @@ -1911,7 +1911,7 @@ export class SubscriberClient { this.initialize(); return this.descriptors.page.listSubscriptions.asyncIterate( this.innerApiCalls['listSubscriptions'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -2054,7 +2054,7 @@ export class SubscriberClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listSnapshots.createStream( - this.innerApiCalls.listSnapshots as gax.GaxCall, + this.innerApiCalls.listSnapshots as GaxCall, request, callSettings ); @@ -2103,7 +2103,7 @@ export class SubscriberClient { this.initialize(); return this.descriptors.page.listSnapshots.asyncIterate( this.innerApiCalls['listSnapshots'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/test/gapic_publisher_v1.ts b/test/gapic_publisher_v1.ts index 80cdf6a8e..0e93f3ad5 100644 --- a/test/gapic_publisher_v1.ts +++ b/test/gapic_publisher_v1.ts @@ -113,99 +113,101 @@ function stubAsyncIterationCall( } describe('v1.PublisherClient', () => { - it('has servicePath', () => { - const servicePath = publisherModule.v1.PublisherClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = publisherModule.v1.PublisherClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = publisherModule.v1.PublisherClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = publisherModule.v1.PublisherClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new publisherModule.v1.PublisherClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = publisherModule.v1.PublisherClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new publisherModule.v1.PublisherClient({ - fallback: true, + it('has port', () => { + const port = publisherModule.v1.PublisherClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new publisherModule.v1.PublisherClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new publisherModule.v1.PublisherClient(); + assert(client); }); - assert.strictEqual(client.publisherStub, undefined); - await client.initialize(); - assert(client.publisherStub); - }); - it('has close method for the initialized client', done => { - const client = new publisherModule.v1.PublisherClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new publisherModule.v1.PublisherClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.publisherStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.publisherStub, undefined); + await client.initialize(); + assert(client.publisherStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new publisherModule.v1.PublisherClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.publisherStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.publisherStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.publisherStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new publisherModule.v1.PublisherClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new publisherModule.v1.PublisherClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createTopic', () => { diff --git a/test/gapic_schema_service_v1.ts b/test/gapic_schema_service_v1.ts index 3d903d482..763b62eec 100644 --- a/test/gapic_schema_service_v1.ts +++ b/test/gapic_schema_service_v1.ts @@ -113,99 +113,103 @@ function stubAsyncIterationCall( } describe('v1.SchemaServiceClient', () => { - it('has servicePath', () => { - const servicePath = schemaserviceModule.v1.SchemaServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = schemaserviceModule.v1.SchemaServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = schemaserviceModule.v1.SchemaServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new schemaserviceModule.v1.SchemaServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + schemaserviceModule.v1.SchemaServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + schemaserviceModule.v1.SchemaServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = schemaserviceModule.v1.SchemaServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.schemaServiceStub, undefined); - await client.initialize(); - assert(client.schemaServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient(); + assert(client); }); - client.initialize(); - assert(client.schemaServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + await client.initialize(); + assert(client.schemaServiceStub); }); - assert.strictEqual(client.schemaServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.schemaServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createSchema', () => { diff --git a/test/gapic_subscriber_v1.ts b/test/gapic_subscriber_v1.ts index cedb59b63..a8d955ba3 100644 --- a/test/gapic_subscriber_v1.ts +++ b/test/gapic_subscriber_v1.ts @@ -127,99 +127,101 @@ function stubAsyncIterationCall( } describe('v1.SubscriberClient', () => { - it('has servicePath', () => { - const servicePath = subscriberModule.v1.SubscriberClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = subscriberModule.v1.SubscriberClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = subscriberModule.v1.SubscriberClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = subscriberModule.v1.SubscriberClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new subscriberModule.v1.SubscriberClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = subscriberModule.v1.SubscriberClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new subscriberModule.v1.SubscriberClient({ - fallback: true, + it('has port', () => { + const port = subscriberModule.v1.SubscriberClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new subscriberModule.v1.SubscriberClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new subscriberModule.v1.SubscriberClient(); + assert(client); }); - assert.strictEqual(client.subscriberStub, undefined); - await client.initialize(); - assert(client.subscriberStub); - }); - it('has close method for the initialized client', done => { - const client = new subscriberModule.v1.SubscriberClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new subscriberModule.v1.SubscriberClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.subscriberStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.subscriberStub, undefined); + await client.initialize(); + assert(client.subscriberStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new subscriberModule.v1.SubscriberClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.subscriberStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.subscriberStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.subscriberStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new subscriberModule.v1.SubscriberClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new subscriberModule.v1.SubscriberClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createSubscription', () => {