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 './asset_service_client_config.json' ;
41- import { operationsProtos } from 'google-gax' ;
4240const version = require ( '../../../package.json' ) . version ;
4341
4442/**
@@ -99,8 +97,18 @@ export class AssetServiceClient {
9997 * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
10098 * For more information, please check the
10199 * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
100+ * @param {gax } [gaxInstance]: loaded instance of `google-gax`. Useful if you
101+ * need to avoid loading the default gRPC version and want to use the fallback
102+ * HTTP implementation. Load only fallback version and pass it to the constructor:
103+ * ```
104+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
105+ * const client = new AssetServiceClient({fallback: 'rest'}, gax);
106+ * ```
102107 */
103- constructor ( opts ?: ClientOptions ) {
108+ constructor (
109+ opts ?: ClientOptions ,
110+ gaxInstance ?: typeof gax | typeof gax . fallback
111+ ) {
104112 // Ensure that options include all the required fields.
105113 const staticMembers = this . constructor as typeof AssetServiceClient ;
106114 const servicePath =
@@ -120,8 +128,13 @@ export class AssetServiceClient {
120128 opts [ 'scopes' ] = staticMembers . scopes ;
121129 }
122130
131+ // Load google-gax module synchronously if needed
132+ if ( ! gaxInstance ) {
133+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
134+ }
135+
123136 // Choose either gRPC or proto-over-HTTP implementation of google-gax.
124- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
137+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
125138
126139 // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
127140 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -290,7 +303,7 @@ export class AssetServiceClient {
290303 this . innerApiCalls = { } ;
291304
292305 // Add a warn function to the client constructor so it can be easily tested.
293- this . warn = gax . warn ;
306+ this . warn = this . _gaxModule . warn ;
294307 }
295308
296309 /**
@@ -560,7 +573,7 @@ export class AssetServiceClient {
560573 options . otherArgs = options . otherArgs || { } ;
561574 options . otherArgs . headers = options . otherArgs . headers || { } ;
562575 options . otherArgs . headers [ 'x-goog-request-params' ] =
563- gax . routingHeader . fromParams ( {
576+ this . _gaxModule . routingHeader . fromParams ( {
564577 parent : request . parent || '' ,
565578 } ) ;
566579 this . initialize ( ) ;
@@ -656,7 +669,7 @@ export class AssetServiceClient {
656669 options . otherArgs = options . otherArgs || { } ;
657670 options . otherArgs . headers = options . otherArgs . headers || { } ;
658671 options . otherArgs . headers [ 'x-goog-request-params' ] =
659- gax . routingHeader . fromParams ( {
672+ this . _gaxModule . routingHeader . fromParams ( {
660673 parent : request . parent || '' ,
661674 } ) ;
662675 this . initialize ( ) ;
@@ -742,7 +755,7 @@ export class AssetServiceClient {
742755 options . otherArgs = options . otherArgs || { } ;
743756 options . otherArgs . headers = options . otherArgs . headers || { } ;
744757 options . otherArgs . headers [ 'x-goog-request-params' ] =
745- gax . routingHeader . fromParams ( {
758+ this . _gaxModule . routingHeader . fromParams ( {
746759 name : request . name || '' ,
747760 } ) ;
748761 this . initialize ( ) ;
@@ -827,7 +840,7 @@ export class AssetServiceClient {
827840 options . otherArgs = options . otherArgs || { } ;
828841 options . otherArgs . headers = options . otherArgs . headers || { } ;
829842 options . otherArgs . headers [ 'x-goog-request-params' ] =
830- gax . routingHeader . fromParams ( {
843+ this . _gaxModule . routingHeader . fromParams ( {
831844 parent : request . parent || '' ,
832845 } ) ;
833846 this . initialize ( ) ;
@@ -918,7 +931,7 @@ export class AssetServiceClient {
918931 options . otherArgs = options . otherArgs || { } ;
919932 options . otherArgs . headers = options . otherArgs . headers || { } ;
920933 options . otherArgs . headers [ 'x-goog-request-params' ] =
921- gax . routingHeader . fromParams ( {
934+ this . _gaxModule . routingHeader . fromParams ( {
922935 'feed.name' : request . feed ! . name || '' ,
923936 } ) ;
924937 this . initialize ( ) ;
@@ -1004,7 +1017,7 @@ export class AssetServiceClient {
10041017 options . otherArgs = options . otherArgs || { } ;
10051018 options . otherArgs . headers = options . otherArgs . headers || { } ;
10061019 options . otherArgs . headers [ 'x-goog-request-params' ] =
1007- gax . routingHeader . fromParams ( {
1020+ this . _gaxModule . routingHeader . fromParams ( {
10081021 name : request . name || '' ,
10091022 } ) ;
10101023 this . initialize ( ) ;
@@ -1119,7 +1132,7 @@ export class AssetServiceClient {
11191132 options . otherArgs = options . otherArgs || { } ;
11201133 options . otherArgs . headers = options . otherArgs . headers || { } ;
11211134 options . otherArgs . headers [ 'x-goog-request-params' ] =
1122- gax . routingHeader . fromParams ( {
1135+ this . _gaxModule . routingHeader . fromParams ( {
11231136 'analysis_query.scope' : request . analysisQuery ! . scope || '' ,
11241137 } ) ;
11251138 this . initialize ( ) ;
@@ -1218,7 +1231,7 @@ export class AssetServiceClient {
12181231 options . otherArgs = options . otherArgs || { } ;
12191232 options . otherArgs . headers = options . otherArgs . headers || { } ;
12201233 options . otherArgs . headers [ 'x-goog-request-params' ] =
1221- gax . routingHeader . fromParams ( {
1234+ this . _gaxModule . routingHeader . fromParams ( {
12221235 resource : request . resource || '' ,
12231236 } ) ;
12241237 this . initialize ( ) ;
@@ -1368,7 +1381,7 @@ export class AssetServiceClient {
13681381 options . otherArgs = options . otherArgs || { } ;
13691382 options . otherArgs . headers = options . otherArgs . headers || { } ;
13701383 options . otherArgs . headers [ 'x-goog-request-params' ] =
1371- gax . routingHeader . fromParams ( {
1384+ this . _gaxModule . routingHeader . fromParams ( {
13721385 parent : request . parent || '' ,
13731386 } ) ;
13741387 this . initialize ( ) ;
@@ -1470,7 +1483,7 @@ export class AssetServiceClient {
14701483 options . otherArgs = options . otherArgs || { } ;
14711484 options . otherArgs . headers = options . otherArgs . headers || { } ;
14721485 options . otherArgs . headers [ 'x-goog-request-params' ] =
1473- gax . routingHeader . fromParams ( {
1486+ this . _gaxModule . routingHeader . fromParams ( {
14741487 parent : request . parent || '' ,
14751488 } ) ;
14761489 this . initialize ( ) ;
@@ -1557,7 +1570,7 @@ export class AssetServiceClient {
15571570 options . otherArgs = options . otherArgs || { } ;
15581571 options . otherArgs . headers = options . otherArgs . headers || { } ;
15591572 options . otherArgs . headers [ 'x-goog-request-params' ] =
1560- gax . routingHeader . fromParams ( {
1573+ this . _gaxModule . routingHeader . fromParams ( {
15611574 name : request . name || '' ,
15621575 } ) ;
15631576 this . initialize ( ) ;
@@ -1651,7 +1664,7 @@ export class AssetServiceClient {
16511664 options . otherArgs = options . otherArgs || { } ;
16521665 options . otherArgs . headers = options . otherArgs . headers || { } ;
16531666 options . otherArgs . headers [ 'x-goog-request-params' ] =
1654- gax . routingHeader . fromParams ( {
1667+ this . _gaxModule . routingHeader . fromParams ( {
16551668 'saved_query.name' : request . savedQuery ! . name || '' ,
16561669 } ) ;
16571670 this . initialize ( ) ;
@@ -1741,7 +1754,7 @@ export class AssetServiceClient {
17411754 options . otherArgs = options . otherArgs || { } ;
17421755 options . otherArgs . headers = options . otherArgs . headers || { } ;
17431756 options . otherArgs . headers [ 'x-goog-request-params' ] =
1744- gax . routingHeader . fromParams ( {
1757+ this . _gaxModule . routingHeader . fromParams ( {
17451758 name : request . name || '' ,
17461759 } ) ;
17471760 this . initialize ( ) ;
@@ -1854,7 +1867,7 @@ export class AssetServiceClient {
18541867 options . otherArgs = options . otherArgs || { } ;
18551868 options . otherArgs . headers = options . otherArgs . headers || { } ;
18561869 options . otherArgs . headers [ 'x-goog-request-params' ] =
1857- gax . routingHeader . fromParams ( {
1870+ this . _gaxModule . routingHeader . fromParams ( {
18581871 scope : request . scope || '' ,
18591872 } ) ;
18601873 this . initialize ( ) ;
@@ -2022,7 +2035,7 @@ export class AssetServiceClient {
20222035 options . otherArgs = options . otherArgs || { } ;
20232036 options . otherArgs . headers = options . otherArgs . headers || { } ;
20242037 options . otherArgs . headers [ 'x-goog-request-params' ] =
2025- gax . routingHeader . fromParams ( {
2038+ this . _gaxModule . routingHeader . fromParams ( {
20262039 parent : request . parent || '' ,
20272040 } ) ;
20282041 this . initialize ( ) ;
@@ -2048,11 +2061,12 @@ export class AssetServiceClient {
20482061 protos . google . cloud . asset . v1 . ExportAssetsRequest
20492062 >
20502063 > {
2051- const request = new operationsProtos . google . longrunning . GetOperationRequest (
2052- { name}
2053- ) ;
2064+ const request =
2065+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
2066+ { name}
2067+ ) ;
20542068 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
2055- const decodeOperation = new gax . Operation (
2069+ const decodeOperation = new this . _gaxModule . Operation (
20562070 operation ,
20572071 this . descriptors . longrunning . exportAssets ,
20582072 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -2188,7 +2202,7 @@ export class AssetServiceClient {
21882202 options . otherArgs = options . otherArgs || { } ;
21892203 options . otherArgs . headers = options . otherArgs . headers || { } ;
21902204 options . otherArgs . headers [ 'x-goog-request-params' ] =
2191- gax . routingHeader . fromParams ( {
2205+ this . _gaxModule . routingHeader . fromParams ( {
21922206 'analysis_query.scope' : request . analysisQuery ! . scope || '' ,
21932207 } ) ;
21942208 this . initialize ( ) ;
@@ -2218,11 +2232,12 @@ export class AssetServiceClient {
22182232 protos . google . cloud . asset . v1 . AnalyzeIamPolicyLongrunningMetadata
22192233 >
22202234 > {
2221- const request = new operationsProtos . google . longrunning . GetOperationRequest (
2222- { name}
2223- ) ;
2235+ const request =
2236+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
2237+ { name}
2238+ ) ;
22242239 const [ operation ] = await this . operationsClient . getOperation ( request ) ;
2225- const decodeOperation = new gax . Operation (
2240+ const decodeOperation = new this . _gaxModule . Operation (
22262241 operation ,
22272242 this . descriptors . longrunning . analyzeIamPolicyLongrunning ,
22282243 this . _gaxModule . createDefaultBackoffSettings ( )
@@ -2368,7 +2383,7 @@ export class AssetServiceClient {
23682383 options . otherArgs = options . otherArgs || { } ;
23692384 options . otherArgs . headers = options . otherArgs . headers || { } ;
23702385 options . otherArgs . headers [ 'x-goog-request-params' ] =
2371- gax . routingHeader . fromParams ( {
2386+ this . _gaxModule . routingHeader . fromParams ( {
23722387 parent : request . parent || '' ,
23732388 } ) ;
23742389 this . initialize ( ) ;
@@ -2457,7 +2472,7 @@ export class AssetServiceClient {
24572472 options . otherArgs = options . otherArgs || { } ;
24582473 options . otherArgs . headers = options . otherArgs . headers || { } ;
24592474 options . otherArgs . headers [ 'x-goog-request-params' ] =
2460- gax . routingHeader . fromParams ( {
2475+ this . _gaxModule . routingHeader . fromParams ( {
24612476 parent : request . parent || '' ,
24622477 } ) ;
24632478 const defaultCallSettings = this . _defaults [ 'listAssets' ] ;
@@ -2555,7 +2570,7 @@ export class AssetServiceClient {
25552570 options . otherArgs = options . otherArgs || { } ;
25562571 options . otherArgs . headers = options . otherArgs . headers || { } ;
25572572 options . otherArgs . headers [ 'x-goog-request-params' ] =
2558- gax . routingHeader . fromParams ( {
2573+ this . _gaxModule . routingHeader . fromParams ( {
25592574 parent : request . parent || '' ,
25602575 } ) ;
25612576 const defaultCallSettings = this . _defaults [ 'listAssets' ] ;
@@ -2799,7 +2814,7 @@ export class AssetServiceClient {
27992814 options . otherArgs = options . otherArgs || { } ;
28002815 options . otherArgs . headers = options . otherArgs . headers || { } ;
28012816 options . otherArgs . headers [ 'x-goog-request-params' ] =
2802- gax . routingHeader . fromParams ( {
2817+ this . _gaxModule . routingHeader . fromParams ( {
28032818 scope : request . scope || '' ,
28042819 } ) ;
28052820 this . initialize ( ) ;
@@ -2974,7 +2989,7 @@ export class AssetServiceClient {
29742989 options . otherArgs = options . otherArgs || { } ;
29752990 options . otherArgs . headers = options . otherArgs . headers || { } ;
29762991 options . otherArgs . headers [ 'x-goog-request-params' ] =
2977- gax . routingHeader . fromParams ( {
2992+ this . _gaxModule . routingHeader . fromParams ( {
29782993 scope : request . scope || '' ,
29792994 } ) ;
29802995 const defaultCallSettings = this . _defaults [ 'searchAllResources' ] ;
@@ -3158,7 +3173,7 @@ export class AssetServiceClient {
31583173 options . otherArgs = options . otherArgs || { } ;
31593174 options . otherArgs . headers = options . otherArgs . headers || { } ;
31603175 options . otherArgs . headers [ 'x-goog-request-params' ] =
3161- gax . routingHeader . fromParams ( {
3176+ this . _gaxModule . routingHeader . fromParams ( {
31623177 scope : request . scope || '' ,
31633178 } ) ;
31643179 const defaultCallSettings = this . _defaults [ 'searchAllResources' ] ;
@@ -3355,7 +3370,7 @@ export class AssetServiceClient {
33553370 options . otherArgs = options . otherArgs || { } ;
33563371 options . otherArgs . headers = options . otherArgs . headers || { } ;
33573372 options . otherArgs . headers [ 'x-goog-request-params' ] =
3358- gax . routingHeader . fromParams ( {
3373+ this . _gaxModule . routingHeader . fromParams ( {
33593374 scope : request . scope || '' ,
33603375 } ) ;
33613376 this . initialize ( ) ;
@@ -3483,7 +3498,7 @@ export class AssetServiceClient {
34833498 options . otherArgs = options . otherArgs || { } ;
34843499 options . otherArgs . headers = options . otherArgs . headers || { } ;
34853500 options . otherArgs . headers [ 'x-goog-request-params' ] =
3486- gax . routingHeader . fromParams ( {
3501+ this . _gaxModule . routingHeader . fromParams ( {
34873502 scope : request . scope || '' ,
34883503 } ) ;
34893504 const defaultCallSettings = this . _defaults [ 'searchAllIamPolicies' ] ;
@@ -3620,7 +3635,7 @@ export class AssetServiceClient {
36203635 options . otherArgs = options . otherArgs || { } ;
36213636 options . otherArgs . headers = options . otherArgs . headers || { } ;
36223637 options . otherArgs . headers [ 'x-goog-request-params' ] =
3623- gax . routingHeader . fromParams ( {
3638+ this . _gaxModule . routingHeader . fromParams ( {
36243639 scope : request . scope || '' ,
36253640 } ) ;
36263641 const defaultCallSettings = this . _defaults [ 'searchAllIamPolicies' ] ;
@@ -3735,7 +3750,7 @@ export class AssetServiceClient {
37353750 options . otherArgs = options . otherArgs || { } ;
37363751 options . otherArgs . headers = options . otherArgs . headers || { } ;
37373752 options . otherArgs . headers [ 'x-goog-request-params' ] =
3738- gax . routingHeader . fromParams ( {
3753+ this . _gaxModule . routingHeader . fromParams ( {
37393754 parent : request . parent || '' ,
37403755 } ) ;
37413756 this . initialize ( ) ;
@@ -3790,7 +3805,7 @@ export class AssetServiceClient {
37903805 options . otherArgs = options . otherArgs || { } ;
37913806 options . otherArgs . headers = options . otherArgs . headers || { } ;
37923807 options . otherArgs . headers [ 'x-goog-request-params' ] =
3793- gax . routingHeader . fromParams ( {
3808+ this . _gaxModule . routingHeader . fromParams ( {
37943809 parent : request . parent || '' ,
37953810 } ) ;
37963811 const defaultCallSettings = this . _defaults [ 'listSavedQueries' ] ;
@@ -3854,7 +3869,7 @@ export class AssetServiceClient {
38543869 options . otherArgs = options . otherArgs || { } ;
38553870 options . otherArgs . headers = options . otherArgs . headers || { } ;
38563871 options . otherArgs . headers [ 'x-goog-request-params' ] =
3857- gax . routingHeader . fromParams ( {
3872+ this . _gaxModule . routingHeader . fromParams ( {
38583873 parent : request . parent || '' ,
38593874 } ) ;
38603875 const defaultCallSettings = this . _defaults [ 'listSavedQueries' ] ;
0 commit comments