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 './identity_aware_proxy_admin_service_client_config.json' ;
39-
4038const version = require ( '../../../package.json' ) . version ;
4139
4240/**
@@ -96,8 +94,18 @@ export class IdentityAwareProxyAdminServiceClient {
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 IdentityAwareProxyAdminServiceClient({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
103111 . constructor as typeof IdentityAwareProxyAdminServiceClient ;
@@ -118,8 +126,13 @@ export class IdentityAwareProxyAdminServiceClient {
118126 opts [ 'scopes' ] = staticMembers . scopes ;
119127 }
120128
129+ // Load google-gax module synchronously if needed
130+ if ( ! gaxInstance ) {
131+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
132+ }
133+
121134 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
122- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
135+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
123136
124137 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
125138 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -199,7 +212,7 @@ export class IdentityAwareProxyAdminServiceClient {
199212 this . innerApiCalls = { } ;
200213
201214 // Add a warn function to the client constructor so it can be easily tested.
202- this . warn = gax . warn ;
215+ this . warn = this . _gaxModule . warn ;
203216 }
204217
205218 /**
@@ -421,7 +434,7 @@ export class IdentityAwareProxyAdminServiceClient {
421434 options . otherArgs = options . otherArgs || { } ;
422435 options . otherArgs . headers = options . otherArgs . headers || { } ;
423436 options . otherArgs . headers [ 'x-goog-request-params' ] =
424- gax . routingHeader . fromParams ( {
437+ this . _gaxModule . routingHeader . fromParams ( {
425438 resource : request . resource || '' ,
426439 } ) ;
427440 this . initialize ( ) ;
@@ -511,7 +524,7 @@ export class IdentityAwareProxyAdminServiceClient {
511524 options . otherArgs = options . otherArgs || { } ;
512525 options . otherArgs . headers = options . otherArgs . headers || { } ;
513526 options . otherArgs . headers [ 'x-goog-request-params' ] =
514- gax . routingHeader . fromParams ( {
527+ this . _gaxModule . routingHeader . fromParams ( {
515528 resource : request . resource || '' ,
516529 } ) ;
517530 this . initialize ( ) ;
@@ -603,7 +616,7 @@ export class IdentityAwareProxyAdminServiceClient {
603616 options . otherArgs = options . otherArgs || { } ;
604617 options . otherArgs . headers = options . otherArgs . headers || { } ;
605618 options . otherArgs . headers [ 'x-goog-request-params' ] =
606- gax . routingHeader . fromParams ( {
619+ this . _gaxModule . routingHeader . fromParams ( {
607620 resource : request . resource || '' ,
608621 } ) ;
609622 this . initialize ( ) ;
@@ -688,7 +701,7 @@ export class IdentityAwareProxyAdminServiceClient {
688701 options . otherArgs = options . otherArgs || { } ;
689702 options . otherArgs . headers = options . otherArgs . headers || { } ;
690703 options . otherArgs . headers [ 'x-goog-request-params' ] =
691- gax . routingHeader . fromParams ( {
704+ this . _gaxModule . routingHeader . fromParams ( {
692705 name : request . name || '' ,
693706 } ) ;
694707 this . initialize ( ) ;
@@ -780,7 +793,7 @@ export class IdentityAwareProxyAdminServiceClient {
780793 options . otherArgs = options . otherArgs || { } ;
781794 options . otherArgs . headers = options . otherArgs . headers || { } ;
782795 options . otherArgs . headers [ 'x-goog-request-params' ] =
783- gax . routingHeader . fromParams ( {
796+ this . _gaxModule . routingHeader . fromParams ( {
784797 'iap_settings.name' : request . iapSettings ! . name || '' ,
785798 } ) ;
786799 this . initialize ( ) ;
@@ -881,7 +894,7 @@ export class IdentityAwareProxyAdminServiceClient {
881894 options . otherArgs = options . otherArgs || { } ;
882895 options . otherArgs . headers = options . otherArgs . headers || { } ;
883896 options . otherArgs . headers [ 'x-goog-request-params' ] =
884- gax . routingHeader . fromParams ( {
897+ this . _gaxModule . routingHeader . fromParams ( {
885898 parent : request . parent || '' ,
886899 } ) ;
887900 this . initialize ( ) ;
@@ -968,7 +981,7 @@ export class IdentityAwareProxyAdminServiceClient {
968981 options . otherArgs = options . otherArgs || { } ;
969982 options . otherArgs . headers = options . otherArgs . headers || { } ;
970983 options . otherArgs . headers [ 'x-goog-request-params' ] =
971- gax . routingHeader . fromParams ( {
984+ this . _gaxModule . routingHeader . fromParams ( {
972985 name : request . name || '' ,
973986 } ) ;
974987 this . initialize ( ) ;
@@ -1061,7 +1074,7 @@ export class IdentityAwareProxyAdminServiceClient {
10611074 options . otherArgs = options . otherArgs || { } ;
10621075 options . otherArgs . headers = options . otherArgs . headers || { } ;
10631076 options . otherArgs . headers [ 'x-goog-request-params' ] =
1064- gax . routingHeader . fromParams ( {
1077+ this . _gaxModule . routingHeader . fromParams ( {
10651078 name : request . name || '' ,
10661079 } ) ;
10671080 this . initialize ( ) ;
@@ -1156,7 +1169,7 @@ export class IdentityAwareProxyAdminServiceClient {
11561169 options . otherArgs = options . otherArgs || { } ;
11571170 options . otherArgs . headers = options . otherArgs . headers || { } ;
11581171 options . otherArgs . headers [ 'x-goog-request-params' ] =
1159- gax . routingHeader . fromParams ( {
1172+ this . _gaxModule . routingHeader . fromParams ( {
11601173 'tunnel_dest_group.name' : request . tunnelDestGroup ! . name || '' ,
11611174 } ) ;
11621175 this . initialize ( ) ;
@@ -1268,7 +1281,7 @@ export class IdentityAwareProxyAdminServiceClient {
12681281 options . otherArgs = options . otherArgs || { } ;
12691282 options . otherArgs . headers = options . otherArgs . headers || { } ;
12701283 options . otherArgs . headers [ 'x-goog-request-params' ] =
1271- gax . routingHeader . fromParams ( {
1284+ this . _gaxModule . routingHeader . fromParams ( {
12721285 parent : request . parent || '' ,
12731286 } ) ;
12741287 this . initialize ( ) ;
@@ -1317,7 +1330,7 @@ export class IdentityAwareProxyAdminServiceClient {
13171330 options . otherArgs = options . otherArgs || { } ;
13181331 options . otherArgs . headers = options . otherArgs . headers || { } ;
13191332 options . otherArgs . headers [ 'x-goog-request-params' ] =
1320- gax . routingHeader . fromParams ( {
1333+ this . _gaxModule . routingHeader . fromParams ( {
13211334 parent : request . parent || '' ,
13221335 } ) ;
13231336 const defaultCallSettings = this . _defaults [ 'listTunnelDestGroups' ] ;
@@ -1375,7 +1388,7 @@ export class IdentityAwareProxyAdminServiceClient {
13751388 options . otherArgs = options . otherArgs || { } ;
13761389 options . otherArgs . headers = options . otherArgs . headers || { } ;
13771390 options . otherArgs . headers [ 'x-goog-request-params' ] =
1378- gax . routingHeader . fromParams ( {
1391+ this . _gaxModule . routingHeader . fromParams ( {
13791392 parent : request . parent || '' ,
13801393 } ) ;
13811394 const defaultCallSettings = this . _defaults [ 'listTunnelDestGroups' ] ;
0 commit comments