@@ -51,8 +51,10 @@ export class PhishingProtectionServiceV1Beta1Client {
51
51
/**
52
52
* Construct an instance of PhishingProtectionServiceV1Beta1Client.
53
53
*
54
- * @param {object } [options] - The configuration object. See the subsequent
55
- * parameters for more details.
54
+ * @param {object } [options] - The configuration object.
55
+ * The options accepted by the constructor are described in detail
56
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
57
+ * The common options are:
56
58
* @param {object } [options.credentials] - Credentials object.
57
59
* @param {string } [options.credentials.client_email]
58
60
* @param {string } [options.credentials.private_key]
@@ -72,44 +74,34 @@ export class PhishingProtectionServiceV1Beta1Client {
72
74
* your project ID will be detected automatically.
73
75
* @param {string } [options.apiEndpoint] - The domain name of the
74
76
* API remote host.
77
+ * @param {gax.ClientConfig } [options.clientConfig] - client configuration override.
78
+ * TODO(@alexander-fenster): link to gax documentation.
79
+ * @param {boolean } fallback - Use HTTP fallback mode.
80
+ * In fallback mode, a special browser-compatible transport implementation is used
81
+ * instead of gRPC transport. In browser context (if the `window` object is defined)
82
+ * the fallback mode is enabled automatically; set `options.fallback` to `false`
83
+ * if you need to override this behavior.
75
84
*/
76
-
77
85
constructor ( opts ?: ClientOptions ) {
78
- // Ensure that options include the service address and port .
86
+ // Ensure that options include all the required fields .
79
87
const staticMembers = this
80
88
. constructor as typeof PhishingProtectionServiceV1Beta1Client ;
81
89
const servicePath =
82
- opts && opts . servicePath
83
- ? opts . servicePath
84
- : opts && opts . apiEndpoint
85
- ? opts . apiEndpoint
86
- : staticMembers . servicePath ;
87
- const port = opts && opts . port ? opts . port : staticMembers . port ;
88
-
89
- if ( ! opts ) {
90
- opts = { servicePath , port } ;
90
+ opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
91
+ const port = opts ?. port || staticMembers . port ;
92
+ const clientConfig = opts ?. clientConfig ?? { } ;
93
+ const fallback = opts ?. fallback ?? typeof window !== 'undefined' ;
94
+ opts = Object . assign ( { servicePath , port , clientConfig , fallback } , opts ) ;
95
+
96
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
97
+ if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
98
+ opts [ 'scopes' ] = staticMembers . scopes ;
91
99
}
92
- opts . servicePath = opts . servicePath || servicePath ;
93
- opts . port = opts . port || port ;
94
-
95
- // users can override the config from client side, like retry codes name.
96
- // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
97
- // The way to override client config for Showcase API:
98
- //
99
- // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
100
- // const showcaseClient = new showcaseClient({ projectId, customConfig });
101
- opts . clientConfig = opts . clientConfig || { } ;
102
-
103
- // If we're running in browser, it's OK to omit `fallback` since
104
- // google-gax has `browser` field in its `package.json`.
105
- // For Electron (which does not respect `browser` field),
106
- // pass `{fallback: true}` to the PhishingProtectionServiceV1Beta1Client constructor.
100
+
101
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
107
102
this . _gaxModule = opts . fallback ? gax . fallback : gax ;
108
103
109
- // Create a `gaxGrpc` object, with any grpc-specific options
110
- // sent to the client.
111
- opts . scopes = ( this
112
- . constructor as typeof PhishingProtectionServiceV1Beta1Client ) . scopes ;
104
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
113
105
this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
114
106
115
107
// Save options to use in initialize() method.
@@ -118,6 +110,11 @@ export class PhishingProtectionServiceV1Beta1Client {
118
110
// Save the auth object to the client, for use by other methods.
119
111
this . auth = this . _gaxGrpc . auth as gax . GoogleAuth ;
120
112
113
+ // Set the default scopes in auth client if needed.
114
+ if ( servicePath === staticMembers . servicePath ) {
115
+ this . auth . defaultScopes = staticMembers . scopes ;
116
+ }
117
+
121
118
// Determine the client header string.
122
119
const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
123
120
if ( typeof process !== 'undefined' && 'versions' in process ) {
@@ -234,6 +231,7 @@ export class PhishingProtectionServiceV1Beta1Client {
234
231
235
232
/**
236
233
* The DNS address for this API service.
234
+ * @returns {string } The DNS address for this service.
237
235
*/
238
236
static get servicePath ( ) {
239
237
return 'phishingprotection.googleapis.com' ;
@@ -242,13 +240,15 @@ export class PhishingProtectionServiceV1Beta1Client {
242
240
/**
243
241
* The DNS address for this API service - same as servicePath(),
244
242
* exists for compatibility reasons.
243
+ * @returns {string } The DNS address for this service.
245
244
*/
246
245
static get apiEndpoint ( ) {
247
246
return 'phishingprotection.googleapis.com' ;
248
247
}
249
248
250
249
/**
251
250
* The port for this API service.
251
+ * @returns {number } The default port for this service.
252
252
*/
253
253
static get port ( ) {
254
254
return 443 ;
@@ -257,6 +257,7 @@ export class PhishingProtectionServiceV1Beta1Client {
257
257
/**
258
258
* The scopes needed to make gRPC calls for every method defined
259
259
* in this service.
260
+ * @returns {string[] } List of default scopes.
260
261
*/
261
262
static get scopes ( ) {
262
263
return [ 'https://www.googleapis.com/auth/cloud-platform' ] ;
@@ -266,8 +267,7 @@ export class PhishingProtectionServiceV1Beta1Client {
266
267
getProjectId ( callback : Callback < string , undefined , undefined > ) : void ;
267
268
/**
268
269
* Return the project ID used by this class.
269
- * @param {function(Error, string) } callback - the callback to
270
- * be called with the current project Id.
270
+ * @returns {Promise } A promise that resolves to string containing the project ID.
271
271
*/
272
272
getProjectId (
273
273
callback ?: Callback < string , undefined , undefined >
@@ -336,7 +336,11 @@ export class PhishingProtectionServiceV1Beta1Client {
336
336
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
337
337
* @returns {Promise } - The promise which resolves to an array.
338
338
* The first element of the array is an object representing [ReportPhishingResponse]{@link google.cloud.phishingprotection.v1beta1.ReportPhishingResponse}.
339
- * The promise has a method named "cancel" which cancels the ongoing API call.
339
+ * Please see the
340
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
341
+ * for more details and examples.
342
+ * @example
343
+ * const [response] = await client.reportPhishing(request);
340
344
*/
341
345
reportPhishing (
342
346
request : protos . google . cloud . phishingprotection . v1beta1 . IReportPhishingRequest ,
@@ -414,9 +418,10 @@ export class PhishingProtectionServiceV1Beta1Client {
414
418
}
415
419
416
420
/**
417
- * Terminate the GRPC channel and close the client.
421
+ * Terminate the gRPC channel and close the client.
418
422
*
419
423
* The client will no longer be usable and all future behavior is undefined.
424
+ * @returns {Promise } A promise that resolves when the client is closed.
420
425
*/
421
426
close ( ) : Promise < void > {
422
427
this . initialize ( ) ;
0 commit comments