@@ -23,6 +23,7 @@ import {
2323 CallOptions ,
2424 Descriptors ,
2525 ClientOptions ,
26+ GrpcClientOptions ,
2627 LROperation ,
2728} from 'google-gax' ;
2829
@@ -71,7 +72,7 @@ export class CompletionServiceClient {
7172 *
7273 * @param {object } [options] - The configuration object.
7374 * The options accepted by the constructor are described in detail
74- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
75+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
7576 * The common options are:
7677 * @param {object } [options.credentials] - Credentials object.
7778 * @param {string } [options.credentials.client_email]
@@ -94,11 +95,10 @@ export class CompletionServiceClient {
9495 * API remote host.
9596 * @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
9697 * Follows the structure of {@link gapicConfig}.
97- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
98- * In fallback mode, a special browser-compatible transport implementation is used
99- * instead of gRPC transport. In browser context (if the `window` object is defined)
100- * the fallback mode is enabled automatically; set `options.fallback` to `false`
101- * if you need to override this behavior.
98+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
99+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
100+ * For more information, please check the
101+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
102102 */
103103 constructor ( opts ?: ClientOptions ) {
104104 // Ensure that options include all the required fields.
@@ -174,16 +174,39 @@ export class CompletionServiceClient {
174174 } ;
175175
176176 const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
177-
178177 // This API contains "long-running operations", which return a
179178 // an Operation object that allows for tracking of the operation,
180179 // rather than holding a request open.
181-
180+ const lroOptions : GrpcClientOptions = {
181+ auth : this . auth ,
182+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
183+ } ;
184+ if ( opts . fallback === 'rest' ) {
185+ lroOptions . protoJson = protoFilesRoot ;
186+ lroOptions . httpRules = [
187+ {
188+ selector : 'google.longrunning.Operations.GetOperation' ,
189+ get : '/v2/{name=projects/*/locations/*/operations/*}' ,
190+ additional_bindings : [
191+ {
192+ get : '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}' ,
193+ } ,
194+ { get : '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}' } ,
195+ { get : '/v2/{name=projects/*/operations/*}' } ,
196+ ] ,
197+ } ,
198+ {
199+ selector : 'google.longrunning.Operations.ListOperations' ,
200+ get : '/v2/{name=projects/*/locations/*}/operations' ,
201+ additional_bindings : [
202+ { get : '/v2/{name=projects/*/locations/*/catalogs/*}/operations' } ,
203+ { get : '/v2/{name=projects/*}/operations' } ,
204+ ] ,
205+ } ,
206+ ] ;
207+ }
182208 this . operationsClient = this . _gaxModule
183- . lro ( {
184- auth : this . auth ,
185- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
186- } )
209+ . lro ( lroOptions )
187210 . operationsClient ( opts ) ;
188211 const importCompletionDataResponse = protoFilesRoot . lookup (
189212 '.google.cloud.retail.v2.ImportCompletionDataResponse'
0 commit comments