Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/v1/publisher_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<protos.google.pubsub.v1.ITopic>;
}
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<string>;
}
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<string>;
}
Expand Down
8 changes: 4 additions & 4 deletions src/v1/schema_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<protos.google.pubsub.v1.ISchema>;
}
Expand Down
12 changes: 6 additions & 6 deletions src/v1/subscriber_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<protos.google.pubsub.v1.ISubscription>;
}
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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<protos.google.pubsub.v1.ISnapshot>;
}
Expand Down
156 changes: 79 additions & 77 deletions test/gapic_publisher_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,99 +113,101 @@ function stubAsyncIterationCall<ResponseType>(
}

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', () => {
Expand Down
Loading