@@ -23,6 +23,7 @@ import {
23
23
CallOptions ,
24
24
Descriptors ,
25
25
ClientOptions ,
26
+ GrpcClientOptions ,
26
27
LROperation ,
27
28
PaginationCallback ,
28
29
GaxCall ,
@@ -86,7 +87,7 @@ export class CloudRedisClient {
86
87
*
87
88
* @param {object } [options] - The configuration object.
88
89
* The options accepted by the constructor are described in detail
89
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
90
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
90
91
* The common options are:
91
92
* @param {object } [options.credentials] - Credentials object.
92
93
* @param {string } [options.credentials.client_email]
@@ -109,11 +110,10 @@ export class CloudRedisClient {
109
110
* API remote host.
110
111
* @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
111
112
* Follows the structure of {@link gapicConfig}.
112
- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
113
- * In fallback mode, a special browser-compatible transport implementation is used
114
- * instead of gRPC transport. In browser context (if the `window` object is defined)
115
- * the fallback mode is enabled automatically; set `options.fallback` to `false`
116
- * if you need to override this behavior.
113
+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
114
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
115
+ * For more information, please check the
116
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
117
117
*/
118
118
constructor ( opts ?: ClientOptions ) {
119
119
// Ensure that options include all the required fields.
@@ -200,16 +200,44 @@ export class CloudRedisClient {
200
200
} ;
201
201
202
202
const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
203
-
204
203
// This API contains "long-running operations", which return a
205
204
// an Operation object that allows for tracking of the operation,
206
205
// rather than holding a request open.
207
-
206
+ const lroOptions : GrpcClientOptions = {
207
+ auth : this . auth ,
208
+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
209
+ } ;
210
+ if ( opts . fallback === 'rest' ) {
211
+ lroOptions . protoJson = protoFilesRoot ;
212
+ lroOptions . httpRules = [
213
+ {
214
+ selector : 'google.cloud.location.Locations.GetLocation' ,
215
+ get : '/v1beta1/{name=projects/*/locations/*}' ,
216
+ } ,
217
+ {
218
+ selector : 'google.cloud.location.Locations.ListLocations' ,
219
+ get : '/v1beta1/{name=projects/*}/locations' ,
220
+ } ,
221
+ {
222
+ selector : 'google.longrunning.Operations.CancelOperation' ,
223
+ post : '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel' ,
224
+ } ,
225
+ {
226
+ selector : 'google.longrunning.Operations.DeleteOperation' ,
227
+ delete : '/v1beta1/{name=projects/*/locations/*/operations/*}' ,
228
+ } ,
229
+ {
230
+ selector : 'google.longrunning.Operations.GetOperation' ,
231
+ get : '/v1beta1/{name=projects/*/locations/*/operations/*}' ,
232
+ } ,
233
+ {
234
+ selector : 'google.longrunning.Operations.ListOperations' ,
235
+ get : '/v1beta1/{name=projects/*/locations/*}/operations' ,
236
+ } ,
237
+ ] ;
238
+ }
208
239
this . operationsClient = this . _gaxModule
209
- . lro ( {
210
- auth : this . auth ,
211
- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
212
- } )
240
+ . lro ( lroOptions )
213
241
. operationsClient ( opts ) ;
214
242
const createInstanceResponse = protoFilesRoot . lookup (
215
243
'.google.cloud.redis.v1beta1.Instance'
0 commit comments