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 './secret_manager_service_client_config.json' ;
39-
4038const version = require ( '../../../package.json' ) . version ;
4139
4240/**
@@ -102,8 +100,18 @@ export class SecretManagerServiceClient {
102100 * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
103101 * For more information, please check the
104102 * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
103+ * @param {gax } [gaxInstance]: loaded instance of `google-gax`. Useful if you
104+ * need to avoid loading the default gRPC version and want to use the fallback
105+ * HTTP implementation. Load only fallback version and pass it to the constructor:
106+ * ```
107+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
108+ * const client = new SecretManagerServiceClient({fallback: 'rest'}, gax);
109+ * ```
105110 */
106- constructor ( opts ?: ClientOptions ) {
111+ constructor (
112+ opts ?: ClientOptions ,
113+ gaxInstance ?: typeof gax | typeof gax . fallback
114+ ) {
107115 // Ensure that options include all the required fields.
108116 const staticMembers = this . constructor as typeof SecretManagerServiceClient ;
109117 const servicePath =
@@ -123,8 +131,13 @@ export class SecretManagerServiceClient {
123131 opts [ 'scopes' ] = staticMembers . scopes ;
124132 }
125133
134+ // Load google-gax module synchronously if needed
135+ if ( ! gaxInstance ) {
136+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
137+ }
138+
126139 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
127- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
140+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
128141
129142 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
130143 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -212,7 +225,7 @@ export class SecretManagerServiceClient {
212225 this . innerApiCalls = { } ;
213226
214227 // Add a warn function to the client constructor so it can be easily tested.
215- this . warn = gax . warn ;
228+ this . warn = this . _gaxModule . warn ;
216229 }
217230
218231 /**
@@ -441,7 +454,7 @@ export class SecretManagerServiceClient {
441454 options . otherArgs = options . otherArgs || { } ;
442455 options . otherArgs . headers = options . otherArgs . headers || { } ;
443456 options . otherArgs . headers [ 'x-goog-request-params' ] =
444- gax . routingHeader . fromParams ( {
457+ this . _gaxModule . routingHeader . fromParams ( {
445458 parent : request . parent || '' ,
446459 } ) ;
447460 this . initialize ( ) ;
@@ -536,7 +549,7 @@ export class SecretManagerServiceClient {
536549 options . otherArgs = options . otherArgs || { } ;
537550 options . otherArgs . headers = options . otherArgs . headers || { } ;
538551 options . otherArgs . headers [ 'x-goog-request-params' ] =
539- gax . routingHeader . fromParams ( {
552+ this . _gaxModule . routingHeader . fromParams ( {
540553 parent : request . parent || '' ,
541554 } ) ;
542555 this . initialize ( ) ;
@@ -621,7 +634,7 @@ export class SecretManagerServiceClient {
621634 options . otherArgs = options . otherArgs || { } ;
622635 options . otherArgs . headers = options . otherArgs . headers || { } ;
623636 options . otherArgs . headers [ 'x-goog-request-params' ] =
624- gax . routingHeader . fromParams ( {
637+ this . _gaxModule . routingHeader . fromParams ( {
625638 name : request . name || '' ,
626639 } ) ;
627640 this . initialize ( ) ;
@@ -714,7 +727,7 @@ export class SecretManagerServiceClient {
714727 options . otherArgs = options . otherArgs || { } ;
715728 options . otherArgs . headers = options . otherArgs . headers || { } ;
716729 options . otherArgs . headers [ 'x-goog-request-params' ] =
717- gax . routingHeader . fromParams ( {
730+ this . _gaxModule . routingHeader . fromParams ( {
718731 'secret.name' : request . secret ! . name || '' ,
719732 } ) ;
720733 this . initialize ( ) ;
@@ -810,7 +823,7 @@ export class SecretManagerServiceClient {
810823 options . otherArgs = options . otherArgs || { } ;
811824 options . otherArgs . headers = options . otherArgs . headers || { } ;
812825 options . otherArgs . headers [ 'x-goog-request-params' ] =
813- gax . routingHeader . fromParams ( {
826+ this . _gaxModule . routingHeader . fromParams ( {
814827 name : request . name || '' ,
815828 } ) ;
816829 this . initialize ( ) ;
@@ -908,7 +921,7 @@ export class SecretManagerServiceClient {
908921 options . otherArgs = options . otherArgs || { } ;
909922 options . otherArgs . headers = options . otherArgs . headers || { } ;
910923 options . otherArgs . headers [ 'x-goog-request-params' ] =
911- gax . routingHeader . fromParams ( {
924+ this . _gaxModule . routingHeader . fromParams ( {
912925 name : request . name || '' ,
913926 } ) ;
914927 this . initialize ( ) ;
@@ -1012,7 +1025,7 @@ export class SecretManagerServiceClient {
10121025 options . otherArgs = options . otherArgs || { } ;
10131026 options . otherArgs . headers = options . otherArgs . headers || { } ;
10141027 options . otherArgs . headers [ 'x-goog-request-params' ] =
1015- gax . routingHeader . fromParams ( {
1028+ this . _gaxModule . routingHeader . fromParams ( {
10161029 name : request . name || '' ,
10171030 } ) ;
10181031 this . initialize ( ) ;
@@ -1117,7 +1130,7 @@ export class SecretManagerServiceClient {
11171130 options . otherArgs = options . otherArgs || { } ;
11181131 options . otherArgs . headers = options . otherArgs . headers || { } ;
11191132 options . otherArgs . headers [ 'x-goog-request-params' ] =
1120- gax . routingHeader . fromParams ( {
1133+ this . _gaxModule . routingHeader . fromParams ( {
11211134 name : request . name || '' ,
11221135 } ) ;
11231136 this . initialize ( ) ;
@@ -1222,7 +1235,7 @@ export class SecretManagerServiceClient {
12221235 options . otherArgs = options . otherArgs || { } ;
12231236 options . otherArgs . headers = options . otherArgs . headers || { } ;
12241237 options . otherArgs . headers [ 'x-goog-request-params' ] =
1225- gax . routingHeader . fromParams ( {
1238+ this . _gaxModule . routingHeader . fromParams ( {
12261239 name : request . name || '' ,
12271240 } ) ;
12281241 this . initialize ( ) ;
@@ -1328,7 +1341,7 @@ export class SecretManagerServiceClient {
13281341 options . otherArgs = options . otherArgs || { } ;
13291342 options . otherArgs . headers = options . otherArgs . headers || { } ;
13301343 options . otherArgs . headers [ 'x-goog-request-params' ] =
1331- gax . routingHeader . fromParams ( {
1344+ this . _gaxModule . routingHeader . fromParams ( {
13321345 name : request . name || '' ,
13331346 } ) ;
13341347 this . initialize ( ) ;
@@ -1427,7 +1440,7 @@ export class SecretManagerServiceClient {
14271440 options . otherArgs = options . otherArgs || { } ;
14281441 options . otherArgs . headers = options . otherArgs . headers || { } ;
14291442 options . otherArgs . headers [ 'x-goog-request-params' ] =
1430- gax . routingHeader . fromParams ( {
1443+ this . _gaxModule . routingHeader . fromParams ( {
14311444 resource : request . resource || '' ,
14321445 } ) ;
14331446 this . initialize ( ) ;
@@ -1515,7 +1528,7 @@ export class SecretManagerServiceClient {
15151528 options . otherArgs = options . otherArgs || { } ;
15161529 options . otherArgs . headers = options . otherArgs . headers || { } ;
15171530 options . otherArgs . headers [ 'x-goog-request-params' ] =
1518- gax . routingHeader . fromParams ( {
1531+ this . _gaxModule . routingHeader . fromParams ( {
15191532 resource : request . resource || '' ,
15201533 } ) ;
15211534 this . initialize ( ) ;
@@ -1610,7 +1623,7 @@ export class SecretManagerServiceClient {
16101623 options . otherArgs = options . otherArgs || { } ;
16111624 options . otherArgs . headers = options . otherArgs . headers || { } ;
16121625 options . otherArgs . headers [ 'x-goog-request-params' ] =
1613- gax . routingHeader . fromParams ( {
1626+ this . _gaxModule . routingHeader . fromParams ( {
16141627 resource : request . resource || '' ,
16151628 } ) ;
16161629 this . initialize ( ) ;
@@ -1719,7 +1732,7 @@ export class SecretManagerServiceClient {
17191732 options . otherArgs = options . otherArgs || { } ;
17201733 options . otherArgs . headers = options . otherArgs . headers || { } ;
17211734 options . otherArgs . headers [ 'x-goog-request-params' ] =
1722- gax . routingHeader . fromParams ( {
1735+ this . _gaxModule . routingHeader . fromParams ( {
17231736 parent : request . parent || '' ,
17241737 } ) ;
17251738 this . initialize ( ) ;
@@ -1767,7 +1780,7 @@ export class SecretManagerServiceClient {
17671780 options . otherArgs = options . otherArgs || { } ;
17681781 options . otherArgs . headers = options . otherArgs . headers || { } ;
17691782 options . otherArgs . headers [ 'x-goog-request-params' ] =
1770- gax . routingHeader . fromParams ( {
1783+ this . _gaxModule . routingHeader . fromParams ( {
17711784 parent : request . parent || '' ,
17721785 } ) ;
17731786 const defaultCallSettings = this . _defaults [ 'listSecrets' ] ;
@@ -1824,7 +1837,7 @@ export class SecretManagerServiceClient {
18241837 options . otherArgs = options . otherArgs || { } ;
18251838 options . otherArgs . headers = options . otherArgs . headers || { } ;
18261839 options . otherArgs . headers [ 'x-goog-request-params' ] =
1827- gax . routingHeader . fromParams ( {
1840+ this . _gaxModule . routingHeader . fromParams ( {
18281841 parent : request . parent || '' ,
18291842 } ) ;
18301843 const defaultCallSettings = this . _defaults [ 'listSecrets' ] ;
@@ -1940,7 +1953,7 @@ export class SecretManagerServiceClient {
19401953 options . otherArgs = options . otherArgs || { } ;
19411954 options . otherArgs . headers = options . otherArgs . headers || { } ;
19421955 options . otherArgs . headers [ 'x-goog-request-params' ] =
1943- gax . routingHeader . fromParams ( {
1956+ this . _gaxModule . routingHeader . fromParams ( {
19441957 parent : request . parent || '' ,
19451958 } ) ;
19461959 this . initialize ( ) ;
@@ -1989,7 +2002,7 @@ export class SecretManagerServiceClient {
19892002 options . otherArgs = options . otherArgs || { } ;
19902003 options . otherArgs . headers = options . otherArgs . headers || { } ;
19912004 options . otherArgs . headers [ 'x-goog-request-params' ] =
1992- gax . routingHeader . fromParams ( {
2005+ this . _gaxModule . routingHeader . fromParams ( {
19932006 parent : request . parent || '' ,
19942007 } ) ;
19952008 const defaultCallSettings = this . _defaults [ 'listSecretVersions' ] ;
@@ -2047,7 +2060,7 @@ export class SecretManagerServiceClient {
20472060 options . otherArgs = options . otherArgs || { } ;
20482061 options . otherArgs . headers = options . otherArgs . headers || { } ;
20492062 options . otherArgs . headers [ 'x-goog-request-params' ] =
2050- gax . routingHeader . fromParams ( {
2063+ this . _gaxModule . routingHeader . fromParams ( {
20512064 parent : request . parent || '' ,
20522065 } ) ;
20532066 const defaultCallSettings = this . _defaults [ 'listSecretVersions' ] ;
0 commit comments