17
17
// ** All changes to this file may be overwritten. **
18
18
19
19
/* global window */
20
- import * as gax from 'google-gax' ;
21
- import {
20
+ import type * as gax from 'google-gax' ;
21
+ import type {
22
22
Callback ,
23
23
CallOptions ,
24
24
Descriptors ,
@@ -28,7 +28,6 @@ import {
28
28
PaginationCallback ,
29
29
GaxCall ,
30
30
} from 'google-gax' ;
31
-
32
31
import { Transform } from 'stream' ;
33
32
import * as protos from '../../protos/protos' ;
34
33
import jsonProtos = require( '../../protos/protos.json' ) ;
@@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json');
38
37
* This file defines retry strategy and timeouts for all API methods in this library.
39
38
*/
40
39
import * as gapicConfig from './managed_identities_service_client_config.json' ;
41
- import { operationsProtos } from 'google-gax' ;
42
40
const version = require ( '../../../package.json' ) . version ;
43
41
44
42
/**
@@ -130,8 +128,18 @@ export class ManagedIdentitiesServiceClient {
130
128
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
131
129
* For more information, please check the
132
130
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
131
+ * @param {gax } [gaxInstance]: loaded instance of `google-gax`. Useful if you
132
+ * need to avoid loading the default gRPC version and want to use the fallback
133
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
134
+ * ```
135
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
136
+ * const client = new ManagedIdentitiesServiceClient({fallback: 'rest'}, gax);
137
+ * ```
133
138
*/
134
- constructor ( opts ?: ClientOptions ) {
139
+ constructor (
140
+ opts ?: ClientOptions ,
141
+ gaxInstance ?: typeof gax | typeof gax . fallback
142
+ ) {
135
143
// Ensure that options include all the required fields.
136
144
const staticMembers = this
137
145
. constructor as typeof ManagedIdentitiesServiceClient ;
@@ -152,8 +160,13 @@ export class ManagedIdentitiesServiceClient {
152
160
opts [ 'scopes' ] = staticMembers . scopes ;
153
161
}
154
162
163
+ // Load google-gax module synchronously if needed
164
+ if ( ! gaxInstance ) {
165
+ gaxInstance = require ( 'google-gax' ) as typeof gax ;
166
+ }
167
+
155
168
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
156
- this . _gaxModule = opts . fallback ? gax . fallback : gax ;
169
+ this . _gaxModule = opts . fallback ? gaxInstance . fallback : gaxInstance ;
157
170
158
171
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
159
172
this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
@@ -401,7 +414,7 @@ export class ManagedIdentitiesServiceClient {
401
414
this . innerApiCalls = { } ;
402
415
403
416
// Add a warn function to the client constructor so it can be easily tested.
404
- this . warn = gax . warn ;
417
+ this . warn = this . _gaxModule . warn ;
405
418
}
406
419
407
420
/**
@@ -626,7 +639,7 @@ export class ManagedIdentitiesServiceClient {
626
639
options . otherArgs = options . otherArgs || { } ;
627
640
options . otherArgs . headers = options . otherArgs . headers || { } ;
628
641
options . otherArgs . headers [ 'x-goog-request-params' ] =
629
- gax . routingHeader . fromParams ( {
642
+ this . _gaxModule . routingHeader . fromParams ( {
630
643
name : request . name || '' ,
631
644
} ) ;
632
645
this . initialize ( ) ;
@@ -718,7 +731,7 @@ export class ManagedIdentitiesServiceClient {
718
731
options . otherArgs = options . otherArgs || { } ;
719
732
options . otherArgs . headers = options . otherArgs . headers || { } ;
720
733
options . otherArgs . headers [ 'x-goog-request-params' ] =
721
- gax . routingHeader . fromParams ( {
734
+ this . _gaxModule . routingHeader . fromParams ( {
722
735
name : request . name || '' ,
723
736
} ) ;
724
737
this . initialize ( ) ;
@@ -838,7 +851,7 @@ export class ManagedIdentitiesServiceClient {
838
851
options . otherArgs = options . otherArgs || { } ;
839
852
options . otherArgs . headers = options . otherArgs . headers || { } ;
840
853
options . otherArgs . headers [ 'x-goog-request-params' ] =
841
- gax . routingHeader . fromParams ( {
854
+ this . _gaxModule . routingHeader . fromParams ( {
842
855
parent : request . parent || '' ,
843
856
} ) ;
844
857
this . initialize ( ) ;
@@ -868,11 +881,12 @@ export class ManagedIdentitiesServiceClient {
868
881
protos . google . cloud . managedidentities . v1 . OpMetadata
869
882
>
870
883
> {
871
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
872
- { name}
873
- ) ;
884
+ const request =
885
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
886
+ { name}
887
+ ) ;
874
888
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
875
- const decodeOperation = new gax . Operation (
889
+ const decodeOperation = new this . _gaxModule . Operation (
876
890
operation ,
877
891
this . descriptors . longrunning . createMicrosoftAdDomain ,
878
892
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -987,7 +1001,7 @@ export class ManagedIdentitiesServiceClient {
987
1001
options . otherArgs = options . otherArgs || { } ;
988
1002
options . otherArgs . headers = options . otherArgs . headers || { } ;
989
1003
options . otherArgs . headers [ 'x-goog-request-params' ] =
990
- gax . routingHeader . fromParams ( {
1004
+ this . _gaxModule . routingHeader . fromParams ( {
991
1005
'domain.name' : request . domain ! . name || '' ,
992
1006
} ) ;
993
1007
this . initialize ( ) ;
@@ -1013,11 +1027,12 @@ export class ManagedIdentitiesServiceClient {
1013
1027
protos . google . cloud . managedidentities . v1 . OpMetadata
1014
1028
>
1015
1029
> {
1016
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1017
- { name}
1018
- ) ;
1030
+ const request =
1031
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1032
+ { name}
1033
+ ) ;
1019
1034
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1020
- const decodeOperation = new gax . Operation (
1035
+ const decodeOperation = new this . _gaxModule . Operation (
1021
1036
operation ,
1022
1037
this . descriptors . longrunning . updateDomain ,
1023
1038
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1125,7 +1140,7 @@ export class ManagedIdentitiesServiceClient {
1125
1140
options . otherArgs = options . otherArgs || { } ;
1126
1141
options . otherArgs . headers = options . otherArgs . headers || { } ;
1127
1142
options . otherArgs . headers [ 'x-goog-request-params' ] =
1128
- gax . routingHeader . fromParams ( {
1143
+ this . _gaxModule . routingHeader . fromParams ( {
1129
1144
name : request . name || '' ,
1130
1145
} ) ;
1131
1146
this . initialize ( ) ;
@@ -1151,11 +1166,12 @@ export class ManagedIdentitiesServiceClient {
1151
1166
protos . google . cloud . managedidentities . v1 . OpMetadata
1152
1167
>
1153
1168
> {
1154
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1155
- { name}
1156
- ) ;
1169
+ const request =
1170
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1171
+ { name}
1172
+ ) ;
1157
1173
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1158
- const decodeOperation = new gax . Operation (
1174
+ const decodeOperation = new this . _gaxModule . Operation (
1159
1175
operation ,
1160
1176
this . descriptors . longrunning . deleteDomain ,
1161
1177
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1265,7 +1281,7 @@ export class ManagedIdentitiesServiceClient {
1265
1281
options . otherArgs = options . otherArgs || { } ;
1266
1282
options . otherArgs . headers = options . otherArgs . headers || { } ;
1267
1283
options . otherArgs . headers [ 'x-goog-request-params' ] =
1268
- gax . routingHeader . fromParams ( {
1284
+ this . _gaxModule . routingHeader . fromParams ( {
1269
1285
name : request . name || '' ,
1270
1286
} ) ;
1271
1287
this . initialize ( ) ;
@@ -1291,11 +1307,12 @@ export class ManagedIdentitiesServiceClient {
1291
1307
protos . google . cloud . managedidentities . v1 . OpMetadata
1292
1308
>
1293
1309
> {
1294
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1295
- { name}
1296
- ) ;
1310
+ const request =
1311
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1312
+ { name}
1313
+ ) ;
1297
1314
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1298
- const decodeOperation = new gax . Operation (
1315
+ const decodeOperation = new this . _gaxModule . Operation (
1299
1316
operation ,
1300
1317
this . descriptors . longrunning . attachTrust ,
1301
1318
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1409,7 +1426,7 @@ export class ManagedIdentitiesServiceClient {
1409
1426
options . otherArgs = options . otherArgs || { } ;
1410
1427
options . otherArgs . headers = options . otherArgs . headers || { } ;
1411
1428
options . otherArgs . headers [ 'x-goog-request-params' ] =
1412
- gax . routingHeader . fromParams ( {
1429
+ this . _gaxModule . routingHeader . fromParams ( {
1413
1430
name : request . name || '' ,
1414
1431
} ) ;
1415
1432
this . initialize ( ) ;
@@ -1435,11 +1452,12 @@ export class ManagedIdentitiesServiceClient {
1435
1452
protos . google . cloud . managedidentities . v1 . OpMetadata
1436
1453
>
1437
1454
> {
1438
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1439
- { name}
1440
- ) ;
1455
+ const request =
1456
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1457
+ { name}
1458
+ ) ;
1441
1459
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1442
- const decodeOperation = new gax . Operation (
1460
+ const decodeOperation = new this . _gaxModule . Operation (
1443
1461
operation ,
1444
1462
this . descriptors . longrunning . reconfigureTrust ,
1445
1463
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1549,7 +1567,7 @@ export class ManagedIdentitiesServiceClient {
1549
1567
options . otherArgs = options . otherArgs || { } ;
1550
1568
options . otherArgs . headers = options . otherArgs . headers || { } ;
1551
1569
options . otherArgs . headers [ 'x-goog-request-params' ] =
1552
- gax . routingHeader . fromParams ( {
1570
+ this . _gaxModule . routingHeader . fromParams ( {
1553
1571
name : request . name || '' ,
1554
1572
} ) ;
1555
1573
this . initialize ( ) ;
@@ -1575,11 +1593,12 @@ export class ManagedIdentitiesServiceClient {
1575
1593
protos . google . cloud . managedidentities . v1 . OpMetadata
1576
1594
>
1577
1595
> {
1578
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1579
- { name}
1580
- ) ;
1596
+ const request =
1597
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1598
+ { name}
1599
+ ) ;
1581
1600
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1582
- const decodeOperation = new gax . Operation (
1601
+ const decodeOperation = new this . _gaxModule . Operation (
1583
1602
operation ,
1584
1603
this . descriptors . longrunning . detachTrust ,
1585
1604
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1690,7 +1709,7 @@ export class ManagedIdentitiesServiceClient {
1690
1709
options . otherArgs = options . otherArgs || { } ;
1691
1710
options . otherArgs . headers = options . otherArgs . headers || { } ;
1692
1711
options . otherArgs . headers [ 'x-goog-request-params' ] =
1693
- gax . routingHeader . fromParams ( {
1712
+ this . _gaxModule . routingHeader . fromParams ( {
1694
1713
name : request . name || '' ,
1695
1714
} ) ;
1696
1715
this . initialize ( ) ;
@@ -1716,11 +1735,12 @@ export class ManagedIdentitiesServiceClient {
1716
1735
protos . google . cloud . managedidentities . v1 . OpMetadata
1717
1736
>
1718
1737
> {
1719
- const request = new operationsProtos . google . longrunning . GetOperationRequest (
1720
- { name}
1721
- ) ;
1738
+ const request =
1739
+ new this . _gaxModule . operationsProtos . google . longrunning . GetOperationRequest (
1740
+ { name}
1741
+ ) ;
1722
1742
const [ operation ] = await this . operationsClient . getOperation ( request ) ;
1723
- const decodeOperation = new gax . Operation (
1743
+ const decodeOperation = new this . _gaxModule . Operation (
1724
1744
operation ,
1725
1745
this . descriptors . longrunning . validateTrust ,
1726
1746
this . _gaxModule . createDefaultBackoffSettings ( )
@@ -1837,7 +1857,7 @@ export class ManagedIdentitiesServiceClient {
1837
1857
options . otherArgs = options . otherArgs || { } ;
1838
1858
options . otherArgs . headers = options . otherArgs . headers || { } ;
1839
1859
options . otherArgs . headers [ 'x-goog-request-params' ] =
1840
- gax . routingHeader . fromParams ( {
1860
+ this . _gaxModule . routingHeader . fromParams ( {
1841
1861
parent : request . parent || '' ,
1842
1862
} ) ;
1843
1863
this . initialize ( ) ;
@@ -1890,7 +1910,7 @@ export class ManagedIdentitiesServiceClient {
1890
1910
options . otherArgs = options . otherArgs || { } ;
1891
1911
options . otherArgs . headers = options . otherArgs . headers || { } ;
1892
1912
options . otherArgs . headers [ 'x-goog-request-params' ] =
1893
- gax . routingHeader . fromParams ( {
1913
+ this . _gaxModule . routingHeader . fromParams ( {
1894
1914
parent : request . parent || '' ,
1895
1915
} ) ;
1896
1916
const defaultCallSettings = this . _defaults [ 'listDomains' ] ;
@@ -1952,7 +1972,7 @@ export class ManagedIdentitiesServiceClient {
1952
1972
options . otherArgs = options . otherArgs || { } ;
1953
1973
options . otherArgs . headers = options . otherArgs . headers || { } ;
1954
1974
options . otherArgs . headers [ 'x-goog-request-params' ] =
1955
- gax . routingHeader . fromParams ( {
1975
+ this . _gaxModule . routingHeader . fromParams ( {
1956
1976
parent : request . parent || '' ,
1957
1977
} ) ;
1958
1978
const defaultCallSettings = this . _defaults [ 'listDomains' ] ;
0 commit comments