@@ -23,6 +23,7 @@ import {
2323 CallOptions ,
2424 Descriptors ,
2525 ClientOptions ,
26+ GrpcClientOptions ,
2627 LROperation ,
2728 PaginationCallback ,
2829 GaxCall ,
@@ -131,7 +132,7 @@ export class DatastoreAdminClient {
131132 *
132133 * @param {object } [options] - The configuration object.
133134 * The options accepted by the constructor are described in detail
134- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
135+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
135136 * The common options are:
136137 * @param {object } [options.credentials] - Credentials object.
137138 * @param {string } [options.credentials.client_email]
@@ -154,11 +155,10 @@ export class DatastoreAdminClient {
154155 * API remote host.
155156 * @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
156157 * Follows the structure of {@link gapicConfig}.
157- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
158- * In fallback mode, a special browser-compatible transport implementation is used
159- * instead of gRPC transport. In browser context (if the `window` object is defined)
160- * the fallback mode is enabled automatically; set `options.fallback` to `false`
161- * if you need to override this behavior.
158+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
159+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
160+ * For more information, please check the
161+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
162162 */
163163 constructor ( opts ?: ClientOptions ) {
164164 // Ensure that options include all the required fields.
@@ -233,16 +233,36 @@ export class DatastoreAdminClient {
233233 } ;
234234
235235 const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
236-
237236 // This API contains "long-running operations", which return a
238237 // an Operation object that allows for tracking of the operation,
239238 // rather than holding a request open.
240-
239+ const lroOptions : GrpcClientOptions = {
240+ auth : this . auth ,
241+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
242+ } ;
243+ if ( opts . fallback === 'rest' ) {
244+ lroOptions . protoJson = protoFilesRoot ;
245+ lroOptions . httpRules = [
246+ {
247+ selector : 'google.longrunning.Operations.CancelOperation' ,
248+ post : '/v1/{name=projects/*/operations/*}:cancel' ,
249+ } ,
250+ {
251+ selector : 'google.longrunning.Operations.DeleteOperation' ,
252+ delete : '/v1/{name=projects/*/operations/*}' ,
253+ } ,
254+ {
255+ selector : 'google.longrunning.Operations.GetOperation' ,
256+ get : '/v1/{name=projects/*/operations/*}' ,
257+ } ,
258+ {
259+ selector : 'google.longrunning.Operations.ListOperations' ,
260+ get : '/v1/{name=projects/*}/operations' ,
261+ } ,
262+ ] ;
263+ }
241264 this . operationsClient = this . _gaxModule
242- . lro ( {
243- auth : this . auth ,
244- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
245- } )
265+ . lro ( lroOptions )
246266 . operationsClient ( opts ) ;
247267 const exportEntitiesResponse = protoFilesRoot . lookup (
248268 '.google.datastore.admin.v1.ExportEntitiesResponse'
0 commit comments