@@ -60,8 +60,10 @@ export class RecaptchaEnterpriseServiceClient {
60
60
/**
61
61
* Construct an instance of RecaptchaEnterpriseServiceClient.
62
62
*
63
- * @param {object } [options] - The configuration object. See the subsequent
64
- * parameters for more details.
63
+ * @param {object } [options] - The configuration object.
64
+ * The options accepted by the constructor are described in detail
65
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
66
+ * The common options are:
65
67
* @param {object } [options.credentials] - Credentials object.
66
68
* @param {string } [options.credentials.client_email]
67
69
* @param {string } [options.credentials.private_key]
@@ -81,44 +83,34 @@ export class RecaptchaEnterpriseServiceClient {
81
83
* your project ID will be detected automatically.
82
84
* @param {string } [options.apiEndpoint] - The domain name of the
83
85
* API remote host.
86
+ * @param {gax.ClientConfig } [options.clientConfig] - client configuration override.
87
+ * TODO(@alexander-fenster): link to gax documentation.
88
+ * @param {boolean } fallback - Use HTTP fallback mode.
89
+ * In fallback mode, a special browser-compatible transport implementation is used
90
+ * instead of gRPC transport. In browser context (if the `window` object is defined)
91
+ * the fallback mode is enabled automatically; set `options.fallback` to `false`
92
+ * if you need to override this behavior.
84
93
*/
85
-
86
94
constructor ( opts ?: ClientOptions ) {
87
- // Ensure that options include the service address and port .
95
+ // Ensure that options include all the required fields .
88
96
const staticMembers = this
89
97
. constructor as typeof RecaptchaEnterpriseServiceClient ;
90
98
const servicePath =
91
- opts && opts . servicePath
92
- ? opts . servicePath
93
- : opts && opts . apiEndpoint
94
- ? opts . apiEndpoint
95
- : staticMembers . servicePath ;
96
- const port = opts && opts . port ? opts . port : staticMembers . port ;
99
+ opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
100
+ const port = opts ?. port || staticMembers . port ;
101
+ const clientConfig = opts ?. clientConfig ?? { } ;
102
+ const fallback = opts ?. fallback ?? typeof window !== 'undefined' ;
103
+ opts = Object . assign ( { servicePath, port, clientConfig, fallback} , opts ) ;
97
104
98
- if ( ! opts ) {
99
- opts = { servicePath, port} ;
105
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
106
+ if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
107
+ opts [ 'scopes' ] = staticMembers . scopes ;
100
108
}
101
- opts . servicePath = opts . servicePath || servicePath ;
102
- opts . port = opts . port || port ;
103
-
104
- // users can override the config from client side, like retry codes name.
105
- // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
106
- // The way to override client config for Showcase API:
107
- //
108
- // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
109
- // const showcaseClient = new showcaseClient({ projectId, customConfig });
110
- opts . clientConfig = opts . clientConfig || { } ;
111
109
112
- // If we're running in browser, it's OK to omit `fallback` since
113
- // google-gax has `browser` field in its `package.json`.
114
- // For Electron (which does not respect `browser` field),
115
- // pass `{fallback: true}` to the RecaptchaEnterpriseServiceClient constructor.
110
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
116
111
this . _gaxModule = opts . fallback ? gax . fallback : gax ;
117
112
118
- // Create a `gaxGrpc` object, with any grpc-specific options
119
- // sent to the client.
120
- opts . scopes = ( this
121
- . constructor as typeof RecaptchaEnterpriseServiceClient ) . scopes ;
113
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
122
114
this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
123
115
124
116
// Save options to use in initialize() method.
@@ -127,6 +119,11 @@ export class RecaptchaEnterpriseServiceClient {
127
119
// Save the auth object to the client, for use by other methods.
128
120
this . auth = this . _gaxGrpc . auth as gax . GoogleAuth ;
129
121
122
+ // Set the default scopes in auth client if needed.
123
+ if ( servicePath === staticMembers . servicePath ) {
124
+ this . auth . defaultScopes = staticMembers . scopes ;
125
+ }
126
+
130
127
// Determine the client header string.
131
128
const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
132
129
if ( typeof process !== 'undefined' && 'versions' in process ) {
@@ -268,6 +265,7 @@ export class RecaptchaEnterpriseServiceClient {
268
265
269
266
/**
270
267
* The DNS address for this API service.
268
+ * @returns {string } The DNS address for this service.
271
269
*/
272
270
static get servicePath ( ) {
273
271
return 'recaptchaenterprise.googleapis.com' ;
@@ -276,13 +274,15 @@ export class RecaptchaEnterpriseServiceClient {
276
274
/**
277
275
* The DNS address for this API service - same as servicePath(),
278
276
* exists for compatibility reasons.
277
+ * @returns {string } The DNS address for this service.
279
278
*/
280
279
static get apiEndpoint ( ) {
281
280
return 'recaptchaenterprise.googleapis.com' ;
282
281
}
283
282
284
283
/**
285
284
* The port for this API service.
285
+ * @returns {number } The default port for this service.
286
286
*/
287
287
static get port ( ) {
288
288
return 443 ;
@@ -291,6 +291,7 @@ export class RecaptchaEnterpriseServiceClient {
291
291
/**
292
292
* The scopes needed to make gRPC calls for every method defined
293
293
* in this service.
294
+ * @returns {string[] } List of default scopes.
294
295
*/
295
296
static get scopes ( ) {
296
297
return [ 'https://www.googleapis.com/auth/cloud-platform' ] ;
@@ -300,8 +301,7 @@ export class RecaptchaEnterpriseServiceClient {
300
301
getProjectId ( callback : Callback < string , undefined , undefined > ) : void ;
301
302
/**
302
303
* Return the project ID used by this class.
303
- * @param {function(Error, string) } callback - the callback to
304
- * be called with the current project Id.
304
+ * @returns {Promise } A promise that resolves to string containing the project ID.
305
305
*/
306
306
getProjectId (
307
307
callback ?: Callback < string , undefined , undefined >
@@ -364,7 +364,11 @@ export class RecaptchaEnterpriseServiceClient {
364
364
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
365
365
* @returns {Promise } - The promise which resolves to an array.
366
366
* The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1.Assessment}.
367
- * The promise has a method named "cancel" which cancels the ongoing API call.
367
+ * Please see the
368
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
369
+ * for more details and examples.
370
+ * @example
371
+ * const [response] = await client.createAssessment(request);
368
372
*/
369
373
createAssessment (
370
374
request : protos . google . cloud . recaptchaenterprise . v1 . ICreateAssessmentRequest ,
@@ -462,7 +466,11 @@ export class RecaptchaEnterpriseServiceClient {
462
466
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
463
467
* @returns {Promise } - The promise which resolves to an array.
464
468
* The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse}.
465
- * The promise has a method named "cancel" which cancels the ongoing API call.
469
+ * Please see the
470
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
471
+ * for more details and examples.
472
+ * @example
473
+ * const [response] = await client.annotateAssessment(request);
466
474
*/
467
475
annotateAssessment (
468
476
request : protos . google . cloud . recaptchaenterprise . v1 . IAnnotateAssessmentRequest ,
@@ -556,7 +564,11 @@ export class RecaptchaEnterpriseServiceClient {
556
564
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
557
565
* @returns {Promise } - The promise which resolves to an array.
558
566
* The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}.
559
- * The promise has a method named "cancel" which cancels the ongoing API call.
567
+ * Please see the
568
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
569
+ * for more details and examples.
570
+ * @example
571
+ * const [response] = await client.createKey(request);
560
572
*/
561
573
createKey (
562
574
request : protos . google . cloud . recaptchaenterprise . v1 . ICreateKeyRequest ,
@@ -645,7 +657,11 @@ export class RecaptchaEnterpriseServiceClient {
645
657
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
646
658
* @returns {Promise } - The promise which resolves to an array.
647
659
* The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}.
648
- * The promise has a method named "cancel" which cancels the ongoing API call.
660
+ * Please see the
661
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
662
+ * for more details and examples.
663
+ * @example
664
+ * const [response] = await client.getKey(request);
649
665
*/
650
666
getKey (
651
667
request : protos . google . cloud . recaptchaenterprise . v1 . IGetKeyRequest ,
@@ -736,7 +752,11 @@ export class RecaptchaEnterpriseServiceClient {
736
752
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
737
753
* @returns {Promise } - The promise which resolves to an array.
738
754
* The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}.
739
- * The promise has a method named "cancel" which cancels the ongoing API call.
755
+ * Please see the
756
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
757
+ * for more details and examples.
758
+ * @example
759
+ * const [response] = await client.updateKey(request);
740
760
*/
741
761
updateKey (
742
762
request : protos . google . cloud . recaptchaenterprise . v1 . IUpdateKeyRequest ,
@@ -825,7 +845,11 @@ export class RecaptchaEnterpriseServiceClient {
825
845
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
826
846
* @returns {Promise } - The promise which resolves to an array.
827
847
* The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
828
- * The promise has a method named "cancel" which cancels the ongoing API call.
848
+ * Please see the
849
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
850
+ * for more details and examples.
851
+ * @example
852
+ * const [response] = await client.deleteKey(request);
829
853
*/
830
854
deleteKey (
831
855
request : protos . google . cloud . recaptchaenterprise . v1 . IDeleteKeyRequest ,
@@ -921,19 +945,14 @@ export class RecaptchaEnterpriseServiceClient {
921
945
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
922
946
* @returns {Promise } - The promise which resolves to an array.
923
947
* The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key}.
924
- * The client library support auto-pagination by default: it will call the API as many
948
+ * The client library will perform auto-pagination by default: it will call the API as many
925
949
* times as needed and will merge results from all the pages into this array.
926
- *
927
- * When autoPaginate: false is specified through options, the array has three elements.
928
- * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key} that corresponds to
929
- * the one page received from the API server.
930
- * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1.ListKeysRequest}
931
- * that can be used to obtain the next page of the results.
932
- * If it is null, the next page does not exist.
933
- * The third element contains the raw response received from the API server. Its type is
934
- * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1.ListKeysResponse}.
935
- *
936
- * The promise has a method named "cancel" which cancels the ongoing API call.
950
+ * Note that it can affect your quota.
951
+ * We recommend using `listKeysAsync()`
952
+ * method described below for async iteration which you can stop as needed.
953
+ * Please see the
954
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
955
+ * for more details and examples.
937
956
*/
938
957
listKeys (
939
958
request : protos . google . cloud . recaptchaenterprise . v1 . IListKeysRequest ,
@@ -981,18 +1000,7 @@ export class RecaptchaEnterpriseServiceClient {
981
1000
}
982
1001
983
1002
/**
984
- * Equivalent to {@link listKeys}, but returns a NodeJS Stream object.
985
- *
986
- * This fetches the paged responses for {@link listKeys} continuously
987
- * and invokes the callback registered for 'data' event for each element in the
988
- * responses.
989
- *
990
- * The returned object has 'end' method when no more elements are required.
991
- *
992
- * autoPaginate option will be ignored.
993
- *
994
- * @see {@link https://nodejs.org/api/stream.html }
995
- *
1003
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
996
1004
* @param {Object } request
997
1005
* The request object that will be sent.
998
1006
* @param {string } request.parent
@@ -1008,6 +1016,13 @@ export class RecaptchaEnterpriseServiceClient {
1008
1016
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1009
1017
* @returns {Stream }
1010
1018
* An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key} on 'data' event.
1019
+ * The client library will perform auto-pagination by default: it will call the API as many
1020
+ * times as needed. Note that it can affect your quota.
1021
+ * We recommend using `listKeysAsync()`
1022
+ * method described below for async iteration which you can stop as needed.
1023
+ * Please see the
1024
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
1025
+ * for more details and examples.
1011
1026
*/
1012
1027
listKeysStream (
1013
1028
request ?: protos . google . cloud . recaptchaenterprise . v1 . IListKeysRequest ,
@@ -1032,10 +1047,9 @@ export class RecaptchaEnterpriseServiceClient {
1032
1047
}
1033
1048
1034
1049
/**
1035
- * Equivalent to {@link listKeys}, but returns an iterable object.
1036
- *
1037
- * for-await-of syntax is used with the iterable to recursively get response element on-demand.
1050
+ * Equivalent to `listKeys`, but returns an iterable object.
1038
1051
*
1052
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1039
1053
* @param {Object } request
1040
1054
* The request object that will be sent.
1041
1055
* @param {string } request.parent
@@ -1050,7 +1064,18 @@ export class RecaptchaEnterpriseServiceClient {
1050
1064
* @param {object } [options]
1051
1065
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1052
1066
* @returns {Object }
1053
- * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
1067
+ * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
1068
+ * When you iterate the returned iterable, each element will be an object representing
1069
+ * [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. The API will be called under the hood as needed, once per the page,
1070
+ * so you can stop the iteration when you don't need more results.
1071
+ * Please see the
1072
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
1073
+ * for more details and examples.
1074
+ * @example
1075
+ * const iterable = client.listKeysAsync(request);
1076
+ * for await (const response of iterable) {
1077
+ * // process response
1078
+ * }
1054
1079
*/
1055
1080
listKeysAsync (
1056
1081
request ?: protos . google . cloud . recaptchaenterprise . v1 . IListKeysRequest ,
@@ -1176,9 +1201,10 @@ export class RecaptchaEnterpriseServiceClient {
1176
1201
}
1177
1202
1178
1203
/**
1179
- * Terminate the GRPC channel and close the client.
1204
+ * Terminate the gRPC channel and close the client.
1180
1205
*
1181
1206
* The client will no longer be usable and all future behavior is undefined.
1207
+ * @returns {Promise } A promise that resolves when the client is closed.
1182
1208
*/
1183
1209
close ( ) : Promise < void > {
1184
1210
this . initialize ( ) ;
0 commit comments