1717// ** All changes to this file may be overwritten. **
1818
1919/* global window */
20- import * as gax from 'google-gax' ;
21- import {
20+ import type * as gax from 'google-gax' ;
21+ import type {
2222 Callback ,
2323 CallOptions ,
2424 Descriptors ,
2525 ClientOptions ,
2626 PaginationCallback ,
2727 GaxCall ,
2828} from 'google-gax' ;
29-
3029import { Transform } from 'stream' ;
3130import * as protos from '../../protos/protos' ;
3231import jsonProtos = require( '../../protos/protos.json' ) ;
@@ -36,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json');
3635 * This file defines retry strategy and timeouts for all API methods in this library.
3736 */
3837import * as gapicConfig from './data_transfer_service_client_config.json' ;
39-
4038const version = require ( '../../../package.json' ) . version ;
4139
4240/**
@@ -96,8 +94,18 @@ export class DataTransferServiceClient {
9694 * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
9795 * For more information, please check the
9896 * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
97+ * @param {gax } [gaxInstance]: loaded instance of `google-gax`. Useful if you
98+ * need to avoid loading the default gRPC version and want to use the fallback
99+ * HTTP implementation. Load only fallback version and pass it to the constructor:
100+ * ```
101+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
102+ * const client = new DataTransferServiceClient({fallback: 'rest'}, gax);
103+ * ```
99104 */
100- constructor ( opts ?: ClientOptions ) {
105+ constructor (
106+ opts ?: ClientOptions ,
107+ gaxInstance ?: typeof gax | typeof gax . fallback
108+ ) {
101109 // Ensure that options include all the required fields.
102110 const staticMembers = this . constructor as typeof DataTransferServiceClient ;
103111 const servicePath =
@@ -117,8 +125,13 @@ export class DataTransferServiceClient {
117125 opts [ 'scopes' ] = staticMembers . scopes ;
118126 }
119127
128+ // Load google-gax module synchronously if needed
129+ if ( ! gaxInstance ) {
130+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
131+ }
132+
120133 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
121- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
134+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
122135
123136 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
124137 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -227,7 +240,7 @@ export class DataTransferServiceClient {
227240 this . innerApiCalls = { } ;
228241
229242 // Add a warn function to the client constructor so it can be easily tested.
230- this . warn = gax . warn ;
243+ this . warn = this . _gaxModule . warn ;
231244 }
232245
233246 /**
@@ -455,7 +468,7 @@ export class DataTransferServiceClient {
455468 options . otherArgs = options . otherArgs || { } ;
456469 options . otherArgs . headers = options . otherArgs . headers || { } ;
457470 options . otherArgs . headers [ 'x-goog-request-params' ] =
458- gax . routingHeader . fromParams ( {
471+ this . _gaxModule . routingHeader . fromParams ( {
459472 name : request . name || '' ,
460473 } ) ;
461474 this . initialize ( ) ;
@@ -586,7 +599,7 @@ export class DataTransferServiceClient {
586599 options . otherArgs = options . otherArgs || { } ;
587600 options . otherArgs . headers = options . otherArgs . headers || { } ;
588601 options . otherArgs . headers [ 'x-goog-request-params' ] =
589- gax . routingHeader . fromParams ( {
602+ this . _gaxModule . routingHeader . fromParams ( {
590603 parent : request . parent || '' ,
591604 } ) ;
592605 this . initialize ( ) ;
@@ -716,7 +729,7 @@ export class DataTransferServiceClient {
716729 options . otherArgs = options . otherArgs || { } ;
717730 options . otherArgs . headers = options . otherArgs . headers || { } ;
718731 options . otherArgs . headers [ 'x-goog-request-params' ] =
719- gax . routingHeader . fromParams ( {
732+ this . _gaxModule . routingHeader . fromParams ( {
720733 'transfer_config.name' : request . transferConfig ! . name || '' ,
721734 } ) ;
722735 this . initialize ( ) ;
@@ -816,7 +829,7 @@ export class DataTransferServiceClient {
816829 options . otherArgs = options . otherArgs || { } ;
817830 options . otherArgs . headers = options . otherArgs . headers || { } ;
818831 options . otherArgs . headers [ 'x-goog-request-params' ] =
819- gax . routingHeader . fromParams ( {
832+ this . _gaxModule . routingHeader . fromParams ( {
820833 name : request . name || '' ,
821834 } ) ;
822835 this . initialize ( ) ;
@@ -915,7 +928,7 @@ export class DataTransferServiceClient {
915928 options . otherArgs = options . otherArgs || { } ;
916929 options . otherArgs . headers = options . otherArgs . headers || { } ;
917930 options . otherArgs . headers [ 'x-goog-request-params' ] =
918- gax . routingHeader . fromParams ( {
931+ this . _gaxModule . routingHeader . fromParams ( {
919932 name : request . name || '' ,
920933 } ) ;
921934 this . initialize ( ) ;
@@ -1025,7 +1038,7 @@ export class DataTransferServiceClient {
10251038 options . otherArgs = options . otherArgs || { } ;
10261039 options . otherArgs . headers = options . otherArgs . headers || { } ;
10271040 options . otherArgs . headers [ 'x-goog-request-params' ] =
1028- gax . routingHeader . fromParams ( {
1041+ this . _gaxModule . routingHeader . fromParams ( {
10291042 parent : request . parent || '' ,
10301043 } ) ;
10311044 this . initialize ( ) ;
@@ -1137,7 +1150,7 @@ export class DataTransferServiceClient {
11371150 options . otherArgs = options . otherArgs || { } ;
11381151 options . otherArgs . headers = options . otherArgs . headers || { } ;
11391152 options . otherArgs . headers [ 'x-goog-request-params' ] =
1140- gax . routingHeader . fromParams ( {
1153+ this . _gaxModule . routingHeader . fromParams ( {
11411154 parent : request . parent || '' ,
11421155 } ) ;
11431156 this . initialize ( ) ;
@@ -1240,7 +1253,7 @@ export class DataTransferServiceClient {
12401253 options . otherArgs = options . otherArgs || { } ;
12411254 options . otherArgs . headers = options . otherArgs . headers || { } ;
12421255 options . otherArgs . headers [ 'x-goog-request-params' ] =
1243- gax . routingHeader . fromParams ( {
1256+ this . _gaxModule . routingHeader . fromParams ( {
12441257 name : request . name || '' ,
12451258 } ) ;
12461259 this . initialize ( ) ;
@@ -1339,7 +1352,7 @@ export class DataTransferServiceClient {
13391352 options . otherArgs = options . otherArgs || { } ;
13401353 options . otherArgs . headers = options . otherArgs . headers || { } ;
13411354 options . otherArgs . headers [ 'x-goog-request-params' ] =
1342- gax . routingHeader . fromParams ( {
1355+ this . _gaxModule . routingHeader . fromParams ( {
13431356 name : request . name || '' ,
13441357 } ) ;
13451358 this . initialize ( ) ;
@@ -1439,7 +1452,7 @@ export class DataTransferServiceClient {
14391452 options . otherArgs = options . otherArgs || { } ;
14401453 options . otherArgs . headers = options . otherArgs . headers || { } ;
14411454 options . otherArgs . headers [ 'x-goog-request-params' ] =
1442- gax . routingHeader . fromParams ( {
1455+ this . _gaxModule . routingHeader . fromParams ( {
14431456 name : request . name || '' ,
14441457 } ) ;
14451458 this . initialize ( ) ;
@@ -1545,7 +1558,7 @@ export class DataTransferServiceClient {
15451558 options . otherArgs = options . otherArgs || { } ;
15461559 options . otherArgs . headers = options . otherArgs . headers || { } ;
15471560 options . otherArgs . headers [ 'x-goog-request-params' ] =
1548- gax . routingHeader . fromParams ( {
1561+ this . _gaxModule . routingHeader . fromParams ( {
15491562 name : request . name || '' ,
15501563 } ) ;
15511564 this . initialize ( ) ;
@@ -1650,7 +1663,7 @@ export class DataTransferServiceClient {
16501663 options . otherArgs = options . otherArgs || { } ;
16511664 options . otherArgs . headers = options . otherArgs . headers || { } ;
16521665 options . otherArgs . headers [ 'x-goog-request-params' ] =
1653- gax . routingHeader . fromParams ( {
1666+ this . _gaxModule . routingHeader . fromParams ( {
16541667 parent : request . parent || '' ,
16551668 } ) ;
16561669 this . initialize ( ) ;
@@ -1694,7 +1707,7 @@ export class DataTransferServiceClient {
16941707 options . otherArgs = options . otherArgs || { } ;
16951708 options . otherArgs . headers = options . otherArgs . headers || { } ;
16961709 options . otherArgs . headers [ 'x-goog-request-params' ] =
1697- gax . routingHeader . fromParams ( {
1710+ this . _gaxModule . routingHeader . fromParams ( {
16981711 parent : request . parent || '' ,
16991712 } ) ;
17001713 const defaultCallSettings = this . _defaults [ 'listDataSources' ] ;
@@ -1747,7 +1760,7 @@ export class DataTransferServiceClient {
17471760 options . otherArgs = options . otherArgs || { } ;
17481761 options . otherArgs . headers = options . otherArgs . headers || { } ;
17491762 options . otherArgs . headers [ 'x-goog-request-params' ] =
1750- gax . routingHeader . fromParams ( {
1763+ this . _gaxModule . routingHeader . fromParams ( {
17511764 parent : request . parent || '' ,
17521765 } ) ;
17531766 const defaultCallSettings = this . _defaults [ 'listDataSources' ] ;
@@ -1860,7 +1873,7 @@ export class DataTransferServiceClient {
18601873 options . otherArgs = options . otherArgs || { } ;
18611874 options . otherArgs . headers = options . otherArgs . headers || { } ;
18621875 options . otherArgs . headers [ 'x-goog-request-params' ] =
1863- gax . routingHeader . fromParams ( {
1876+ this . _gaxModule . routingHeader . fromParams ( {
18641877 parent : request . parent || '' ,
18651878 } ) ;
18661879 this . initialize ( ) ;
@@ -1906,7 +1919,7 @@ export class DataTransferServiceClient {
19061919 options . otherArgs = options . otherArgs || { } ;
19071920 options . otherArgs . headers = options . otherArgs . headers || { } ;
19081921 options . otherArgs . headers [ 'x-goog-request-params' ] =
1909- gax . routingHeader . fromParams ( {
1922+ this . _gaxModule . routingHeader . fromParams ( {
19101923 parent : request . parent || '' ,
19111924 } ) ;
19121925 const defaultCallSettings = this . _defaults [ 'listTransferConfigs' ] ;
@@ -1961,7 +1974,7 @@ export class DataTransferServiceClient {
19611974 options . otherArgs = options . otherArgs || { } ;
19621975 options . otherArgs . headers = options . otherArgs . headers || { } ;
19631976 options . otherArgs . headers [ 'x-goog-request-params' ] =
1964- gax . routingHeader . fromParams ( {
1977+ this . _gaxModule . routingHeader . fromParams ( {
19651978 parent : request . parent || '' ,
19661979 } ) ;
19671980 const defaultCallSettings = this . _defaults [ 'listTransferConfigs' ] ;
@@ -2076,7 +2089,7 @@ export class DataTransferServiceClient {
20762089 options . otherArgs = options . otherArgs || { } ;
20772090 options . otherArgs . headers = options . otherArgs . headers || { } ;
20782091 options . otherArgs . headers [ 'x-goog-request-params' ] =
2079- gax . routingHeader . fromParams ( {
2092+ this . _gaxModule . routingHeader . fromParams ( {
20802093 parent : request . parent || '' ,
20812094 } ) ;
20822095 this . initialize ( ) ;
@@ -2125,7 +2138,7 @@ export class DataTransferServiceClient {
21252138 options . otherArgs = options . otherArgs || { } ;
21262139 options . otherArgs . headers = options . otherArgs . headers || { } ;
21272140 options . otherArgs . headers [ 'x-goog-request-params' ] =
2128- gax . routingHeader . fromParams ( {
2141+ this . _gaxModule . routingHeader . fromParams ( {
21292142 parent : request . parent || '' ,
21302143 } ) ;
21312144 const defaultCallSettings = this . _defaults [ 'listTransferRuns' ] ;
@@ -2183,7 +2196,7 @@ export class DataTransferServiceClient {
21832196 options . otherArgs = options . otherArgs || { } ;
21842197 options . otherArgs . headers = options . otherArgs . headers || { } ;
21852198 options . otherArgs . headers [ 'x-goog-request-params' ] =
2186- gax . routingHeader . fromParams ( {
2199+ this . _gaxModule . routingHeader . fromParams ( {
21872200 parent : request . parent || '' ,
21882201 } ) ;
21892202 const defaultCallSettings = this . _defaults [ 'listTransferRuns' ] ;
@@ -2296,7 +2309,7 @@ export class DataTransferServiceClient {
22962309 options . otherArgs = options . otherArgs || { } ;
22972310 options . otherArgs . headers = options . otherArgs . headers || { } ;
22982311 options . otherArgs . headers [ 'x-goog-request-params' ] =
2299- gax . routingHeader . fromParams ( {
2312+ this . _gaxModule . routingHeader . fromParams ( {
23002313 parent : request . parent || '' ,
23012314 } ) ;
23022315 this . initialize ( ) ;
@@ -2343,7 +2356,7 @@ export class DataTransferServiceClient {
23432356 options . otherArgs = options . otherArgs || { } ;
23442357 options . otherArgs . headers = options . otherArgs . headers || { } ;
23452358 options . otherArgs . headers [ 'x-goog-request-params' ] =
2346- gax . routingHeader . fromParams ( {
2359+ this . _gaxModule . routingHeader . fromParams ( {
23472360 parent : request . parent || '' ,
23482361 } ) ;
23492362 const defaultCallSettings = this . _defaults [ 'listTransferLogs' ] ;
@@ -2399,7 +2412,7 @@ export class DataTransferServiceClient {
23992412 options . otherArgs = options . otherArgs || { } ;
24002413 options . otherArgs . headers = options . otherArgs . headers || { } ;
24012414 options . otherArgs . headers [ 'x-goog-request-params' ] =
2402- gax . routingHeader . fromParams ( {
2415+ this . _gaxModule . routingHeader . fromParams ( {
24032416 parent : request . parent || '' ,
24042417 } ) ;
24052418 const defaultCallSettings = this . _defaults [ 'listTransferLogs' ] ;
0 commit comments