@@ -52,8 +52,10 @@ export class PolicyTagManagerSerializationClient {
5252 /**
5353 * Construct an instance of PolicyTagManagerSerializationClient.
5454 *
55- * @param {object } [options] - The configuration object. See the subsequent
56- * parameters for more details.
55+ * @param {object } [options] - The configuration object.
56+ * The options accepted by the constructor are described in detail
57+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
58+ * The common options are:
5759 * @param {object } [options.credentials] - Credentials object.
5860 * @param {string } [options.credentials.client_email]
5961 * @param {string } [options.credentials.private_key]
@@ -73,44 +75,34 @@ export class PolicyTagManagerSerializationClient {
7375 * your project ID will be detected automatically.
7476 * @param {string } [options.apiEndpoint] - The domain name of the
7577 * API remote host.
78+ * @param {gax.ClientConfig } [options.clientConfig] - client configuration override.
79+ * TODO(@alexander-fenster): link to gax documentation.
80+ * @param {boolean } fallback - Use HTTP fallback mode.
81+ * In fallback mode, a special browser-compatible transport implementation is used
82+ * instead of gRPC transport. In browser context (if the `window` object is defined)
83+ * the fallback mode is enabled automatically; set `options.fallback` to `false`
84+ * if you need to override this behavior.
7685 */
77-
7886 constructor ( opts ?: ClientOptions ) {
79- // Ensure that options include the service address and port .
87+ // Ensure that options include all the required fields .
8088 const staticMembers = this
8189 . constructor as typeof PolicyTagManagerSerializationClient ;
8290 const servicePath =
83- opts && opts . servicePath
84- ? opts . servicePath
85- : opts && opts . apiEndpoint
86- ? opts . apiEndpoint
87- : staticMembers . servicePath ;
88- const port = opts && opts . port ? opts . port : staticMembers . port ;
89-
90- if ( ! opts ) {
91- opts = { servicePath , port } ;
91+ opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
92+ const port = opts ?. port || staticMembers . port ;
93+ const clientConfig = opts ?. clientConfig ?? { } ;
94+ const fallback = opts ?. fallback ?? typeof window !== 'undefined' ;
95+ opts = Object . assign ( { servicePath , port , clientConfig , fallback } , opts ) ;
96+
97+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
98+ if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
99+ opts [ 'scopes' ] = staticMembers . scopes ;
92100 }
93- opts . servicePath = opts . servicePath || servicePath ;
94- opts . port = opts . port || port ;
95-
96- // users can override the config from client side, like retry codes name.
97- // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
98- // The way to override client config for Showcase API:
99- //
100- // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
101- // const showcaseClient = new showcaseClient({ projectId, customConfig });
102- opts . clientConfig = opts . clientConfig || { } ;
103-
104- // If we're running in browser, it's OK to omit `fallback` since
105- // google-gax has `browser` field in its `package.json`.
106- // For Electron (which does not respect `browser` field),
107- // pass `{fallback: true}` to the PolicyTagManagerSerializationClient constructor.
101+
102+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
108103 this . _gaxModule = opts . fallback ? gax . fallback : gax ;
109104
110- // Create a `gaxGrpc` object, with any grpc-specific options
111- // sent to the client.
112- opts . scopes = ( this
113- . constructor as typeof PolicyTagManagerSerializationClient ) . scopes ;
105+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
114106 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
115107
116108 // Save options to use in initialize() method.
@@ -119,6 +111,11 @@ export class PolicyTagManagerSerializationClient {
119111 // Save the auth object to the client, for use by other methods.
120112 this . auth = this . _gaxGrpc . auth as gax . GoogleAuth ;
121113
114+ // Set the default scopes in auth client if needed.
115+ if ( servicePath === staticMembers . servicePath ) {
116+ this . auth . defaultScopes = staticMembers . scopes ;
117+ }
118+
122119 // Determine the client header string.
123120 const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
124121 if ( typeof process !== 'undefined' && 'versions' in process ) {
@@ -262,6 +259,7 @@ export class PolicyTagManagerSerializationClient {
262259
263260 /**
264261 * The DNS address for this API service.
262+ * @returns {string } The DNS address for this service.
265263 */
266264 static get servicePath ( ) {
267265 return 'datacatalog.googleapis.com' ;
@@ -270,13 +268,15 @@ export class PolicyTagManagerSerializationClient {
270268 /**
271269 * The DNS address for this API service - same as servicePath(),
272270 * exists for compatibility reasons.
271+ * @returns {string } The DNS address for this service.
273272 */
274273 static get apiEndpoint ( ) {
275274 return 'datacatalog.googleapis.com' ;
276275 }
277276
278277 /**
279278 * The port for this API service.
279+ * @returns {number } The default port for this service.
280280 */
281281 static get port ( ) {
282282 return 443 ;
@@ -285,6 +285,7 @@ export class PolicyTagManagerSerializationClient {
285285 /**
286286 * The scopes needed to make gRPC calls for every method defined
287287 * in this service.
288+ * @returns {string[] } List of default scopes.
288289 */
289290 static get scopes ( ) {
290291 return [ 'https://www.googleapis.com/auth/cloud-platform' ] ;
@@ -294,8 +295,7 @@ export class PolicyTagManagerSerializationClient {
294295 getProjectId ( callback : Callback < string , undefined , undefined > ) : void ;
295296 /**
296297 * Return the project ID used by this class.
297- * @param {function(Error, string) } callback - the callback to
298- * be called with the current project Id.
298+ * @returns {Promise } A promise that resolves to string containing the project ID.
299299 */
300300 getProjectId (
301301 callback ?: Callback < string , undefined , undefined >
@@ -362,7 +362,11 @@ export class PolicyTagManagerSerializationClient {
362362 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
363363 * @returns {Promise } - The promise which resolves to an array.
364364 * The first element of the array is an object representing [ImportTaxonomiesResponse]{@link google.cloud.datacatalog.v1beta1.ImportTaxonomiesResponse}.
365- * The promise has a method named "cancel" which cancels the ongoing API call.
365+ * Please see the
366+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
367+ * for more details and examples.
368+ * @example
369+ * const [response] = await client.importTaxonomies(request);
366370 */
367371 importTaxonomies (
368372 request : protos . google . cloud . datacatalog . v1beta1 . IImportTaxonomiesRequest ,
@@ -464,7 +468,11 @@ export class PolicyTagManagerSerializationClient {
464468 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
465469 * @returns {Promise } - The promise which resolves to an array.
466470 * The first element of the array is an object representing [ExportTaxonomiesResponse]{@link google.cloud.datacatalog.v1beta1.ExportTaxonomiesResponse}.
467- * The promise has a method named "cancel" which cancels the ongoing API call.
471+ * Please see the
472+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
473+ * for more details and examples.
474+ * @example
475+ * const [response] = await client.exportTaxonomies(request);
468476 */
469477 exportTaxonomies (
470478 request : protos . google . cloud . datacatalog . v1beta1 . IExportTaxonomiesRequest ,
@@ -1025,9 +1033,10 @@ export class PolicyTagManagerSerializationClient {
10251033 }
10261034
10271035 /**
1028- * Terminate the GRPC channel and close the client.
1036+ * Terminate the gRPC channel and close the client.
10291037 *
10301038 * The client will no longer be usable and all future behavior is undefined.
1039+ * @returns {Promise } A promise that resolves when the client is closed.
10311040 */
10321041 close ( ) : Promise < void > {
10331042 this . initialize ( ) ;
0 commit comments