From 65994f9a1d86dae0c0eec0fd454835b9ad194dd5 Mon Sep 17 00:00:00 2001 From: Xiaozhen Liu Date: Tue, 1 Oct 2019 13:41:31 -0400 Subject: [PATCH] feat: support LRO methods (#27) * init lro setup * upgrade google-gax * add dom to tsconfig for browser check * copy protos to build/ * Revert "copy protos to build/" This reverts commit 028eb20616af051adfa339a3d80fc92160ec445c. * copy protos/ to build/ * load protos from json file * LRO methods & update baseline test * gts fix * update gts version and fix back the format * change path name & update baseline --- package.json | 4 +- templates/typescript_gapic/package.json.njk | 4 +- .../src/$version/$service_client.ts.njk | 183 ++++++++++++------ templates/typescript_gapic/tsconfig.json.njk | 3 +- .../test/testdata/echo_client_baseline.ts.txt | 175 +++++++++++++---- 5 files changed, 266 insertions(+), 103 deletions(-) diff --git a/package.json b/package.json index 86c30f790..288e4be6a 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,11 @@ "@types/command-line-args": "^5.0.0", "@types/get-stdin": "^5.0.1", "@types/mocha": "^5.2.5", - "@types/node": "^11.12.0", + "@types/node": "^11.13.20", "@types/nunjucks": "^3.1.0", "@types/rimraf": "^2.0.2", "assert-rejects": "^1.0.0", - "c8": "^5.0.1", + "c8": "^5.0.4", "codecov": "^3.0.4", "espower-typescript": "^9.0.0", "google-gax": "^1.6.0", diff --git a/templates/typescript_gapic/package.json.njk b/templates/typescript_gapic/package.json.njk index 619888e7c..c53d80649 100644 --- a/templates/typescript_gapic/package.json.njk +++ b/templates/typescript_gapic/package.json.njk @@ -23,8 +23,8 @@ "scripts": { "lint": "gts check", "clean": "gts clean", - "compile": "tsc -p .", - "compile-protos": "pbjs -p protos -t static-module -o pbjs-genfiles/protos.js {{ api.filesToGenerate.join(' ') }} && pbts pbjs-genfiles/protos.js -o pbjs-genfiles/protos.d.ts", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", "pretest": "npm run compile-protos && npm run compile" diff --git a/templates/typescript_gapic/src/$version/$service_client.ts.njk b/templates/typescript_gapic/src/$version/$service_client.ts.njk index 3cacf1a72..8ff607ea6 100644 --- a/templates/typescript_gapic/src/$version/$service_client.ts.njk +++ b/templates/typescript_gapic/src/$version/$service_client.ts.njk @@ -1,10 +1,9 @@ {% import "./license.njk" as license %}{{license.license()}} import * as gax from 'google-gax'; import * as path from 'path'; -import * as protobuf from 'protobufjs'; import * as packageJson from '../../package.json'; -import * as protos from '../../pbjs-genfiles/protos'; +import * as protosTypes from '../../protos/protos'; import * as gapicConfig from './echo_client_config.json'; const version = packageJson.version; @@ -14,7 +13,9 @@ export interface ClientOptions extends gax.GrpcClientOptions, gax.ClientStubOptions { libName?: string; libVersion?: string; - clientConfig?: gax.ClientConfig; + clientConfig: gax.ClientConfig; + fallback?: boolean; + apiEndpoint?: string; } interface Descriptors { @@ -49,42 +50,56 @@ export class {{ service.name }}Client { constructor(opts: ClientOptions) { // Ensure that options include the service address and port. + opts = opts || {}; + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + const servicePath = + opts.servicePath || + opts.apiEndpoint || + (this.constructor as typeof {{service.name}}Client).servicePath; + opts = Object.assign( { clientConfig: {}, port: (this.constructor as typeof {{ service.name }}Client).port, - servicePath: (this.constructor as typeof {{ service.name }}Client).servicePath, + servicePath: servicePath, }, opts); // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof {{ service.name }}Client).scopes; - const gaxGrpc = new gax.GrpcClient(opts); + const gaxGrpc = new gaxModule.GrpcClient(opts); // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; + this.auth = (gaxGrpc.auth as gax.GoogleAuth); // Determine the client header string. const clientHeader = [ `gl-node/${process.version}`, `grpc/${gaxGrpc.grpcVersion}`, - `gax/${gax.version}`, + `gax/${gaxModule.version}`, `gapic/${version}`, + `gl-web/${gaxModule.version}` ]; if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. - const gaxProtos = Object.assign( - {}, -{%- set protosJoiner = joiner() %} -{%- for filename in api.filesToGenerate %} - {{- protosJoiner() }} - gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos'), - '{{ filename }}') -{%- endfor -%} + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath ); {%- if (service.paging.length > 0) %} @@ -96,7 +111,7 @@ export class {{ service.name }}Client { {%- for method in service.paging %} {{- pagingJoiner() }} {{ method.name.toCamelCase() }}: - new gax.PageDescriptor('pageToken', 'nextPageToken', '{{ method.pagingFieldName }}') + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', '{{ method.pagingFieldName }}') {%- endfor %} }; {%- endif %} @@ -109,41 +124,41 @@ export class {{ service.name }}Client { {%- set streamingJoiner = joiner() %} {%- for method in service.streaming %} {{- streamingJoiner() }} - {{ method.name.toCamelCase() }}: new gax.StreamDescriptor(gax.StreamType.{{ method.streaming }}) + {{ method.name.toCamelCase() }}: new gaxModule.StreamDescriptor(gax.StreamType.{{ method.streaming }}) {%- endfor %} }; {%- endif %} -{%- if (service.longrunning.length > 0) %} +{%- if (service.longRunning.length > 0) %} // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - let protoFilesRoot = new gax.GoogleProtoFilesRoot(); -{%- for filename in api.filesToGenerate %} - protoFilesRoot = protobuf.loadSync( - path.join(__dirname, '..', '..', 'protos', '{{ filename }}'), - protoFilesRoot); -{%- endfor %} + const protoFilesRoot = opts.fallback? + gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) : + gaxModule.protobuf.loadSync(nodejsProtoPath); - const operationsClient = new gax.lro({ - auth: gaxGrpc.auth, + const operationsClient = gaxModule.lro({ + auth: this.auth, + // @ts-ignore grpc: gaxGrpc.grpc, }).operationsClient(opts); -{%- for method in service.longrunning %} +{%- for method in service.longRunning %} const {{ method.name.toCamelCase() }}Response = protoFilesRoot.lookup( - '{{ method.longrunning.responseType }}'); + '{{ method.longRunning.responseType }}'); const {{ method.name.toCamelCase() }}Metadata = protoFilesRoot.lookup( - '{{ method.longrunning.metadataType }}'); + '{{ method.longRunning.metadataType }}'); {%- endfor %} this._descriptors.longrunning = { -{%- set longrunningJoiner = joiner() %} -{%- for method in service.longrunning %} - {{- longrunningJoiner() }} - {{ method.name.toCamelCase() }}: new gax.LongrunningDescriptor( +{%- set longRunningJoiner = joiner() %} +{%- for method in service.longRunning %} + {{- longRunningJoiner() }} + {{ method.name.toCamelCase() }}: new gaxModule.LongrunningDescriptor( operationsClient, + // @ts-ignore {{ method.name.toCamelCase() }}Response.decode.bind({{ method.name.toCamelCase() }}Response), + // @ts-ignore {{ method.name.toCamelCase() }}Metadata.decode.bind({{ method.name.toCamelCase() }}Metadata)) {%- endfor %} }; @@ -161,9 +176,14 @@ export class {{ service.name }}Client { // Put together the "service stub" for // google.showcase.v1alpha2.Echo. - const {{ service.name.toCamelCase() }}Stub = + const {{ service.name.toCamelCase() }}Stub = gaxGrpc.createStub( // @ts-ignore We cannot check types that are loaded in runtime. - gaxGrpc.createStub(gaxProtos.{{ api.naming.protoPackage }}.{{ service.name }}, opts); + opts.fallback ? + // @ts-ignore + protos.lookupService('{{api.naming.protoPackage}}.{{ service.name }}') : + // @ts-ignore + protos.{{api.naming.protoPackage}}.{{ service.name }}, + opts); const {{ service.name.toCamelCase() }}StubMethods = [ @@ -175,7 +195,9 @@ export class {{ service.name }}Client { ]; for (const methodName of {{ service.name.toCamelCase() }}StubMethods) { + // @ts-ignore const innerCallPromise = {{ service.name.toCamelCase() }}Stub.then( + // @ts-ignore stub => (...args: Array<{}>) => { return stub[methodName].apply(stub, args); }, @@ -198,6 +220,13 @@ export class {{ service.name }}Client { static get servicePath() { return '{{ service.hostname }}'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'localhost'; + } /** * The port for this API service. @@ -246,31 +275,31 @@ export class {{ service.name }}Client { {%- for method in service.simpleMethods %} {{ method.name.toCamelCase() }}( - request: protos{{ method.inputInterface }}, + request: protosTypes{{ method.inputInterface }}, options?: gax.CallOptions): Promise<[ - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined ]>; {{ method.name.toCamelCase() }}( - request: protos{{ method.inputInterface }}, + request: protosTypes{{ method.inputInterface }}, options: gax.CallOptions, callback: Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>): void; {{ method.name.toCamelCase() }}( - request: protos{{ method.inputInterface }}, + request: protosTypes{{ method.inputInterface }}, optionsOrCallback?: gax.CallOptions|Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined>, + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>, callback?: Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>): Promise<[ - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined ]>|void { request = request || {}; let options = optionsOrCallback; @@ -292,7 +321,7 @@ export class {{ service.name }}Client { } {%- elif method.serverStreaming %} {{ method.name.toCamelCase() }}( - request?: protos{{ method.inputInterface }}, + request?: protosTypes{{ method.inputInterface }}, options?: gax.CallOptions): gax.ServerStreamingCall{ request = request || {}; @@ -303,21 +332,21 @@ export class {{ service.name }}Client { {{ method.name.toCamelCase() }}( options: gax.CallOptions, callback: Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined>): + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>): gax.ClientStreamingCall; {{ method.name.toCamelCase() }}( callback: Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined>): + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>): gax.ClientStreamingCall; {{ method.name.toCamelCase() }}( optionsOrCallback: gax.CallOptions|Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined>, + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>, callback?: Callback< - protos{{ method.outputInterface }}, - protos{{ method.inputInterface }}|undefined, {}|undefined>): + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>): gax.ClientStreamingCall { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -328,4 +357,42 @@ export class {{ service.name }}Client { } {%- endif %} {% endfor %} +{%- for method in service.longRunning %} + {{ method.name.toCamelCase() }}( + request: protosTypes{{ method.inputInterface }}, + options?: gax.CallOptions): + Promise<[ + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined + ]>; + {{ method.name.toCamelCase() }}( + request: protosTypes{{ method.inputInterface }}, + options: gax.CallOptions, + callback: Callback< + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, + {}|undefined>): void; + {{ method.name.toCamelCase() }}( + request: protosTypes{{ method.inputInterface }}, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined>, + callback?: Callback< + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, + {}|undefined>): + Promise<[ + protosTypes{{ method.outputInterface }}, + protosTypes{{ method.inputInterface }}|undefined, {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.{{ method.name.toCamelCase() }}(request, options, callback); + } +{%- endfor %} } diff --git a/templates/typescript_gapic/tsconfig.json.njk b/templates/typescript_gapic/tsconfig.json.njk index a7647fcc4..2d9b83e3f 100644 --- a/templates/typescript_gapic/tsconfig.json.njk +++ b/templates/typescript_gapic/tsconfig.json.njk @@ -3,7 +3,8 @@ "compilerOptions": { "rootDir": ".", "outDir": "build", - "resolveJsonModule": true + "resolveJsonModule": true, + "lib": ["es2016", "dom"] }, "include": [ "src/*.ts", diff --git a/typescript/test/testdata/echo_client_baseline.ts.txt b/typescript/test/testdata/echo_client_baseline.ts.txt index efa02f718..f85a9b5f5 100644 --- a/typescript/test/testdata/echo_client_baseline.ts.txt +++ b/typescript/test/testdata/echo_client_baseline.ts.txt @@ -18,10 +18,9 @@ import * as gax from 'google-gax'; import * as path from 'path'; -import * as protobuf from 'protobufjs'; import * as packageJson from '../../package.json'; -import * as protos from '../../pbjs-genfiles/protos'; +import * as protosTypes from '../../protos/protos'; import * as gapicConfig from './echo_client_config.json'; const version = packageJson.version; @@ -31,7 +30,9 @@ export interface ClientOptions extends gax.GrpcClientOptions, gax.ClientStubOptions { libName?: string; libVersion?: string; - clientConfig?: gax.ClientConfig; + clientConfig: gax.ClientConfig; + fallback?: boolean; + apiEndpoint?: string; } interface Descriptors { @@ -66,53 +67,97 @@ export class EchoClient { constructor(opts: ClientOptions) { // Ensure that options include the service address and port. + opts = opts || {}; + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + const servicePath = + opts.servicePath || + opts.apiEndpoint || + (this.constructor as typeof EchoClient).servicePath; + opts = Object.assign( { clientConfig: {}, port: (this.constructor as typeof EchoClient).port, - servicePath: (this.constructor as typeof EchoClient).servicePath, + servicePath: servicePath, }, opts); // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof EchoClient).scopes; - const gaxGrpc = new gax.GrpcClient(opts); + const gaxGrpc = new gaxModule.GrpcClient(opts); // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; + this.auth = (gaxGrpc.auth as gax.GoogleAuth); // Determine the client header string. const clientHeader = [ `gl-node/${process.version}`, `grpc/${gaxGrpc.grpcVersion}`, - `gax/${gax.version}`, + `gax/${gaxModule.version}`, `gapic/${version}`, + `gl-web/${gaxModule.version}` ]; if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. - const gaxProtos = Object.assign( - {}, - gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos'), - 'google/showcase/v1beta1/echo.proto')); + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { pagedExpand: - new gax.PageDescriptor('pageToken', 'nextPageToken', 'responses') + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'responses') }; // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this._descriptors.stream = { - expand: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - collect: new gax.StreamDescriptor(gax.StreamType.CLIENT_STREAMING), - chat: new gax.StreamDescriptor(gax.StreamType.BIDI_STREAMING) + expand: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + collect: new gaxModule.StreamDescriptor(gax.StreamType.CLIENT_STREAMING), + chat: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING) + }; + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const protoFilesRoot = opts.fallback? + gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) : + gaxModule.protobuf.loadSync(nodejsProtoPath); + + const operationsClient = gaxModule.lro({ + auth: this.auth, + // @ts-ignore + grpc: gaxGrpc.grpc, + }).operationsClient(opts); + const waitResponse = protoFilesRoot.lookup( + 'WaitResponse'); + const waitMetadata = protoFilesRoot.lookup( + 'WaitMetadata'); + + this._descriptors.longrunning = { + wait: new gaxModule.LongrunningDescriptor( + operationsClient, + // @ts-ignore + waitResponse.decode.bind(waitResponse), + // @ts-ignore + waitMetadata.decode.bind(waitMetadata)) }; // Put together the default options sent with requests. @@ -127,15 +172,22 @@ export class EchoClient { // Put together the "service stub" for // google.showcase.v1alpha2.Echo. - const echoStub = + const echoStub = gaxGrpc.createStub( // @ts-ignore We cannot check types that are loaded in runtime. - gaxGrpc.createStub(gaxProtos.google.showcase.v1beta1.Echo, opts); + opts.fallback ? + // @ts-ignore + protos.lookupService('google.showcase.v1beta1.Echo') : + // @ts-ignore + protos.google.showcase.v1beta1.Echo, + opts); const echoStubMethods = ['echo', 'expand', 'collect', 'chat', 'pagedExpand', 'wait']; for (const methodName of echoStubMethods) { + // @ts-ignore const innerCallPromise = echoStub.then( + // @ts-ignore stub => (...args: Array<{}>) => { return stub[methodName].apply(stub, args); }, @@ -158,6 +210,13 @@ export class EchoClient { static get servicePath() { return 'localhost'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'localhost'; + } /** * The port for this API service. @@ -194,31 +253,31 @@ export class EchoClient { // -- Service calls -- // ------------------- echo( - request: protos.google.showcase.v1beta1.IEchoRequest, + request: protosTypes.google.showcase.v1beta1.IEchoRequest, options?: gax.CallOptions): Promise<[ - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined ]>; echo( - request: protos.google.showcase.v1beta1.IEchoRequest, + request: protosTypes.google.showcase.v1beta1.IEchoRequest, options: gax.CallOptions, callback: Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): void; echo( - request: protos.google.showcase.v1beta1.IEchoRequest, + request: protosTypes.google.showcase.v1beta1.IEchoRequest, optionsOrCallback?: gax.CallOptions|Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, callback?: Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): Promise<[ - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined ]>|void { request = request || {}; let options = optionsOrCallback; @@ -231,7 +290,7 @@ export class EchoClient { } expand( - request?: protos.google.showcase.v1beta1.IExpandRequest, + request?: protosTypes.google.showcase.v1beta1.IExpandRequest, options?: gax.CallOptions): gax.ServerStreamingCall{ request = request || {}; @@ -242,21 +301,21 @@ export class EchoClient { collect( options: gax.CallOptions, callback: Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): gax.ClientStreamingCall; collect( callback: Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): gax.ClientStreamingCall; collect( optionsOrCallback: gax.CallOptions|Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, callback?: Callback< - protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protosTypes.google.showcase.v1beta1.IEchoResponse, + protosTypes.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): gax.ClientStreamingCall { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -273,4 +332,40 @@ export class EchoClient { return this._innerApiCalls.chat(options); } + wait( + request: protosTypes.google.showcase.v1beta1.IWaitRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.longrunning.IOperation, + protosTypes.google.showcase.v1beta1.IWaitRequest|undefined, {}|undefined + ]>; + wait( + request: protosTypes.google.showcase.v1beta1.IWaitRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.longrunning.IOperation, + protosTypes.google.showcase.v1beta1.IWaitRequest|undefined, + {}|undefined>): void; + wait( + request: protosTypes.google.showcase.v1beta1.IWaitRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.longrunning.IOperation, + protosTypes.google.showcase.v1beta1.IWaitRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.longrunning.IOperation, + protosTypes.google.showcase.v1beta1.IWaitRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.longrunning.IOperation, + protosTypes.google.showcase.v1beta1.IWaitRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options = optionsOrCallback; + if (typeof options === 'function' && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + return this._innerApiCalls.wait(request, options, callback); + } }