@@ -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 ,
@@ -72,7 +73,7 @@ export class DataMigrationServiceClient {
72
73
*
73
74
* @param {object } [options] - The configuration object.
74
75
* The options accepted by the constructor are described in detail
75
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master /client-libraries.md#creating-the-client-instance).
76
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main /client-libraries.md#creating-the-client-instance).
76
77
* The common options are:
77
78
* @param {object } [options.credentials] - Credentials object.
78
79
* @param {string } [options.credentials.client_email]
@@ -95,11 +96,10 @@ export class DataMigrationServiceClient {
95
96
* API remote host.
96
97
* @param {gax.ClientConfig } [options.clientConfig] - Client configuration override.
97
98
* Follows the structure of {@link gapicConfig}.
98
- * @param {boolean } [options.fallback] - Use HTTP fallback mode.
99
- * In fallback mode, a special browser-compatible transport implementation is used
100
- * instead of gRPC transport. In browser context (if the `window` object is defined)
101
- * the fallback mode is enabled automatically; set `options.fallback` to `false`
102
- * if you need to override this behavior.
99
+ * @param {boolean | "rest" } [options.fallback] - Use HTTP fallback mode.
100
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
101
+ * For more information, please check the
102
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
103
103
*/
104
104
constructor ( opts ?: ClientOptions ) {
105
105
// Ensure that options include all the required fields.
@@ -197,16 +197,76 @@ export class DataMigrationServiceClient {
197
197
} ;
198
198
199
199
const protoFilesRoot = this . _gaxModule . protobuf . Root . fromJSON ( jsonProtos ) ;
200
-
201
200
// This API contains "long-running operations", which return a
202
201
// an Operation object that allows for tracking of the operation,
203
202
// rather than holding a request open.
204
-
203
+ const lroOptions : GrpcClientOptions = {
204
+ auth : this . auth ,
205
+ grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
206
+ } ;
207
+ if ( opts . fallback === 'rest' ) {
208
+ lroOptions . protoJson = protoFilesRoot ;
209
+ lroOptions . httpRules = [
210
+ {
211
+ selector : 'google.cloud.location.Locations.GetLocation' ,
212
+ get : '/v1/{name=projects/*/locations/*}' ,
213
+ } ,
214
+ {
215
+ selector : 'google.cloud.location.Locations.ListLocations' ,
216
+ get : '/v1/{name=projects/*}/locations' ,
217
+ } ,
218
+ {
219
+ selector : 'google.iam.v1.IAMPolicy.GetIamPolicy' ,
220
+ get : '/v1/{resource=projects/*/locations/*/connectionProfiles/*}:getIamPolicy' ,
221
+ additional_bindings : [
222
+ {
223
+ get : '/v1/{resource=projects/*/locations/*/migrationJobs/*}:getIamPolicy' ,
224
+ } ,
225
+ ] ,
226
+ } ,
227
+ {
228
+ selector : 'google.iam.v1.IAMPolicy.SetIamPolicy' ,
229
+ post : '/v1/{resource=projects/*/locations/*/connectionProfiles/*}:setIamPolicy' ,
230
+ body : '*' ,
231
+ additional_bindings : [
232
+ {
233
+ post : '/v1/{resource=projects/*/locations/*/migrationJobs/*}:setIamPolicy' ,
234
+ body : '*' ,
235
+ } ,
236
+ ] ,
237
+ } ,
238
+ {
239
+ selector : 'google.iam.v1.IAMPolicy.TestIamPermissions' ,
240
+ post : '/v1/{resource=projects/*/locations/*/migrationJobs/*}:testIamPermissions' ,
241
+ body : '*' ,
242
+ additional_bindings : [
243
+ {
244
+ post : '/v1/{resource=projects/*/locations/*/connectionProfiles/*}:testIamPermissions' ,
245
+ body : '*' ,
246
+ } ,
247
+ ] ,
248
+ } ,
249
+ {
250
+ selector : 'google.longrunning.Operations.CancelOperation' ,
251
+ post : '/v1/{name=projects/*/locations/*/operations/*}:cancel' ,
252
+ body : '*' ,
253
+ } ,
254
+ {
255
+ selector : 'google.longrunning.Operations.DeleteOperation' ,
256
+ delete : '/v1/{name=projects/*/locations/*/operations/*}' ,
257
+ } ,
258
+ {
259
+ selector : 'google.longrunning.Operations.GetOperation' ,
260
+ get : '/v1/{name=projects/*/locations/*/operations/*}' ,
261
+ } ,
262
+ {
263
+ selector : 'google.longrunning.Operations.ListOperations' ,
264
+ get : '/v1/{name=projects/*/locations/*}/operations' ,
265
+ } ,
266
+ ] ;
267
+ }
205
268
this . operationsClient = this . _gaxModule
206
- . lro ( {
207
- auth : this . auth ,
208
- grpc : 'grpc' in this . _gaxGrpc ? this . _gaxGrpc . grpc : undefined ,
209
- } )
269
+ . lro ( lroOptions )
210
270
. operationsClient ( opts ) ;
211
271
const createMigrationJobResponse = protoFilesRoot . lookup (
212
272
'.google.cloud.clouddms.v1.MigrationJob'
0 commit comments