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 ,
@@ -28,7 +28,6 @@ import {
2828 PaginationCallback ,
2929 GaxCall ,
3030} from 'google-gax' ;
31-
3231import { Transform } from 'stream' ;
3332import * as protos from '../../protos/protos' ;
3433import jsonProtos = require( '../../protos/protos.json' ) ;
@@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json');
3837 * This file defines retry strategy and timeouts for all API methods in this library.
3938 */
4039import * as gapicConfig from './aws_clusters_client_config.json' ;
41- import { operationsProtos } from 'google-gax' ;
4240const version = require ( '../../../package.json' ) . version ;
4341
4442/**
@@ -100,8 +98,18 @@ export class AwsClustersClient {
10098 * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
10199 * For more information, please check the
102100 * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
101+ * @param {gax } [gaxInstance]: loaded instance of `google-gax`. Useful if you
102+ * need to avoid loading the default gRPC version and want to use the fallback
103+ * HTTP implementation. Load only fallback version and pass it to the constructor:
104+ * ```
105+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
106+ * const client = new AwsClustersClient({fallback: 'rest'}, gax);
107+ * ```
103108 */
104- constructor ( opts ?: ClientOptions ) {
109+ constructor (
110+ opts ?: ClientOptions ,
111+ gaxInstance ?: typeof gax | typeof gax . fallback
112+ ) {
105113 // Ensure that options include all the required fields.
106114 const staticMembers = this . constructor as typeof AwsClustersClient ;
107115 const servicePath =
@@ -121,8 +129,13 @@ export class AwsClustersClient {
121129 opts [ 'scopes' ] = staticMembers . scopes ;
122130 }
123131
132+ // Load google-gax module synchronously if needed
133+ if ( ! gaxInstance ) {
134+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
135+ }
136+
124137 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
125- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
138+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
126139
127140 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
128141 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -328,7 +341,7 @@ export class AwsClustersClient {
328341 this . innerApiCalls = { } ;
329342
330343 // Add a warn function to the client constructor so it can be easily tested.
331- this . warn = gax . warn ;
344+ this . warn = this . _gaxModule . warn ;
332345 }
333346
334347 /**
@@ -553,7 +566,7 @@ export class AwsClustersClient {
553566 options . otherArgs = options . otherArgs || { } ;
554567 options . otherArgs . headers = options . otherArgs . headers || { } ;
555568 options . otherArgs . headers [ 'x-goog-request-params' ] =
556- gax . routingHeader . fromParams ( {
569+ this . _gaxModule . routingHeader . fromParams ( {
557570 name : request . name || '' ,
558571 } ) ;
559572 this . initialize ( ) ;
@@ -657,7 +670,7 @@ export class AwsClustersClient {
657670 options . otherArgs = options . otherArgs || { } ;
658671 options . otherArgs . headers = options . otherArgs . headers || { } ;
659672 options . otherArgs . headers [ 'x-goog-request-params' ] =
660- gax . routingHeader . fromParams ( {
673+ this . _gaxModule . routingHeader . fromParams ( {
661674 aws_cluster : request . awsCluster || '' ,
662675 } ) ;
663676 this . initialize ( ) ;
@@ -758,7 +771,7 @@ export class AwsClustersClient {
758771 options . otherArgs = options . otherArgs || { } ;
759772 options . otherArgs . headers = options . otherArgs . headers || { } ;
760773 options . otherArgs . headers [ 'x-goog-request-params' ] =
761- gax . routingHeader . fromParams ( {
774+ this . _gaxModule . routingHeader . fromParams ( {
762775 name : request . name || '' ,
763776 } ) ;
764777 this . initialize ( ) ;
@@ -862,7 +875,7 @@ export class AwsClustersClient {
862875 options . otherArgs = options . otherArgs || { } ;
863876 options . otherArgs . headers = options . otherArgs . headers || { } ;
864877 options . otherArgs . headers [ 'x-goog-request-params' ] =
865- gax . routingHeader . fromParams ( {
878+ this . _gaxModule . routingHeader . fromParams ( {
866879 name : request . name || '' ,
867880 } ) ;
868881 this . initialize ( ) ;
@@ -989,7 +1002,7 @@ export class AwsClustersClient {
9891002 options . otherArgs = options . otherArgs || { } ;
9901003 options . otherArgs . headers = options . otherArgs . headers || { } ;
9911004 options . otherArgs . headers [ 'x-goog-request-params' ] =
992- gax . routingHeader . fromParams ( {
1005+ this . _gaxModule . routingHeader . fromParams ( {
9931006 parent : request . parent || '' ,
9941007 } ) ;
9951008 this . initialize ( ) ;
@@ -1015,11 +1028,12 @@ export class AwsClustersClient {
10151028 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
10161029 >
10171030 > {
1018- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1019- { name}
1020- ) ;
1031+ const request =
1032+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1033+ { name}
1034+ ) ;
10211035 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1022- const decodeOperation = new gax . Operation (
1036+ const decodeOperation = new this . _gaxModule . Operation (
10231037 operation ,
10241038 this . descriptors . longrunning . createAwsCluster ,
10251039 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1153,7 +1167,7 @@ export class AwsClustersClient {
11531167 options . otherArgs = options . otherArgs || { } ;
11541168 options . otherArgs . headers = options . otherArgs . headers || { } ;
11551169 options . otherArgs . headers [ 'x-goog-request-params' ] =
1156- gax . routingHeader . fromParams ( {
1170+ this . _gaxModule . routingHeader . fromParams ( {
11571171 'aws_cluster.name' : request . awsCluster ! . name || '' ,
11581172 } ) ;
11591173 this . initialize ( ) ;
@@ -1179,11 +1193,12 @@ export class AwsClustersClient {
11791193 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
11801194 >
11811195 > {
1182- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1183- { name}
1184- ) ;
1196+ const request =
1197+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1198+ { name}
1199+ ) ;
11851200 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1186- const decodeOperation = new gax . Operation (
1201+ const decodeOperation = new this . _gaxModule . Operation (
11871202 operation ,
11881203 this . descriptors . longrunning . updateAwsCluster ,
11891204 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1318,7 +1333,7 @@ export class AwsClustersClient {
13181333 options . otherArgs = options . otherArgs || { } ;
13191334 options . otherArgs . headers = options . otherArgs . headers || { } ;
13201335 options . otherArgs . headers [ 'x-goog-request-params' ] =
1321- gax . routingHeader . fromParams ( {
1336+ this . _gaxModule . routingHeader . fromParams ( {
13221337 name : request . name || '' ,
13231338 } ) ;
13241339 this . initialize ( ) ;
@@ -1344,11 +1359,12 @@ export class AwsClustersClient {
13441359 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
13451360 >
13461361 > {
1347- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1348- { name}
1349- ) ;
1362+ const request =
1363+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1364+ { name}
1365+ ) ;
13501366 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1351- const decodeOperation = new gax . Operation (
1367+ const decodeOperation = new this . _gaxModule . Operation (
13521368 operation ,
13531369 this . descriptors . longrunning . deleteAwsCluster ,
13541370 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1479,7 +1495,7 @@ export class AwsClustersClient {
14791495 options . otherArgs = options . otherArgs || { } ;
14801496 options . otherArgs . headers = options . otherArgs . headers || { } ;
14811497 options . otherArgs . headers [ 'x-goog-request-params' ] =
1482- gax . routingHeader . fromParams ( {
1498+ this . _gaxModule . routingHeader . fromParams ( {
14831499 parent : request . parent || '' ,
14841500 } ) ;
14851501 this . initialize ( ) ;
@@ -1505,11 +1521,12 @@ export class AwsClustersClient {
15051521 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
15061522 >
15071523 > {
1508- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1509- { name}
1510- ) ;
1524+ const request =
1525+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1526+ { name}
1527+ ) ;
15111528 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1512- const decodeOperation = new gax . Operation (
1529+ const decodeOperation = new this . _gaxModule . Operation (
15131530 operation ,
15141531 this . descriptors . longrunning . createAwsNodePool ,
15151532 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1638,7 +1655,7 @@ export class AwsClustersClient {
16381655 options . otherArgs = options . otherArgs || { } ;
16391656 options . otherArgs . headers = options . otherArgs . headers || { } ;
16401657 options . otherArgs . headers [ 'x-goog-request-params' ] =
1641- gax . routingHeader . fromParams ( {
1658+ this . _gaxModule . routingHeader . fromParams ( {
16421659 'aws_node_pool.name' : request . awsNodePool ! . name || '' ,
16431660 } ) ;
16441661 this . initialize ( ) ;
@@ -1664,11 +1681,12 @@ export class AwsClustersClient {
16641681 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
16651682 >
16661683 > {
1667- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1668- { name}
1669- ) ;
1684+ const request =
1685+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1686+ { name}
1687+ ) ;
16701688 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1671- const decodeOperation = new gax . Operation (
1689+ const decodeOperation = new this . _gaxModule . Operation (
16721690 operation ,
16731691 this . descriptors . longrunning . updateAwsNodePool ,
16741692 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1801,7 +1819,7 @@ export class AwsClustersClient {
18011819 options . otherArgs = options . otherArgs || { } ;
18021820 options . otherArgs . headers = options . otherArgs . headers || { } ;
18031821 options . otherArgs . headers [ 'x-goog-request-params' ] =
1804- gax . routingHeader . fromParams ( {
1822+ this . _gaxModule . routingHeader . fromParams ( {
18051823 name : request . name || '' ,
18061824 } ) ;
18071825 this . initialize ( ) ;
@@ -1827,11 +1845,12 @@ export class AwsClustersClient {
18271845 protos . google . cloud . gkemulticloud . v1 . OperationMetadata
18281846 >
18291847 > {
1830- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1831- { name}
1832- ) ;
1848+ const request =
1849+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1850+ { name}
1851+ ) ;
18331852 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1834- const decodeOperation = new gax . Operation (
1853+ const decodeOperation = new this . _gaxModule . Operation (
18351854 operation ,
18361855 this . descriptors . longrunning . deleteAwsNodePool ,
18371856 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1947,7 +1966,7 @@ export class AwsClustersClient {
19471966 options . otherArgs = options . otherArgs || { } ;
19481967 options . otherArgs . headers = options . otherArgs . headers || { } ;
19491968 options . otherArgs . headers [ 'x-goog-request-params' ] =
1950- gax . routingHeader . fromParams ( {
1969+ this . _gaxModule . routingHeader . fromParams ( {
19511970 parent : request . parent || '' ,
19521971 } ) ;
19531972 this . initialize ( ) ;
@@ -1998,7 +2017,7 @@ export class AwsClustersClient {
19982017 options . otherArgs = options . otherArgs || { } ;
19992018 options . otherArgs . headers = options . otherArgs . headers || { } ;
20002019 options . otherArgs . headers [ 'x-goog-request-params' ] =
2001- gax . routingHeader . fromParams ( {
2020+ this . _gaxModule . routingHeader . fromParams ( {
20022021 parent : request . parent || '' ,
20032022 } ) ;
20042023 const defaultCallSettings = this . _defaults [ 'listAwsClusters' ] ;
@@ -2058,7 +2077,7 @@ export class AwsClustersClient {
20582077 options . otherArgs = options . otherArgs || { } ;
20592078 options . otherArgs . headers = options . otherArgs . headers || { } ;
20602079 options . otherArgs . headers [ 'x-goog-request-params' ] =
2061- gax . routingHeader . fromParams ( {
2080+ this . _gaxModule . routingHeader . fromParams ( {
20622081 parent : request . parent || '' ,
20632082 } ) ;
20642083 const defaultCallSettings = this . _defaults [ 'listAwsClusters' ] ;
@@ -2176,7 +2195,7 @@ export class AwsClustersClient {
21762195 options . otherArgs = options . otherArgs || { } ;
21772196 options . otherArgs . headers = options . otherArgs . headers || { } ;
21782197 options . otherArgs . headers [ 'x-goog-request-params' ] =
2179- gax . routingHeader . fromParams ( {
2198+ this . _gaxModule . routingHeader . fromParams ( {
21802199 parent : request . parent || '' ,
21812200 } ) ;
21822201 this . initialize ( ) ;
@@ -2228,7 +2247,7 @@ export class AwsClustersClient {
22282247 options . otherArgs = options . otherArgs || { } ;
22292248 options . otherArgs . headers = options . otherArgs . headers || { } ;
22302249 options . otherArgs . headers [ 'x-goog-request-params' ] =
2231- gax . routingHeader . fromParams ( {
2250+ this . _gaxModule . routingHeader . fromParams ( {
22322251 parent : request . parent || '' ,
22332252 } ) ;
22342253 const defaultCallSettings = this . _defaults [ 'listAwsNodePools' ] ;
@@ -2289,7 +2308,7 @@ export class AwsClustersClient {
22892308 options . otherArgs = options . otherArgs || { } ;
22902309 options . otherArgs . headers = options . otherArgs . headers || { } ;
22912310 options . otherArgs . headers [ 'x-goog-request-params' ] =
2292- gax . routingHeader . fromParams ( {
2311+ this . _gaxModule . routingHeader . fromParams ( {
22932312 parent : request . parent || '' ,
22942313 } ) ;
22952314 const defaultCallSettings = this . _defaults [ 'listAwsNodePools' ] ;
0 commit comments