Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose service stub as public member #167

Merged
merged 1 commit into from
Dec 10, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const version = require('../../../package.json').version;
*/
export class {{ service.name }}Client {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _{{ service.name.toCamelCase() }}Stub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
{%- if (service.pathTemplates.length > 0) %}
private _pathTemplates: {[name: string]: gax.PathTemplate};
{%- endif %}
private _terminated = false;
auth: gax.GoogleAuth;
{{ service.name.toCamelCase() }}Stub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of {{ service.name }}Client.
Expand Down Expand Up @@ -221,7 +221,7 @@ export class {{ service.name }}Client {

// Put together the "service stub" for
// {{api.naming.protoPackage}}.{{ service.name }}.
this._{{ service.name.toCamelCase() }}Stub = gaxGrpc.createStub(
this.{{ service.name.toCamelCase() }}Stub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('{{api.naming.protoPackage}}.{{ service.name }}') :
// tslint:disable-next-line no-any
Expand All @@ -240,7 +240,7 @@ export class {{ service.name }}Client {
];

for (const methodName of {{ service.name.toCamelCase() }}StubMethods) {
const innerCallPromise = this._{{ service.name.toCamelCase() }}Stub.then(
const innerCallPromise = this.{{ service.name.toCamelCase() }}Stub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -611,7 +611,7 @@ export class {{ service.name }}Client {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._{{ service.name.toCamelCase() }}Stub.then(stub => {
return this.{{ service.name.toCamelCase() }}Stub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ const version = require('../../../package.json').version;
*/
export class KeyManagementServiceClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _keyManagementServiceStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
keyManagementServiceStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of KeyManagementServiceClient.
Expand Down Expand Up @@ -162,7 +162,7 @@ export class KeyManagementServiceClient {

// Put together the "service stub" for
// google.cloud.kms.v1.KeyManagementService.
this._keyManagementServiceStub = gaxGrpc.createStub(
this.keyManagementServiceStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.cloud.kms.v1.KeyManagementService') :
// tslint:disable-next-line no-any
Expand All @@ -175,7 +175,7 @@ export class KeyManagementServiceClient {
['listKeyRings', 'listCryptoKeys', 'listCryptoKeyVersions', 'listImportJobs', 'getKeyRing', 'getCryptoKey', 'getCryptoKeyVersion', 'getPublicKey', 'getImportJob', 'createKeyRing', 'createCryptoKey', 'createCryptoKeyVersion', 'importCryptoKeyVersion', 'createImportJob', 'updateCryptoKey', 'updateCryptoKeyVersion', 'encrypt', 'decrypt', 'asymmetricSign', 'asymmetricDecrypt', 'updateCryptoKeyPrimaryVersion', 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion'];

for (const methodName of keyManagementServiceStubMethods) {
const innerCallPromise = this._keyManagementServiceStub.then(
const innerCallPromise = this.keyManagementServiceStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -2074,7 +2074,7 @@ export class KeyManagementServiceClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._keyManagementServiceStub.then(stub => {
return this.keyManagementServiceStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const version = require('../../../package.json').version;
*/
export class CloudRedisClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _cloudRedisStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _pathTemplates: {[name: string]: gax.PathTemplate};
private _terminated = false;
auth: gax.GoogleAuth;
cloudRedisStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of CloudRedisClient.
Expand Down Expand Up @@ -236,7 +236,7 @@ export class CloudRedisClient {

// Put together the "service stub" for
// google.cloud.redis.v1beta1.CloudRedis.
this._cloudRedisStub = gaxGrpc.createStub(
this.cloudRedisStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.cloud.redis.v1beta1.CloudRedis') :
// tslint:disable-next-line no-any
Expand All @@ -249,7 +249,7 @@ export class CloudRedisClient {
['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance'];

for (const methodName of cloudRedisStubMethods) {
const innerCallPromise = this._cloudRedisStub.then(
const innerCallPromise = this.cloudRedisStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -1045,7 +1045,7 @@ export class CloudRedisClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._cloudRedisStub.then(stub => {
return this.cloudRedisStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const version = require('../../../package.json').version;
*/
export class EchoClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _echoStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
echoStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of EchoClient.
Expand Down Expand Up @@ -180,7 +180,7 @@ export class EchoClient {

// Put together the "service stub" for
// google.showcase.v1beta1.Echo.
this._echoStub = gaxGrpc.createStub(
this.echoStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.showcase.v1beta1.Echo') :
// tslint:disable-next-line no-any
Expand All @@ -193,7 +193,7 @@ export class EchoClient {
['echo', 'expand', 'collect', 'chat', 'pagedExpand', 'wait'];

for (const methodName of echoStubMethods) {
const innerCallPromise = this._echoStub.then(
const innerCallPromise = this.echoStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -586,7 +586,7 @@ export class EchoClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._echoStub.then(stub => {
return this.echoStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const version = require('../../../package.json').version;
*/
export class TextToSpeechClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _textToSpeechStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
textToSpeechStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of TextToSpeechClient.
Expand Down Expand Up @@ -137,7 +137,7 @@ export class TextToSpeechClient {

// Put together the "service stub" for
// google.cloud.texttospeech.v1.TextToSpeech.
this._textToSpeechStub = gaxGrpc.createStub(
this.textToSpeechStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.cloud.texttospeech.v1.TextToSpeech') :
// tslint:disable-next-line no-any
Expand All @@ -150,7 +150,7 @@ export class TextToSpeechClient {
['listVoices', 'synthesizeSpeech'];

for (const methodName of textToSpeechStubMethods) {
const innerCallPromise = this._textToSpeechStub.then(
const innerCallPromise = this.textToSpeechStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -355,7 +355,7 @@ export class TextToSpeechClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._textToSpeechStub.then(stub => {
return this.textToSpeechStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const version = require('../../../package.json').version;
*/
export class TranslationServiceClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _translationServiceStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _pathTemplates: {[name: string]: gax.PathTemplate};
private _terminated = false;
auth: gax.GoogleAuth;
translationServiceStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of TranslationServiceClient.
Expand Down Expand Up @@ -198,7 +198,7 @@ export class TranslationServiceClient {

// Put together the "service stub" for
// google.cloud.translation.v3beta1.TranslationService.
this._translationServiceStub = gaxGrpc.createStub(
this.translationServiceStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.cloud.translation.v3beta1.TranslationService') :
// tslint:disable-next-line no-any
Expand All @@ -211,7 +211,7 @@ export class TranslationServiceClient {
['translateText', 'detectLanguage', 'getSupportedLanguages', 'batchTranslateText', 'createGlossary', 'listGlossaries', 'getGlossary', 'deleteGlossary'];

for (const methodName of translationServiceStubMethods) {
const innerCallPromise = this._translationServiceStub.then(
const innerCallPromise = this.translationServiceStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -1118,7 +1118,7 @@ export class TranslationServiceClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._translationServiceStub.then(stub => {
return this.translationServiceStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down