@@ -23,6 +23,7 @@ import {
2323 CallOptions ,
2424 Descriptors ,
2525 ClientOptions ,
26+ GrpcClientOptions ,
2627 LROperation ,
2728} from 'google-gax' ;
2829
@@ -70,7 +71,7 @@ export class ImageAnnotatorClient {
7071 *
7172 * @param {object } [options] - The configuration object.
7273 * The options accepted by the constructor are described in detail
73- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
74+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
7475 * The common options are:
7576 * @param {object } [options.credentials] - Credentials object.
7677 * @param {string } [options.credentials.client_email]
@@ -93,11 +94,10 @@ export class ImageAnnotatorClient {
9394 * API remote host.
9495 * @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
9596 * Follows the structure of {@link gapicConfig}.
96- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
97- * In fallback mode, a special browser-compatible transport implementation is used
98- * instead of gRPC transport. In browser context (if the `window` object is defined)
99- * the fallback mode is enabled automatically; set `options.fallback` to `false`
100- * if you need to override this behavior.
97+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
98+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
99+ * For more information, please check the
100+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
101101 */
102102 constructor ( opts ?: ClientOptions ) {
103103 // Ensure that options include all the required fields.
@@ -176,16 +176,29 @@ export class ImageAnnotatorClient {
176176 } ;
177177
178178 const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
179-
180179 // This API contains "long-running operations", which return a
181180 // an Operation object that allows for tracking of the operation,
182181 // rather than holding a request open.
183-
182+ const lroOptions : GrpcClientOptions = {
183+ auth : this . auth ,
184+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
185+ } ;
186+ if ( opts . fallback === 'rest' ) {
187+ lroOptions . protoJson = protoFilesRoot ;
188+ lroOptions . httpRules = [
189+ {
190+ selector : 'google.longrunning.Operations.GetOperation' ,
191+ get : '/v1/{name=projects/*/operations/*}' ,
192+ additional_bindings : [
193+ { get : '/v1/{name=projects/*/locations/*/operations/*}' } ,
194+ { get : '/v1/{name=operations/*}' } ,
195+ { get : '/v1/{name=locations/*/operations/*}' } ,
196+ ] ,
197+ } ,
198+ ] ;
199+ }
184200 this . operationsClient = this . _gaxModule
185- . lro ( {
186- auth : this . auth ,
187- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
188- } )
201+ . lro ( lroOptions )
189202 . operationsClient ( opts ) ;
190203 const asyncBatchAnnotateImagesResponse = protoFilesRoot . lookup (
191204 '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse'
0 commit comments