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 './game_server_clusters_service_client_config.json' ;
41- import { operationsProtos } from 'google-gax' ;
4240const version = require ( '../../../package.json' ) . version ;
4341
4442/**
@@ -100,8 +98,18 @@ export class GameServerClustersServiceClient {
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 GameServerClustersServiceClient({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
107115 . constructor as typeof GameServerClustersServiceClient ;
@@ -122,8 +130,13 @@ export class GameServerClustersServiceClient {
122130 opts [ 'scopes' ] = staticMembers . scopes ;
123131 }
124132
133+ // Load google-gax module synchronously if needed
134+ if ( ! gaxInstance ) {
135+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
136+ }
137+
125138 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
126- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
139+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
127140
128141 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
129142 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -313,7 +326,7 @@ export class GameServerClustersServiceClient {
313326 this . innerApiCalls = { } ;
314327
315328 // Add a warn function to the client constructor so it can be easily tested.
316- this . warn = gax . warn ;
329+ this . warn = this . _gaxModule . warn ;
317330 }
318331
319332 /**
@@ -537,7 +550,7 @@ export class GameServerClustersServiceClient {
537550 options . otherArgs = options . otherArgs || { } ;
538551 options . otherArgs . headers = options . otherArgs . headers || { } ;
539552 options . otherArgs . headers [ 'x-goog-request-params' ] =
540- gax . routingHeader . fromParams ( {
553+ this . _gaxModule . routingHeader . fromParams ( {
541554 name : request . name || '' ,
542555 } ) ;
543556 this . initialize ( ) ;
@@ -645,7 +658,7 @@ export class GameServerClustersServiceClient {
645658 options . otherArgs = options . otherArgs || { } ;
646659 options . otherArgs . headers = options . otherArgs . headers || { } ;
647660 options . otherArgs . headers [ 'x-goog-request-params' ] =
648- gax . routingHeader . fromParams ( {
661+ this . _gaxModule . routingHeader . fromParams ( {
649662 parent : request . parent || '' ,
650663 } ) ;
651664 this . initialize ( ) ;
@@ -749,7 +762,7 @@ export class GameServerClustersServiceClient {
749762 options . otherArgs = options . otherArgs || { } ;
750763 options . otherArgs . headers = options . otherArgs . headers || { } ;
751764 options . otherArgs . headers [ 'x-goog-request-params' ] =
752- gax . routingHeader . fromParams ( {
765+ this . _gaxModule . routingHeader . fromParams ( {
753766 name : request . name || '' ,
754767 } ) ;
755768 this . initialize ( ) ;
@@ -857,7 +870,7 @@ export class GameServerClustersServiceClient {
857870 options . otherArgs = options . otherArgs || { } ;
858871 options . otherArgs . headers = options . otherArgs . headers || { } ;
859872 options . otherArgs . headers [ 'x-goog-request-params' ] =
860- gax . routingHeader . fromParams ( {
873+ this . _gaxModule . routingHeader . fromParams ( {
861874 'game_server_cluster.name' : request . gameServerCluster ! . name || '' ,
862875 } ) ;
863876 this . initialize ( ) ;
@@ -970,7 +983,7 @@ export class GameServerClustersServiceClient {
970983 options . otherArgs = options . otherArgs || { } ;
971984 options . otherArgs . headers = options . otherArgs . headers || { } ;
972985 options . otherArgs . headers [ 'x-goog-request-params' ] =
973- gax . routingHeader . fromParams ( {
986+ this . _gaxModule . routingHeader . fromParams ( {
974987 parent : request . parent || '' ,
975988 } ) ;
976989 this . initialize ( ) ;
@@ -1000,11 +1013,12 @@ export class GameServerClustersServiceClient {
10001013 protos . google . cloud . gaming . v1 . OperationMetadata
10011014 >
10021015 > {
1003- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1004- { name}
1005- ) ;
1016+ const request =
1017+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1018+ { name}
1019+ ) ;
10061020 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1007- const decodeOperation = new gax . Operation (
1021+ const decodeOperation = new this . _gaxModule . Operation (
10081022 operation ,
10091023 this . descriptors . longrunning . createGameServerCluster ,
10101024 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1112,7 +1126,7 @@ export class GameServerClustersServiceClient {
11121126 options . otherArgs = options . otherArgs || { } ;
11131127 options . otherArgs . headers = options . otherArgs . headers || { } ;
11141128 options . otherArgs . headers [ 'x-goog-request-params' ] =
1115- gax . routingHeader . fromParams ( {
1129+ this . _gaxModule . routingHeader . fromParams ( {
11161130 name : request . name || '' ,
11171131 } ) ;
11181132 this . initialize ( ) ;
@@ -1142,11 +1156,12 @@ export class GameServerClustersServiceClient {
11421156 protos . google . cloud . gaming . v1 . OperationMetadata
11431157 >
11441158 > {
1145- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1146- { name}
1147- ) ;
1159+ const request =
1160+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1161+ { name}
1162+ ) ;
11481163 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1149- const decodeOperation = new gax . Operation (
1164+ const decodeOperation = new this . _gaxModule . Operation (
11501165 operation ,
11511166 this . descriptors . longrunning . deleteGameServerCluster ,
11521167 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1258,7 +1273,7 @@ export class GameServerClustersServiceClient {
12581273 options . otherArgs = options . otherArgs || { } ;
12591274 options . otherArgs . headers = options . otherArgs . headers || { } ;
12601275 options . otherArgs . headers [ 'x-goog-request-params' ] =
1261- gax . routingHeader . fromParams ( {
1276+ this . _gaxModule . routingHeader . fromParams ( {
12621277 'game_server_cluster.name' : request . gameServerCluster ! . name || '' ,
12631278 } ) ;
12641279 this . initialize ( ) ;
@@ -1288,11 +1303,12 @@ export class GameServerClustersServiceClient {
12881303 protos . google . cloud . gaming . v1 . OperationMetadata
12891304 >
12901305 > {
1291- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1292- { name}
1293- ) ;
1306+ const request =
1307+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1308+ { name}
1309+ ) ;
12941310 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1295- const decodeOperation = new gax . Operation (
1311+ const decodeOperation = new this . _gaxModule . Operation (
12961312 operation ,
12971313 this . descriptors . longrunning . updateGameServerCluster ,
12981314 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1411,7 +1427,7 @@ export class GameServerClustersServiceClient {
14111427 options . otherArgs = options . otherArgs || { } ;
14121428 options . otherArgs . headers = options . otherArgs . headers || { } ;
14131429 options . otherArgs . headers [ 'x-goog-request-params' ] =
1414- gax . routingHeader . fromParams ( {
1430+ this . _gaxModule . routingHeader . fromParams ( {
14151431 parent : request . parent || '' ,
14161432 } ) ;
14171433 this . initialize ( ) ;
@@ -1470,7 +1486,7 @@ export class GameServerClustersServiceClient {
14701486 options . otherArgs = options . otherArgs || { } ;
14711487 options . otherArgs . headers = options . otherArgs . headers || { } ;
14721488 options . otherArgs . headers [ 'x-goog-request-params' ] =
1473- gax . routingHeader . fromParams ( {
1489+ this . _gaxModule . routingHeader . fromParams ( {
14741490 parent : request . parent || '' ,
14751491 } ) ;
14761492 const defaultCallSettings = this . _defaults [ 'listGameServerClusters' ] ;
@@ -1534,7 +1550,7 @@ export class GameServerClustersServiceClient {
15341550 options . otherArgs = options . otherArgs || { } ;
15351551 options . otherArgs . headers = options . otherArgs . headers || { } ;
15361552 options . otherArgs . headers [ 'x-goog-request-params' ] =
1537- gax . routingHeader . fromParams ( {
1553+ this . _gaxModule . routingHeader . fromParams ( {
15381554 parent : request . parent || '' ,
15391555 } ) ;
15401556 const defaultCallSettings = this . _defaults [ 'listGameServerClusters' ] ;
0 commit comments