diff --git a/packages/google-cloud-datacatalog/src/v1beta1/data_catalog_client.ts b/packages/google-cloud-datacatalog/src/v1beta1/data_catalog_client.ts index 10bf336b734..e2d3882c92f 100644 --- a/packages/google-cloud-datacatalog/src/v1beta1/data_catalog_client.ts +++ b/packages/google-cloud-datacatalog/src/v1beta1/data_catalog_client.ts @@ -45,8 +45,13 @@ export class DataCatalogClient { private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - dataCatalogStub: Promise<{[name: string]: Function}>; + dataCatalogStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of DataCatalogClient. @@ -70,8 +75,6 @@ export class DataCatalogClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -101,25 +104,28 @@ export class DataCatalogClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof DataCatalogClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -135,7 +141,7 @@ export class DataCatalogClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -143,29 +149,31 @@ export class DataCatalogClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - entryPathTemplate: new gaxModule.PathTemplate( + entryPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}' ), - entryGroupPathTemplate: new gaxModule.PathTemplate( + entryGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}' ), - locationPathTemplate: new gaxModule.PathTemplate( + locationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}' ), - policyTagPathTemplate: new gaxModule.PathTemplate( + policyTagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - tagPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag}' ), - tagTemplatePathTemplate: new gaxModule.PathTemplate( + tagTemplatePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}' ), - tagTemplateFieldPathTemplate: new gaxModule.PathTemplate( + tagTemplateFieldPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field}' ), - taxonomyPathTemplate: new gaxModule.PathTemplate( + taxonomyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}' ), }; @@ -174,22 +182,22 @@ export class DataCatalogClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - searchCatalog: new gaxModule.PageDescriptor( + searchCatalog: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'results' ), - listEntryGroups: new gaxModule.PageDescriptor( + listEntryGroups: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'entryGroups' ), - listEntries: new gaxModule.PageDescriptor( + listEntries: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'entries' ), - listTags: new gaxModule.PageDescriptor( + listTags: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'tags' @@ -197,7 +205,7 @@ export class DataCatalogClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.datacatalog.v1beta1.DataCatalog', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -208,17 +216,35 @@ export class DataCatalogClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.dataCatalogStub) { + return this.dataCatalogStub; + } // Put together the "service stub" for // google.cloud.datacatalog.v1beta1.DataCatalog. - this.dataCatalogStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.dataCatalogStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.datacatalog.v1beta1.DataCatalog' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.datacatalog.v1beta1.DataCatalog, - opts + (this._protos as any).google.cloud.datacatalog.v1beta1.DataCatalog, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -266,9 +292,9 @@ export class DataCatalogClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -282,6 +308,8 @@ export class DataCatalogClient { return apiCall(argument, callOptions, callback); }; } + + return this.dataCatalogStub; } /** @@ -440,6 +468,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createEntryGroup(request, options, callback); } updateEntryGroup( @@ -526,6 +555,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ 'entry_group.name': request.entryGroup!.name || '', }); + this.initialize(); return this._innerApiCalls.updateEntryGroup(request, options, callback); } getEntryGroup( @@ -609,6 +639,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getEntryGroup(request, options, callback); } deleteEntryGroup( @@ -695,6 +726,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteEntryGroup(request, options, callback); } createEntry( @@ -791,6 +823,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createEntry(request, options, callback); } updateEntry( @@ -895,6 +928,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ 'entry.name': request.entry!.name || '', }); + this.initialize(); return this._innerApiCalls.updateEntry(request, options, callback); } deleteEntry( @@ -922,7 +956,7 @@ export class DataCatalogClient { ): void; /** * Deletes an existing entry. Only entries created through - * [CreateEntry][google.cloud.datacatalog.v1beta1.DataCatalog.CreateEntry] + * {@link google.cloud.datacatalog.v1beta1.DataCatalog.CreateEntry|CreateEntry} * method can be deleted. * Users should enable the Data Catalog API in the project identified by * the `name` parameter (see [Data Catalog Resource Project] @@ -982,6 +1016,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteEntry(request, options, callback); } getEntry( @@ -1056,6 +1091,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getEntry(request, options, callback); } lookupEntry( @@ -1152,6 +1188,7 @@ export class DataCatalogClient { options = optionsOrCallback as gax.CallOptions; } options = options || {}; + this.initialize(); return this._innerApiCalls.lookupEntry(request, options, callback); } createTagTemplate( @@ -1245,6 +1282,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createTagTemplate(request, options, callback); } getTagTemplate( @@ -1327,6 +1365,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getTagTemplate(request, options, callback); } updateTagTemplate( @@ -1420,6 +1459,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ 'tag_template.name': request.tagTemplate!.name || '', }); + this.initialize(); return this._innerApiCalls.updateTagTemplate(request, options, callback); } deleteTagTemplate( @@ -1509,6 +1549,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteTagTemplate(request, options, callback); } createTagTemplateField( @@ -1607,6 +1648,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createTagTemplateField( request, options, @@ -1713,6 +1755,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.updateTagTemplateField( request, options, @@ -1805,6 +1848,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.renameTagTemplateField( request, options, @@ -1898,6 +1942,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteTagTemplateField( request, options, @@ -1928,7 +1973,7 @@ export class DataCatalogClient { > ): void; /** - * Creates a tag on an [Entry][google.cloud.datacatalog.v1beta1.Entry]. + * Creates a tag on an {@link google.cloud.datacatalog.v1beta1.Entry|Entry}. * Note: The project identified by the `parent` parameter for the * [tag](https://cloud.google.com/data-catalog/docs/reference/rest/v1beta1/projects.locations.entryGroups.entries.tags/create#path-parameters) * and the @@ -1996,6 +2041,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createTag(request, options, callback); } updateTag( @@ -2079,6 +2125,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ 'tag.name': request.tag!.name || '', }); + this.initialize(); return this._innerApiCalls.updateTag(request, options, callback); } deleteTag( @@ -2161,6 +2208,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteTag(request, options, callback); } setIamPolicy( @@ -2244,6 +2292,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.setIamPolicy(request, options, callback); } getIamPolicy( @@ -2329,6 +2378,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.getIamPolicy(request, options, callback); } testIamPermissions( @@ -2411,6 +2461,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.testIamPermissions(request, options, callback); } @@ -2472,9 +2523,9 @@ export class DataCatalogClient { * for page_size is 1000. Throws an invalid argument for page_size > 1000. * @param {string} [request.pageToken] * Optional. Pagination token returned in an earlier - * [SearchCatalogResponse.next_page_token][google.cloud.datacatalog.v1beta1.SearchCatalogResponse.next_page_token], + * {@link google.cloud.datacatalog.v1beta1.SearchCatalogResponse.next_page_token|SearchCatalogResponse.next_page_token}, * which indicates that this is a continuation of a prior - * [SearchCatalogRequest][google.cloud.datacatalog.v1beta1.DataCatalog.SearchCatalog] + * {@link google.cloud.datacatalog.v1beta1.DataCatalog.SearchCatalog|SearchCatalogRequest} * call, and that the system should return the next page of data. If empty, * the first page is returned. * @param {string} request.orderBy @@ -2534,6 +2585,7 @@ export class DataCatalogClient { options = optionsOrCallback as gax.CallOptions; } options = options || {}; + this.initialize(); return this._innerApiCalls.searchCatalog(request, options, callback); } @@ -2572,9 +2624,9 @@ export class DataCatalogClient { * for page_size is 1000. Throws an invalid argument for page_size > 1000. * @param {string} [request.pageToken] * Optional. Pagination token returned in an earlier - * [SearchCatalogResponse.next_page_token][google.cloud.datacatalog.v1beta1.SearchCatalogResponse.next_page_token], + * {@link google.cloud.datacatalog.v1beta1.SearchCatalogResponse.next_page_token|SearchCatalogResponse.next_page_token}, * which indicates that this is a continuation of a prior - * [SearchCatalogRequest][google.cloud.datacatalog.v1beta1.DataCatalog.SearchCatalog] + * {@link google.cloud.datacatalog.v1beta1.DataCatalog.SearchCatalog|SearchCatalogRequest} * call, and that the system should return the next page of data. If empty, * the first page is returned. * @param {string} request.orderBy @@ -2598,6 +2650,7 @@ export class DataCatalogClient { request = request || {}; options = options || {}; const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.searchCatalog.createStream( this._innerApiCalls.searchCatalog as gax.GaxCall, request, @@ -2694,6 +2747,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listEntryGroups(request, options, callback); } @@ -2742,6 +2796,7 @@ export class DataCatalogClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listEntryGroups.createStream( this._innerApiCalls.listEntryGroups as gax.GaxCall, request, @@ -2843,6 +2898,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listEntries(request, options, callback); } @@ -2896,6 +2952,7 @@ export class DataCatalogClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listEntries.createStream( this._innerApiCalls.listEntries as gax.GaxCall, request, @@ -2922,14 +2979,14 @@ export class DataCatalogClient { > ): void; /** - * Lists the tags on an [Entry][google.cloud.datacatalog.v1beta1.Entry]. + * Lists the tags on an {@link google.cloud.datacatalog.v1beta1.Entry|Entry}. * * @param {Object} request * The request object that will be sent. * @param {string} request.parent * Required. The name of the Data Catalog resource to list the tags of. The - * resource could be an [Entry][google.cloud.datacatalog.v1beta1.Entry] or an - * [EntryGroup][google.cloud.datacatalog.v1beta1.EntryGroup]. + * resource could be an {@link google.cloud.datacatalog.v1beta1.Entry|Entry} or an + * {@link google.cloud.datacatalog.v1beta1.EntryGroup|EntryGroup}. * * Examples: * @@ -2995,6 +3052,7 @@ export class DataCatalogClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listTags(request, options, callback); } @@ -3015,8 +3073,8 @@ export class DataCatalogClient { * The request object that will be sent. * @param {string} request.parent * Required. The name of the Data Catalog resource to list the tags of. The - * resource could be an [Entry][google.cloud.datacatalog.v1beta1.Entry] or an - * [EntryGroup][google.cloud.datacatalog.v1beta1.EntryGroup]. + * resource could be an {@link google.cloud.datacatalog.v1beta1.Entry|Entry} or an + * {@link google.cloud.datacatalog.v1beta1.EntryGroup|EntryGroup}. * * Examples: * @@ -3046,6 +3104,7 @@ export class DataCatalogClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listTags.createStream( this._innerApiCalls.listTags as gax.GaxCall, request, @@ -3571,8 +3630,9 @@ export class DataCatalogClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.dataCatalogStub.then(stub => { + return this.dataCatalogStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_client.ts b/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_client.ts index d6217c5cede..22ff97437e5 100644 --- a/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_client.ts +++ b/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_client.ts @@ -45,8 +45,13 @@ export class PolicyTagManagerClient { private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - policyTagManagerStub: Promise<{[name: string]: Function}>; + policyTagManagerStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of PolicyTagManagerClient. @@ -70,8 +75,6 @@ export class PolicyTagManagerClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -101,25 +104,28 @@ export class PolicyTagManagerClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof PolicyTagManagerClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -135,7 +141,7 @@ export class PolicyTagManagerClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -143,29 +149,31 @@ export class PolicyTagManagerClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - entryPathTemplate: new gaxModule.PathTemplate( + entryPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}' ), - entryGroupPathTemplate: new gaxModule.PathTemplate( + entryGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}' ), - locationPathTemplate: new gaxModule.PathTemplate( + locationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}' ), - policyTagPathTemplate: new gaxModule.PathTemplate( + policyTagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - tagPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag}' ), - tagTemplatePathTemplate: new gaxModule.PathTemplate( + tagTemplatePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}' ), - tagTemplateFieldPathTemplate: new gaxModule.PathTemplate( + tagTemplateFieldPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field}' ), - taxonomyPathTemplate: new gaxModule.PathTemplate( + taxonomyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}' ), }; @@ -174,12 +182,12 @@ export class PolicyTagManagerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listTaxonomies: new gaxModule.PageDescriptor( + listTaxonomies: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'taxonomies' ), - listPolicyTags: new gaxModule.PageDescriptor( + listPolicyTags: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'policyTags' @@ -187,7 +195,7 @@ export class PolicyTagManagerClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.datacatalog.v1beta1.PolicyTagManager', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -198,17 +206,36 @@ export class PolicyTagManagerClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.policyTagManagerStub) { + return this.policyTagManagerStub; + } // Put together the "service stub" for // google.cloud.datacatalog.v1beta1.PolicyTagManager. - this.policyTagManagerStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.policyTagManagerStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.datacatalog.v1beta1.PolicyTagManager' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.datacatalog.v1beta1.PolicyTagManager, - opts + (this._protos as any).google.cloud.datacatalog.v1beta1 + .PolicyTagManager, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -242,9 +269,9 @@ export class PolicyTagManagerClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -258,6 +285,8 @@ export class PolicyTagManagerClient { return apiCall(argument, callOptions, callback); }; } + + return this.policyTagManagerStub; } /** @@ -390,6 +419,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createTaxonomy(request, options, callback); } deleteTaxonomy( @@ -472,6 +502,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteTaxonomy(request, options, callback); } updateTaxonomy( @@ -558,6 +589,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ 'taxonomy.name': request.taxonomy!.name || '', }); + this.initialize(); return this._innerApiCalls.updateTaxonomy(request, options, callback); } getTaxonomy( @@ -638,6 +670,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getTaxonomy(request, options, callback); } createPolicyTag( @@ -720,6 +753,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createPolicyTag(request, options, callback); } deletePolicyTag( @@ -801,6 +835,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deletePolicyTag(request, options, callback); } updatePolicyTag( @@ -890,6 +925,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ 'policy_tag.name': request.policyTag!.name || '', }); + this.initialize(); return this._innerApiCalls.updatePolicyTag(request, options, callback); } getPolicyTag( @@ -970,6 +1006,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getPolicyTag(request, options, callback); } getIamPolicy( @@ -1039,6 +1076,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.getIamPolicy(request, options, callback); } setIamPolicy( @@ -1108,6 +1146,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.setIamPolicy(request, options, callback); } testIamPermissions( @@ -1178,6 +1217,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ resource: request.resource || '', }); + this.initialize(); return this._innerApiCalls.testIamPermissions(request, options, callback); } @@ -1269,6 +1309,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listTaxonomies(request, options, callback); } @@ -1314,6 +1355,7 @@ export class PolicyTagManagerClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listTaxonomies.createStream( this._innerApiCalls.listTaxonomies as gax.GaxCall, request, @@ -1407,6 +1449,7 @@ export class PolicyTagManagerClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listPolicyTags(request, options, callback); } @@ -1452,6 +1495,7 @@ export class PolicyTagManagerClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listPolicyTags.createStream( this._innerApiCalls.listPolicyTags as gax.GaxCall, request, @@ -1977,8 +2021,9 @@ export class PolicyTagManagerClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.policyTagManagerStub.then(stub => { + return this.policyTagManagerStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_serialization_client.ts b/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_serialization_client.ts index 6e49cbfc07b..aa8134c6abd 100644 --- a/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_serialization_client.ts +++ b/packages/google-cloud-datacatalog/src/v1beta1/policy_tag_manager_serialization_client.ts @@ -42,8 +42,13 @@ export class PolicyTagManagerSerializationClient { private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - policyTagManagerSerializationStub: Promise<{[name: string]: Function}>; + policyTagManagerSerializationStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of PolicyTagManagerSerializationClient. @@ -67,8 +72,6 @@ export class PolicyTagManagerSerializationClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -99,26 +102,29 @@ export class PolicyTagManagerSerializationClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this .constructor as typeof PolicyTagManagerSerializationClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -134,7 +140,7 @@ export class PolicyTagManagerSerializationClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -142,35 +148,37 @@ export class PolicyTagManagerSerializationClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - entryPathTemplate: new gaxModule.PathTemplate( + entryPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}' ), - entryGroupPathTemplate: new gaxModule.PathTemplate( + entryGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}' ), - locationPathTemplate: new gaxModule.PathTemplate( + locationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}' ), - policyTagPathTemplate: new gaxModule.PathTemplate( + policyTagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - tagPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag}' ), - tagTemplatePathTemplate: new gaxModule.PathTemplate( + tagTemplatePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}' ), - tagTemplateFieldPathTemplate: new gaxModule.PathTemplate( + tagTemplateFieldPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field}' ), - taxonomyPathTemplate: new gaxModule.PathTemplate( + taxonomyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/taxonomies/{taxonomy}' ), }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.datacatalog.v1beta1.PolicyTagManagerSerialization', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -181,18 +189,36 @@ export class PolicyTagManagerSerializationClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.policyTagManagerSerializationStub) { + return this.policyTagManagerSerializationStub; + } // Put together the "service stub" for // google.cloud.datacatalog.v1beta1.PolicyTagManagerSerialization. - this.policyTagManagerSerializationStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.policyTagManagerSerializationStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.datacatalog.v1beta1.PolicyTagManagerSerialization' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.datacatalog.v1beta1 + (this._protos as any).google.cloud.datacatalog.v1beta1 .PolicyTagManagerSerialization, - opts + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -215,9 +241,9 @@ export class PolicyTagManagerSerializationClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -231,6 +257,8 @@ export class PolicyTagManagerSerializationClient { return apiCall(argument, callOptions, callback); }; } + + return this.policyTagManagerSerializationStub; } /** @@ -368,6 +396,7 @@ export class PolicyTagManagerSerializationClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.importTaxonomies(request, options, callback); } exportTaxonomies( @@ -456,6 +485,7 @@ export class PolicyTagManagerSerializationClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.exportTaxonomies(request, options, callback); } @@ -978,8 +1008,9 @@ export class PolicyTagManagerSerializationClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.policyTagManagerSerializationStub.then(stub => { + return this.policyTagManagerSerializationStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-datacatalog/synth.metadata b/packages/google-cloud-datacatalog/synth.metadata index bda673aafb8..778c1f6b479 100644 --- a/packages/google-cloud-datacatalog/synth.metadata +++ b/packages/google-cloud-datacatalog/synth.metadata @@ -1,13 +1,13 @@ { - "updateTime": "2020-02-29T12:20:31.368336Z", + "updateTime": "2020-03-05T23:04:37.504249Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "83c6f84035ee0f80eaa44d8b688a010461cc4080", - "internalRef": "297918498", - "log": "83c6f84035ee0f80eaa44d8b688a010461cc4080\nUpdate google/api/auth.proto to make AuthProvider to have JwtLocation\n\nPiperOrigin-RevId: 297918498\n\ne9e90a787703ec5d388902e2cb796aaed3a385b4\nDialogflow weekly v2/v2beta1 library update:\n - adding get validation result\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297671458\n\n1a2b05cc3541a5f7714529c665aecc3ea042c646\nAdding .yaml and .json config files.\n\nPiperOrigin-RevId: 297570622\n\ndfe1cf7be44dee31d78f78e485d8c95430981d6e\nPublish `QueryOptions` proto.\n\nIntroduced a `query_options` input in `ExecuteSqlRequest`.\n\nPiperOrigin-RevId: 297497710\n\ndafc905f71e5d46f500b41ed715aad585be062c3\npubsub: revert pull init_rpc_timeout & max_rpc_timeout back to 25 seconds and reset multiplier to 1.0\n\nPiperOrigin-RevId: 297486523\n\nf077632ba7fee588922d9e8717ee272039be126d\nfirestore: add update_transform\n\nPiperOrigin-RevId: 297405063\n\n0aba1900ffef672ec5f0da677cf590ee5686e13b\ncluster: use square brace for cross-reference\n\nPiperOrigin-RevId: 297204568\n\n5dac2da18f6325cbaed54603c43f0667ecd50247\nRestore retry params in gapic config because securitycenter has non-standard default retry params.\nRestore a few retry codes for some idempotent methods.\n\nPiperOrigin-RevId: 297196720\n\n1eb61455530252bba8b2c8d4bc9832960e5a56f6\npubsub: v1 replace IAM HTTP rules\n\nPiperOrigin-RevId: 297188590\n\n80b2d25f8d43d9d47024ff06ead7f7166548a7ba\nDialogflow weekly v2/v2beta1 library update:\n - updates to mega agent api\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297187629\n\n0b1876b35e98f560f9c9ca9797955f020238a092\nUse an older version of protoc-docs-plugin that is compatible with the specified gapic-generator and protobuf versions.\n\nprotoc-docs-plugin >=0.4.0 (see commit https://github.com/googleapis/protoc-docs-plugin/commit/979f03ede6678c487337f3d7e88bae58df5207af) is incompatible with protobuf 3.9.1.\n\nPiperOrigin-RevId: 296986742\n\n1e47e676cddbbd8d93f19ba0665af15b5532417e\nFix: Restore a method signature for UpdateCluster\n\nPiperOrigin-RevId: 296901854\n\n7f910bcc4fc4704947ccfd3ceed015d16b9e00c2\nUpdate Dataproc v1beta2 client.\n\nPiperOrigin-RevId: 296451205\n\nde287524405a3dce124d301634731584fc0432d7\nFix: Reinstate method signatures that had been missed off some RPCs\nFix: Correct resource types for two fields\n\nPiperOrigin-RevId: 296435091\n\ne5bc9566ae057fb4c92f8b7e047f1c8958235b53\nDeprecate the endpoint_uris field, as it is unused.\n\nPiperOrigin-RevId: 296357191\n\n8c12e2b4dca94e12bff9f538bdac29524ff7ef7a\nUpdate Dataproc v1 client.\n\nPiperOrigin-RevId: 296336662\n\n17567c4a1ef0a9b50faa87024d66f8acbb561089\nRemoving erroneous comment, a la https://github.com/googleapis/java-speech/pull/103\n\nPiperOrigin-RevId: 296332968\n\n3eaaaf8626ce5b0c0bc7eee05e143beffa373b01\nAdd BUILD.bazel for v1 secretmanager.googleapis.com\n\nPiperOrigin-RevId: 296274723\n\ne76149c3d992337f85eeb45643106aacae7ede82\nMove securitycenter v1 to use generate from annotations.\n\nPiperOrigin-RevId: 296266862\n\n203740c78ac69ee07c3bf6be7408048751f618f8\nAdd StackdriverLoggingConfig field to Cloud Tasks v2 API.\n\nPiperOrigin-RevId: 296256388\n\ne4117d5e9ed8bbca28da4a60a94947ca51cb2083\nCreate a Bazel BUILD file for the google.actions.type export.\n\nPiperOrigin-RevId: 296212567\n\na9639a0a9854fd6e1be08bba1ac3897f4f16cb2f\nAdd secretmanager.googleapis.com v1 protos\n\nPiperOrigin-RevId: 295983266\n\nce4f4c21d9dd2bfab18873a80449b9d9851efde8\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295861722\n\ncb61d6c2d070b589980c779b68ffca617f789116\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295855449\n\nab2685d8d3a0e191dc8aef83df36773c07cb3d06\nfix: Dataproc v1 - AutoscalingPolicy annotation\n\nThis adds the second resource name pattern to the\nAutoscalingPolicy resource.\n\nCommitter: @lukesneeringer\nPiperOrigin-RevId: 295738415\n\n8a1020bf6828f6e3c84c3014f2c51cb62b739140\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295286165\n\n5cfa105206e77670369e4b2225597386aba32985\nAdd service control related proto build rule.\n\nPiperOrigin-RevId: 295262088\n\nee4dddf805072004ab19ac94df2ce669046eec26\nmonitoring v3: Add prefix \"https://cloud.google.com/\" into the link for global access\ncl 295167522, get ride of synth.py hacks\n\nPiperOrigin-RevId: 295238095\n\nd9835e922ea79eed8497db270d2f9f85099a519c\nUpdate some minor docs changes about user event proto\n\nPiperOrigin-RevId: 295185610\n\n5f311e416e69c170243de722023b22f3df89ec1c\nfix: use correct PHP package name in gapic configuration\n\nPiperOrigin-RevId: 295161330\n\n6cdd74dcdb071694da6a6b5a206e3a320b62dd11\npubsub: v1 add client config annotations and retry config\n\nPiperOrigin-RevId: 295158776\n\n5169f46d9f792e2934d9fa25c36d0515b4fd0024\nAdded cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295026522\n\n56b55aa8818cd0a532a7d779f6ef337ba809ccbd\nFix: Resource annotations for CreateTimeSeriesRequest and ListTimeSeriesRequest should refer to valid resources. TimeSeries is not a named resource.\n\nPiperOrigin-RevId: 294931650\n\n0646bc775203077226c2c34d3e4d50cc4ec53660\nRemove unnecessary languages from bigquery-related artman configuration files.\n\nPiperOrigin-RevId: 294809380\n\n8b78aa04382e3d4147112ad6d344666771bb1909\nUpdate backend.proto for schemes and protocol\n\nPiperOrigin-RevId: 294788800\n\n80b8f8b3de2359831295e24e5238641a38d8488f\nAdds artman config files for bigquerystorage endpoints v1beta2, v1alpha2, v1\n\nPiperOrigin-RevId: 294763931\n\n2c17ac33b226194041155bb5340c3f34733f1b3a\nAdd parameter to sample generated for UpdateInstance. Related to https://github.com/googleapis/python-redis/issues/4\n\nPiperOrigin-RevId: 294734008\n\nd5e8a8953f2acdfe96fb15e85eb2f33739623957\nMove bigquery datatransfer to gapic v2.\n\nPiperOrigin-RevId: 294703703\n\nefd36705972cfcd7d00ab4c6dfa1135bafacd4ae\nfix: Add two annotations that we missed.\n\nPiperOrigin-RevId: 294664231\n\n8a36b928873ff9c05b43859b9d4ea14cd205df57\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1beta2).\n\nPiperOrigin-RevId: 294459768\n\nc7a3caa2c40c49f034a3c11079dd90eb24987047\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1).\n\nPiperOrigin-RevId: 294456889\n\n5006247aa157e59118833658084345ee59af7c09\nFix: Make deprecated fields optional\nFix: Deprecate SetLoggingServiceRequest.zone in line with the comments\nFeature: Add resource name method signatures where appropriate\n\nPiperOrigin-RevId: 294383128\n\neabba40dac05c5cbe0fca3a35761b17e372036c4\nFix: C# and PHP package/namespace capitalization for BigQuery Storage v1.\n\nPiperOrigin-RevId: 294382444\n\nf8d9a858a7a55eba8009a23aa3f5cc5fe5e88dde\nfix: artman configuration file for bigtable-admin\n\nPiperOrigin-RevId: 294322616\n\n0f29555d1cfcf96add5c0b16b089235afbe9b1a9\nAPI definition for (not-yet-launched) GCS gRPC.\n\nPiperOrigin-RevId: 294321472\n\nfcc86bee0e84dc11e9abbff8d7c3529c0626f390\nfix: Bigtable Admin v2\n\nChange LRO metadata from PartialUpdateInstanceMetadata\nto UpdateInstanceMetadata. (Otherwise, it will not build.)\n\nPiperOrigin-RevId: 294264582\n\n6d9361eae2ebb3f42d8c7ce5baf4bab966fee7c0\nrefactor: Add annotations to Bigtable Admin v2.\n\nPiperOrigin-RevId: 294243406\n\nad7616f3fc8e123451c8b3a7987bc91cea9e6913\nFix: Resource type in CreateLogMetricRequest should use logging.googleapis.com.\nFix: ListLogEntries should have a method signature for convenience of calling it.\n\nPiperOrigin-RevId: 294222165\n\n63796fcbb08712676069e20a3e455c9f7aa21026\nFix: Remove extraneous resource definition for cloudkms.googleapis.com/CryptoKey.\n\nPiperOrigin-RevId: 294176658\n\ne7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\n" + "sha": "f0b581b5bdf803e45201ecdb3688b60e381628a8", + "internalRef": "299181282", + "log": "f0b581b5bdf803e45201ecdb3688b60e381628a8\nfix: recommendationengine/v1beta1 update some comments\n\nPiperOrigin-RevId: 299181282\n\n10e9a0a833dc85ff8f05b2c67ebe5ac785fe04ff\nbuild: add generated BUILD file for Routes Preferred API\n\nPiperOrigin-RevId: 299164808\n\n86738c956a8238d7c77f729be78b0ed887a6c913\npublish v1p1beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299152383\n\n73d9f2ad4591de45c2e1f352bc99d70cbd2a6d95\npublish v1: update with absolute address in comments\n\nPiperOrigin-RevId: 299147194\n\nd2158f24cb77b0b0ccfe68af784c6a628705e3c6\npublish v1beta2: update with absolute address in comments\n\nPiperOrigin-RevId: 299147086\n\n7fca61292c11b4cd5b352cee1a50bf88819dd63b\npublish v1p2beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146903\n\n583b7321624736e2c490e328f4b1957335779295\npublish v1p3beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146674\n\n638253bf86d1ce1c314108a089b7351440c2f0bf\nfix: add java_multiple_files option for automl text_sentiment.proto\n\nPiperOrigin-RevId: 298971070\n\n373d655703bf914fb8b0b1cc4071d772bac0e0d1\nUpdate Recs AI Beta public bazel file\n\nPiperOrigin-RevId: 298961623\n\ndcc5d00fc8a8d8b56f16194d7c682027b2c66a3b\nfix: add java_multiple_files option for automl classification.proto\n\nPiperOrigin-RevId: 298953301\n\na3f791827266f3496a6a5201d58adc4bb265c2a3\nchore: automl/v1 publish annotations and retry config\n\nPiperOrigin-RevId: 298942178\n\n01c681586d8d6dbd60155289b587aee678530bd9\nMark return_immediately in PullRequest deprecated.\n\nPiperOrigin-RevId: 298893281\n\nc9f5e9c4bfed54bbd09227e990e7bded5f90f31c\nRemove out of date documentation for predicate support on the Storage API\n\nPiperOrigin-RevId: 298883309\n\nfd5b3b8238d783b04692a113ffe07c0363f5de0f\ngenerate webrisk v1 proto\n\nPiperOrigin-RevId: 298847934\n\n541b1ded4abadcc38e8178680b0677f65594ea6f\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 298686266\n\nc0d171acecb4f5b0bfd2c4ca34fc54716574e300\n Updated to include the Notification v1 API.\n\nPiperOrigin-RevId: 298652775\n\n2346a9186c0bff2c9cc439f2459d558068637e05\nAdd Service Directory v1beta1 protos and configs\n\nPiperOrigin-RevId: 298625638\n\na78ed801b82a5c6d9c5368e24b1412212e541bb7\nPublishing v3 protos and configs.\n\nPiperOrigin-RevId: 298607357\n\n4a180bfff8a21645b3a935c2756e8d6ab18a74e0\nautoml/v1beta1 publish proto updates\n\nPiperOrigin-RevId: 298484782\n\n6de6e938b7df1cd62396563a067334abeedb9676\nchore: use the latest gapic-generator and protoc-java-resource-name-plugin in Bazel workspace.\n\nPiperOrigin-RevId: 298474513\n\n244ab2b83a82076a1fa7be63b7e0671af73f5c02\nAdds service config definition for bigqueryreservation v1\n\nPiperOrigin-RevId: 298455048\n\n" } }, { diff --git a/packages/google-cloud-datacatalog/test/gapic-data_catalog-v1beta1.ts b/packages/google-cloud-datacatalog/test/gapic-data_catalog-v1beta1.ts index 1fd3db9e7a2..977839595be 100644 --- a/packages/google-cloud-datacatalog/test/gapic-data_catalog-v1beta1.ts +++ b/packages/google-cloud-datacatalog/test/gapic-data_catalog-v1beta1.ts @@ -81,12 +81,30 @@ describe('v1beta1.DataCatalogClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new datacatalogModule.v1beta1.DataCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.dataCatalogStub, undefined); + await client.initialize(); + assert(client.dataCatalogStub); + }); + it('has close method', () => { + const client = new datacatalogModule.v1beta1.DataCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createEntryGroup', () => { it('invokes createEntryGroup without error', done => { const client = new datacatalogModule.v1beta1.DataCatalogClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateEntryGroupRequest = {}; request.parent = ''; @@ -110,6 +128,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateEntryGroupRequest = {}; request.parent = ''; @@ -135,6 +155,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateEntryGroupRequest = {}; request.entryGroup = {}; @@ -159,6 +181,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateEntryGroupRequest = {}; request.entryGroup = {}; @@ -185,6 +209,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetEntryGroupRequest = {}; request.name = ''; @@ -208,6 +234,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetEntryGroupRequest = {}; request.name = ''; @@ -233,6 +261,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteEntryGroupRequest = {}; request.name = ''; @@ -256,6 +286,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteEntryGroupRequest = {}; request.name = ''; @@ -281,6 +313,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateEntryRequest = {}; request.parent = ''; @@ -304,6 +338,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateEntryRequest = {}; request.parent = ''; @@ -329,6 +365,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateEntryRequest = {}; request.entry = {}; @@ -353,6 +391,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateEntryRequest = {}; request.entry = {}; @@ -379,6 +419,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteEntryRequest = {}; request.name = ''; @@ -402,6 +444,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteEntryRequest = {}; request.name = ''; @@ -427,6 +471,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetEntryRequest = {}; request.name = ''; @@ -450,6 +496,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetEntryRequest = {}; request.name = ''; @@ -475,6 +523,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ILookupEntryRequest = {}; // Mock response @@ -497,6 +547,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ILookupEntryRequest = {}; // Mock response @@ -521,6 +573,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagTemplateRequest = {}; request.parent = ''; @@ -544,6 +598,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagTemplateRequest = {}; request.parent = ''; @@ -569,6 +625,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetTagTemplateRequest = {}; request.name = ''; @@ -592,6 +650,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetTagTemplateRequest = {}; request.name = ''; @@ -617,6 +677,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagTemplateRequest = {}; request.tagTemplate = {}; @@ -641,6 +703,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagTemplateRequest = {}; request.tagTemplate = {}; @@ -667,6 +731,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagTemplateRequest = {}; request.name = ''; @@ -690,6 +756,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagTemplateRequest = {}; request.name = ''; @@ -715,6 +783,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagTemplateFieldRequest = {}; request.parent = ''; @@ -738,6 +808,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagTemplateFieldRequest = {}; request.parent = ''; @@ -763,6 +835,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagTemplateFieldRequest = {}; request.name = ''; @@ -786,6 +860,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagTemplateFieldRequest = {}; request.name = ''; @@ -811,6 +887,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IRenameTagTemplateFieldRequest = {}; request.name = ''; @@ -834,6 +912,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IRenameTagTemplateFieldRequest = {}; request.name = ''; @@ -859,6 +939,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagTemplateFieldRequest = {}; request.name = ''; @@ -882,6 +964,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagTemplateFieldRequest = {}; request.name = ''; @@ -907,6 +991,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagRequest = {}; request.parent = ''; @@ -930,6 +1016,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTagRequest = {}; request.parent = ''; @@ -955,6 +1043,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagRequest = {}; request.tag = {}; @@ -979,6 +1069,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTagRequest = {}; request.tag = {}; @@ -1005,6 +1097,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagRequest = {}; request.name = ''; @@ -1028,6 +1122,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTagRequest = {}; request.name = ''; @@ -1053,6 +1149,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ISetIamPolicyRequest = {}; request.resource = ''; @@ -1076,6 +1174,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ISetIamPolicyRequest = {}; request.resource = ''; @@ -1101,6 +1201,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.IGetIamPolicyRequest = {}; request.resource = ''; @@ -1124,6 +1226,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.IGetIamPolicyRequest = {}; request.resource = ''; @@ -1149,6 +1253,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ITestIamPermissionsRequest = {}; request.resource = ''; @@ -1172,6 +1278,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ITestIamPermissionsRequest = {}; request.resource = ''; @@ -1197,6 +1305,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ISearchCatalogRequest = {}; // Mock response @@ -1223,6 +1333,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ISearchCatalogRequest = {}; // Mock response @@ -1254,6 +1366,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListEntryGroupsRequest = {}; request.parent = ''; @@ -1281,6 +1395,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListEntryGroupsRequest = {}; request.parent = ''; @@ -1313,6 +1429,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListEntriesRequest = {}; request.parent = ''; @@ -1340,6 +1458,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListEntriesRequest = {}; request.parent = ''; @@ -1372,6 +1492,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListTagsRequest = {}; request.parent = ''; @@ -1399,6 +1521,8 @@ describe('v1beta1.DataCatalogClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListTagsRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager-v1beta1.ts b/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager-v1beta1.ts index e41aabddffc..27d69d7bb88 100644 --- a/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager-v1beta1.ts +++ b/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager-v1beta1.ts @@ -83,12 +83,30 @@ describe('v1beta1.PolicyTagManagerClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new policytagmanagerModule.v1beta1.PolicyTagManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.policyTagManagerStub, undefined); + await client.initialize(); + assert(client.policyTagManagerStub); + }); + it('has close method', () => { + const client = new policytagmanagerModule.v1beta1.PolicyTagManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createTaxonomy', () => { it('invokes createTaxonomy without error', done => { const client = new policytagmanagerModule.v1beta1.PolicyTagManagerClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTaxonomyRequest = {}; request.parent = ''; @@ -112,6 +130,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreateTaxonomyRequest = {}; request.parent = ''; @@ -137,6 +157,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTaxonomyRequest = {}; request.name = ''; @@ -160,6 +182,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeleteTaxonomyRequest = {}; request.name = ''; @@ -185,6 +209,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTaxonomyRequest = {}; request.taxonomy = {}; @@ -209,6 +235,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdateTaxonomyRequest = {}; request.taxonomy = {}; @@ -235,6 +263,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetTaxonomyRequest = {}; request.name = ''; @@ -258,6 +288,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetTaxonomyRequest = {}; request.name = ''; @@ -283,6 +315,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreatePolicyTagRequest = {}; request.parent = ''; @@ -306,6 +340,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.ICreatePolicyTagRequest = {}; request.parent = ''; @@ -331,6 +367,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeletePolicyTagRequest = {}; request.name = ''; @@ -354,6 +392,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IDeletePolicyTagRequest = {}; request.name = ''; @@ -379,6 +419,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdatePolicyTagRequest = {}; request.policyTag = {}; @@ -403,6 +445,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IUpdatePolicyTagRequest = {}; request.policyTag = {}; @@ -429,6 +473,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetPolicyTagRequest = {}; request.name = ''; @@ -452,6 +498,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IGetPolicyTagRequest = {}; request.name = ''; @@ -477,6 +525,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.IGetIamPolicyRequest = {}; request.resource = ''; @@ -500,6 +550,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.IGetIamPolicyRequest = {}; request.resource = ''; @@ -525,6 +577,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ISetIamPolicyRequest = {}; request.resource = ''; @@ -548,6 +602,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ISetIamPolicyRequest = {}; request.resource = ''; @@ -573,6 +629,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ITestIamPermissionsRequest = {}; request.resource = ''; @@ -596,6 +654,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.iam.v1.ITestIamPermissionsRequest = {}; request.resource = ''; @@ -621,6 +681,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListTaxonomiesRequest = {}; request.parent = ''; @@ -648,6 +710,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListTaxonomiesRequest = {}; request.parent = ''; @@ -680,6 +744,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListPolicyTagsRequest = {}; request.parent = ''; @@ -707,6 +773,8 @@ describe('v1beta1.PolicyTagManagerClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IListPolicyTagsRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager_serialization-v1beta1.ts b/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager_serialization-v1beta1.ts index b7b04d59885..e156f5617a6 100644 --- a/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager_serialization-v1beta1.ts +++ b/packages/google-cloud-datacatalog/test/gapic-policy_tag_manager_serialization-v1beta1.ts @@ -89,6 +89,26 @@ describe('v1beta1.PolicyTagManagerSerializationClient', () => { ); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new policytagmanagerserializationModule.v1beta1.PolicyTagManagerSerializationClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.policyTagManagerSerializationStub, undefined); + await client.initialize(); + assert(client.policyTagManagerSerializationStub); + }); + it('has close method', () => { + const client = new policytagmanagerserializationModule.v1beta1.PolicyTagManagerSerializationClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); describe('importTaxonomies', () => { it('invokes importTaxonomies without error', done => { const client = new policytagmanagerserializationModule.v1beta1.PolicyTagManagerSerializationClient( @@ -97,6 +117,8 @@ describe('v1beta1.PolicyTagManagerSerializationClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IImportTaxonomiesRequest = {}; request.parent = ''; @@ -122,6 +144,8 @@ describe('v1beta1.PolicyTagManagerSerializationClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IImportTaxonomiesRequest = {}; request.parent = ''; @@ -149,6 +173,8 @@ describe('v1beta1.PolicyTagManagerSerializationClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IExportTaxonomiesRequest = {}; request.parent = ''; @@ -174,6 +200,8 @@ describe('v1beta1.PolicyTagManagerSerializationClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.datacatalog.v1beta1.IExportTaxonomiesRequest = {}; request.parent = '';