From 4870fe110c528c420a08a4a8691fcfe76ece8f1e Mon Sep 17 00:00:00 2001 From: "gcf-merge-on-green[bot]" <60162190+gcf-merge-on-green[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2020 00:22:28 +0000 Subject: [PATCH] feat: deferred client initialization (#171) This PR includes changes from https://github.com/googleapis/gapic-generator-typescript/pull/317 that will move the asynchronous initialization and authentication from the client constructor to an `initialize()` method. This method will be automatically called when the first RPC call is performed. The client library usage has not changed, there is no need to update any code. If you want to make sure the client is authenticated _before_ the first RPC call, you can do ```js await client.initialize(); ``` manually before calling any client method. --- .../src/v4beta1/application_service_client.ts | 93 +++-- .../src/v4beta1/company_service_client.ts | 101 +++-- .../src/v4beta1/completion_client.ts | 88 +++-- .../src/v4beta1/event_service_client.ts | 84 +++-- .../src/v4beta1/job_service_client.ts | 353 ++++++++++-------- .../src/v4beta1/profile_service_client.ts | 142 ++++--- .../src/v4beta1/tenant_service_client.ts | 93 +++-- packages/google-cloud-talent/synth.metadata | 8 +- .../test/gapic-application_service-v4beta1.ts | 40 ++ .../test/gapic-company_service-v4beta1.ts | 36 ++ .../test/gapic-completion-v4beta1.ts | 20 + .../test/gapic-event_service-v4beta1.ts | 20 + .../test/gapic-job_service-v4beta1.ts | 56 +++ .../test/gapic-profile_service-v4beta1.ts | 40 ++ .../test/gapic-tenant_service-v4beta1.ts | 36 ++ 15 files changed, 848 insertions(+), 362 deletions(-) diff --git a/packages/google-cloud-talent/src/v4beta1/application_service_client.ts b/packages/google-cloud-talent/src/v4beta1/application_service_client.ts index ee0c0b22462..3d4badd75b3 100644 --- a/packages/google-cloud-talent/src/v4beta1/application_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/application_service_client.ts @@ -45,8 +45,13 @@ export class ApplicationServiceClient { 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; - applicationServiceStub: Promise<{[name: string]: Function}>; + applicationServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of ApplicationServiceClient. @@ -70,8 +75,6 @@ export class ApplicationServiceClient { * 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 ApplicationServiceClient { // 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 ApplicationServiceClient).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 ApplicationServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -143,25 +149,25 @@ export class ApplicationServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; @@ -170,7 +176,7 @@ export class ApplicationServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listApplications: new gaxModule.PageDescriptor( + listApplications: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'applications' @@ -178,7 +184,7 @@ export class ApplicationServiceClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.ApplicationService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -189,17 +195,35 @@ export class ApplicationServiceClient { // 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.applicationServiceStub) { + return this.applicationServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.ApplicationService. - this.applicationServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.applicationServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.ApplicationService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.ApplicationService, - opts + (this._protos as any).google.cloud.talent.v4beta1.ApplicationService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -225,9 +249,9 @@ export class ApplicationServiceClient { } ); - 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] @@ -241,6 +265,8 @@ export class ApplicationServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.applicationServiceStub; } /** @@ -380,6 +406,7 @@ export class ApplicationServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createApplication(request, options, callback); } getApplication( @@ -464,6 +491,7 @@ export class ApplicationServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getApplication(request, options, callback); } updateApplication( @@ -499,11 +527,11 @@ export class ApplicationServiceClient { * @param {google.protobuf.FieldMask} request.updateMask * Strongly recommended for the best service experience. * - * If [update_mask][google.cloud.talent.v4beta1.UpdateApplicationRequest.update_mask] is provided, only the specified fields in - * [application][google.cloud.talent.v4beta1.UpdateApplicationRequest.application] are updated. Otherwise all the fields are updated. + * If {@link google.cloud.talent.v4beta1.UpdateApplicationRequest.update_mask|update_mask} is provided, only the specified fields in + * {@link google.cloud.talent.v4beta1.UpdateApplicationRequest.application|application} are updated. Otherwise all the fields are updated. * * A field mask to specify the application fields to be updated. Only - * top level fields of [Application][google.cloud.talent.v4beta1.Application] are supported. + * top level fields of {@link google.cloud.talent.v4beta1.Application|Application} are supported. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -552,6 +580,7 @@ export class ApplicationServiceClient { ] = gax.routingHeader.fromParams({ 'application.name': request.application!.name || '', }); + this.initialize(); return this._innerApiCalls.updateApplication(request, options, callback); } deleteApplication( @@ -636,6 +665,7 @@ export class ApplicationServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteApplication(request, options, callback); } @@ -729,6 +759,7 @@ export class ApplicationServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listApplications(request, options, callback); } @@ -777,6 +808,7 @@ export class ApplicationServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listApplications.createStream( this._innerApiCalls.listApplications as gax.GaxCall, request, @@ -1136,8 +1168,9 @@ export class ApplicationServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.applicationServiceStub.then(stub => { + return this.applicationServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/company_service_client.ts b/packages/google-cloud-talent/src/v4beta1/company_service_client.ts index c444699c675..558a4bbd564 100644 --- a/packages/google-cloud-talent/src/v4beta1/company_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/company_service_client.ts @@ -44,8 +44,13 @@ export class CompanyServiceClient { 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; - companyServiceStub: Promise<{[name: string]: Function}>; + companyServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of CompanyServiceClient. @@ -69,8 +74,6 @@ export class CompanyServiceClient { * 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. */ @@ -100,25 +103,28 @@ export class CompanyServiceClient { // 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 CompanyServiceClient).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 CompanyServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -142,26 +148,28 @@ export class CompanyServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; @@ -170,7 +178,7 @@ export class CompanyServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listCompanies: new gaxModule.PageDescriptor( + listCompanies: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'companies' @@ -178,7 +186,7 @@ export class CompanyServiceClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.CompanyService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -189,17 +197,35 @@ export class CompanyServiceClient { // 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.companyServiceStub) { + return this.companyServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.CompanyService. - this.companyServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.companyServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.CompanyService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.CompanyService, - opts + (this._protos as any).google.cloud.talent.v4beta1.CompanyService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -225,9 +251,9 @@ export class CompanyServiceClient { } ); - 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] @@ -241,6 +267,8 @@ export class CompanyServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.companyServiceStub; } /** @@ -372,6 +400,7 @@ export class CompanyServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createCompany(request, options, callback); } getCompany( @@ -451,6 +480,7 @@ export class CompanyServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getCompany(request, options, callback); } updateCompany( @@ -482,11 +512,11 @@ export class CompanyServiceClient { * @param {google.protobuf.FieldMask} request.updateMask * Strongly recommended for the best service experience. * - * If [update_mask][google.cloud.talent.v4beta1.UpdateCompanyRequest.update_mask] is provided, only the specified fields in - * [company][google.cloud.talent.v4beta1.UpdateCompanyRequest.company] are updated. Otherwise all the fields are updated. + * If {@link google.cloud.talent.v4beta1.UpdateCompanyRequest.update_mask|update_mask} is provided, only the specified fields in + * {@link google.cloud.talent.v4beta1.UpdateCompanyRequest.company|company} are updated. Otherwise all the fields are updated. * * A field mask to specify the company fields to be updated. Only - * top level fields of [Company][google.cloud.talent.v4beta1.Company] are supported. + * top level fields of {@link google.cloud.talent.v4beta1.Company|Company} are supported. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -531,6 +561,7 @@ export class CompanyServiceClient { ] = gax.routingHeader.fromParams({ 'company.name': request.company!.name || '', }); + this.initialize(); return this._innerApiCalls.updateCompany(request, options, callback); } deleteCompany( @@ -611,6 +642,7 @@ export class CompanyServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteCompany(request, options, callback); } @@ -656,7 +688,7 @@ export class CompanyServiceClient { * * Defaults to false. * - * If true, at most [page_size][google.cloud.talent.v4beta1.ListCompaniesRequest.page_size] of companies are fetched, among which + * If true, at most {@link google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of companies are fetched, among which * only those with open jobs are returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -713,6 +745,7 @@ export class CompanyServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listCompanies(request, options, callback); } @@ -749,7 +782,7 @@ export class CompanyServiceClient { * * Defaults to false. * - * If true, at most [page_size][google.cloud.talent.v4beta1.ListCompaniesRequest.page_size] of companies are fetched, among which + * If true, at most {@link google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of companies are fetched, among which * only those with open jobs are returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -770,6 +803,7 @@ export class CompanyServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listCompanies.createStream( this._innerApiCalls.listCompanies as gax.GaxCall, request, @@ -1152,8 +1186,9 @@ export class CompanyServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.companyServiceStub.then(stub => { + return this.companyServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/completion_client.ts b/packages/google-cloud-talent/src/v4beta1/completion_client.ts index 37bc1a4aacb..f699b93b5fc 100644 --- a/packages/google-cloud-talent/src/v4beta1/completion_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/completion_client.ts @@ -41,8 +41,13 @@ export class CompletionClient { 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; - completionStub: Promise<{[name: string]: Function}>; + completionStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of CompletionClient. @@ -66,8 +71,6 @@ export class CompletionClient { * 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. */ @@ -97,25 +100,28 @@ export class CompletionClient { // 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 CompletionClient).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}`); @@ -131,7 +137,7 @@ export class CompletionClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -139,32 +145,34 @@ export class CompletionClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.Completion', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -175,17 +183,35 @@ export class CompletionClient { // 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.completionStub) { + return this.completionStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.Completion. - this.completionStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.completionStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.Completion' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.Completion, - opts + (this._protos as any).google.cloud.talent.v4beta1.Completion, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -205,9 +231,9 @@ export class CompletionClient { } ); - 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] @@ -221,6 +247,8 @@ export class CompletionClient { return apiCall(argument, callOptions, callback); }; } + + return this.completionStub; } /** @@ -334,9 +362,9 @@ export class CompletionClient { * If tenant id is unspecified, the default tenant is used, for * example, "projects/foo". * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope} request.scope - * The scope of the completion. The defaults is [CompletionScope.PUBLIC][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC]. + * The scope of the completion. The defaults is {@link google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC|CompletionScope.PUBLIC}. * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType} request.type - * The completion topic. The default is [CompletionType.COMBINED][google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED]. + * The completion topic. The default is {@link google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED|CompletionType.COMBINED}. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -381,6 +409,7 @@ export class CompletionClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.completeQuery(request, options, callback); } @@ -760,8 +789,9 @@ export class CompletionClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.completionStub.then(stub => { + return this.completionStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/event_service_client.ts b/packages/google-cloud-talent/src/v4beta1/event_service_client.ts index 02f287019cc..fd70fca48e0 100644 --- a/packages/google-cloud-talent/src/v4beta1/event_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/event_service_client.ts @@ -41,8 +41,13 @@ export class EventServiceClient { 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; - eventServiceStub: Promise<{[name: string]: Function}>; + eventServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of EventServiceClient. @@ -66,8 +71,6 @@ export class EventServiceClient { * 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. */ @@ -97,25 +100,28 @@ export class EventServiceClient { // 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 EventServiceClient).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}`); @@ -131,7 +137,7 @@ export class EventServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -139,32 +145,34 @@ export class EventServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.EventService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -175,17 +183,35 @@ export class EventServiceClient { // 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.eventServiceStub) { + return this.eventServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.EventService. - this.eventServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.eventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.EventService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.EventService, - opts + (this._protos as any).google.cloud.talent.v4beta1.EventService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -205,9 +231,9 @@ export class EventServiceClient { } ); - 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] @@ -221,6 +247,8 @@ export class EventServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.eventServiceStub; } /** @@ -367,6 +395,7 @@ export class EventServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createClientEvent(request, options, callback); } @@ -746,8 +775,9 @@ export class EventServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.eventServiceStub.then(stub => { + return this.eventServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/job_service_client.ts b/packages/google-cloud-talent/src/v4beta1/job_service_client.ts index 7ca3476974a..587096f56d1 100644 --- a/packages/google-cloud-talent/src/v4beta1/job_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/job_service_client.ts @@ -45,9 +45,14 @@ export class JobServiceClient { 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; operationsClient: gax.OperationsClient; - jobServiceStub: Promise<{[name: string]: Function}>; + jobServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of JobServiceClient. @@ -71,8 +76,6 @@ export class JobServiceClient { * 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. */ @@ -102,25 +105,28 @@ export class JobServiceClient { // 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 JobServiceClient).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}`); @@ -136,7 +142,7 @@ export class JobServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -144,26 +150,28 @@ export class JobServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; @@ -172,12 +180,12 @@ export class JobServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listJobs: new gaxModule.PageDescriptor( + listJobs: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'jobs' ), - searchJobsForAlert: new gaxModule.PageDescriptor( + searchJobsForAlert: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'matchingJobs' @@ -188,13 +196,15 @@ export class JobServiceClient { // an Operation object that allows for tracking of the operation, // rather than holding a request open. const protoFilesRoot = opts.fallback - ? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json')) - : gaxModule.protobuf.loadSync(nodejsProtoPath); + ? this._gaxModule.protobuf.Root.fromJSON( + require('../../protos/protos.json') + ) + : this._gaxModule.protobuf.loadSync(nodejsProtoPath); - this.operationsClient = gaxModule + this.operationsClient = this._gaxModule .lro({ auth: this.auth, - grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }) .operationsClient(opts); const batchCreateJobsResponse = protoFilesRoot.lookup( @@ -211,12 +221,12 @@ export class JobServiceClient { ) as gax.protobuf.Type; this._descriptors.longrunning = { - batchCreateJobs: new gaxModule.LongrunningDescriptor( + batchCreateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchCreateJobsResponse.decode.bind(batchCreateJobsResponse), batchCreateJobsMetadata.decode.bind(batchCreateJobsMetadata) ), - batchUpdateJobs: new gaxModule.LongrunningDescriptor( + batchUpdateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchUpdateJobsResponse.decode.bind(batchUpdateJobsResponse), batchUpdateJobsMetadata.decode.bind(batchUpdateJobsMetadata) @@ -224,7 +234,7 @@ export class JobServiceClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.JobService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -235,17 +245,35 @@ export class JobServiceClient { // 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.jobServiceStub) { + return this.jobServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.JobService. - this.jobServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.jobServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.JobService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.JobService, - opts + (this._protos as any).google.cloud.talent.v4beta1.JobService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -276,9 +304,9 @@ export class JobServiceClient { } ); - 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] @@ -292,6 +320,8 @@ export class JobServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.jobServiceStub; } /** @@ -425,6 +455,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createJob(request, options, callback); } getJob( @@ -504,6 +535,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getJob(request, options, callback); } updateJob( @@ -538,11 +570,11 @@ export class JobServiceClient { * @param {google.protobuf.FieldMask} request.updateMask * Strongly recommended for the best service experience. * - * If [update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask] is provided, only the specified fields in - * [job][google.cloud.talent.v4beta1.UpdateJobRequest.job] are updated. Otherwise all the fields are updated. + * If {@link google.cloud.talent.v4beta1.UpdateJobRequest.update_mask|update_mask} is provided, only the specified fields in + * {@link google.cloud.talent.v4beta1.UpdateJobRequest.job|job} are updated. Otherwise all the fields are updated. * * A field mask to restrict the fields that are updated. Only - * top level fields of [Job][google.cloud.talent.v4beta1.Job] are supported. + * top level fields of {@link google.cloud.talent.v4beta1.Job|Job} are supported. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -586,6 +618,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ 'job.name': request.job!.name || '', }); + this.initialize(); return this._innerApiCalls.updateJob(request, options, callback); } deleteJob( @@ -667,6 +700,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteJob(request, options, callback); } batchDeleteJobs( @@ -693,7 +727,7 @@ export class JobServiceClient { > ): void; /** - * Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by filter. + * Deletes a list of {@link google.cloud.talent.v4beta1.Job|Job}s by filter. * * @param {Object} request * The request object that will be sent. @@ -763,6 +797,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.batchDeleteJobs(request, options, callback); } searchJobs( @@ -785,9 +820,9 @@ export class JobServiceClient { > ): void; /** - * Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + * Searches for jobs using the provided {@link google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. * - * This call constrains the [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + * This call constrains the {@link google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs * present in the database, and only returns jobs that the caller has * permission to search against. * @@ -802,7 +837,7 @@ export class JobServiceClient { * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode * Mode of a search. * - * Defaults to [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH]. + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata * Required. The meta information collected about the job searcher, used to improve the * search quality of the service. The identifiers (such as `user_id`) are @@ -839,7 +874,7 @@ export class JobServiceClient { * * Data types: * - * * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+. + * * Histogram facet: facet names with format {@link a-zA-Z0-9_|a-zA-Z}+. * * String: string like "any string with backslash escape for quote(\")." * * Number: whole number and floating point number like 10, -1 and -0.01. * * List: list of elements with comma(,) separator surrounded by square @@ -858,20 +893,20 @@ export class JobServiceClient { * * Job histogram facets: * - * * company_display_name: histogram by [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name]. - * * employment_type: histogram by [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], for example, + * * company_display_name: histogram by {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by {@link google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, for example, * "FULL_TIME", "PART_TIME". - * * company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL", + * * company_size: histogram by {@link google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, "SMALL", * "MEDIUM", "BIG". - * * publish_time_in_month: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_month: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in months. * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_year: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in years. * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the [Job.degree_types][google.cloud.talent.v4beta1.Job.degree_types], for example, + * * degree_types: histogram by the {@link google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for example, * "Bachelors", "Masters". - * * job_level: histogram by the [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], for example, "Entry + * * job_level: histogram by the {@link google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, "Entry * Level". * * country: histogram by the country code of jobs, for example, "US", "FR". * * admin1: histogram by the admin1 code of jobs, which is a global @@ -886,14 +921,14 @@ export class JobServiceClient { * and longitude), for example, 37.4038522,-122.0987765. Since the * coordinates of a city center can change, customers may need to refresh * them periodically. - * * locale: histogram by the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], for example, "en-US", + * * locale: histogram by the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for example, "en-US", * "fr-FR". - * * language: histogram by the language subtag of the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], + * * language: histogram by the language subtag of the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, * for example, "en", "fr". - * * category: histogram by the [JobCategory][google.cloud.talent.v4beta1.JobCategory], for example, + * * category: histogram by the {@link google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, * "COMPUTER_AND_IT", "HEALTHCARE". * * base_compensation_unit: histogram by the - * [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit] of base + * {@link google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} of base * salary, for example, "WEEKLY", "MONTHLY". * * base_compensation: histogram by the base salary. Must specify list of * numeric buckets to group results by. @@ -901,10 +936,10 @@ export class JobServiceClient { * Must specify list of numeric buckets to group results by. * * annualized_total_compensation: histogram by the total annualized salary. * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * string_custom_attribute: histogram by string {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * numeric_custom_attribute: histogram by numeric {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to * group results by. @@ -919,11 +954,11 @@ export class JobServiceClient { * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])` * @param {google.cloud.talent.v4beta1.JobView} request.jobView * The desired job attributes returned for jobs in the search response. - * Defaults to [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL] if no value is specified. + * Defaults to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if no value is specified. * @param {number} request.offset * An integer that specifies the current offset (that is, starting result * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] is unset. + * results. This field is only considered if {@link google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is unset. * * The maximum allowed value is 5000. Otherwise an error is thrown. * @@ -939,7 +974,7 @@ export class JobServiceClient { * response time. The value can be between 1 and 100. * @param {string} request.pageToken * The token specifying the current offset within - * search results. See [SearchJobsResponse.next_page_token][google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token] for + * search results. See {@link google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} for * an explanation of how to obtain the next set of query results. * @param {string} request.orderBy * The criteria determining how search results are sorted. Default is @@ -950,32 +985,32 @@ export class JobServiceClient { * * `"relevance desc"`: By relevance descending, as determined by the API * algorithms. Relevance thresholding of query results is only available * with this ordering. - * * `"posting_publish_time desc"`: By [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * `"posting_publish_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * descending. - * * `"posting_update_time desc"`: By [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time] + * * `"posting_update_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} * descending. - * * `"title"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] ascending. - * * `"title desc"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] descending. + * * `"title"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} ascending. + * * `"title desc"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} descending. * * `"annualized_base_compensation"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_base_compensation desc"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation desc"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"custom_ranking desc"`: By the relevance score adjusted to the - * [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] with weight + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} with weight * factor assigned by - * [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level] in descending + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} in descending * order. * * Location sorting: Use the special syntax to order jobs by distance:
* `"distance_from('Hawaii')"`: Order by distance from Hawaii.
@@ -991,7 +1026,7 @@ export class JobServiceClient { * don't have locations will be ranked at the bottom. Distance is calculated * with a precision of 11.3 meters (37.4 feet). Diversification strategy is * still applied unless explicitly disabled in - * [diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level]. + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel * Controls whether highly similar jobs are returned next to each other in * the search results. Jobs are identified as highly similar based on @@ -1000,15 +1035,15 @@ export class JobServiceClient { * displayed to the job seeker higher up in the results, with the other jobs * being displayed lower down in the results. * - * Defaults to [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] if no value + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} if no value * is specified. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo * Controls over how job documents get ranked on top of existing relevance * score (determined by API algorithm). * @param {boolean} request.disableKeywordMatch - * Controls whether to disable exact keyword match on [Job.title][google.cloud.talent.v4beta1.Job.title], - * [Job.description][google.cloud.talent.v4beta1.Job.description], [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], [Job.addresses][google.cloud.talent.v4beta1.Job.addresses], - * [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. When disable keyword match is turned off, a + * Controls whether to disable exact keyword match on {@link google.cloud.talent.v4beta1.Job.title|Job.title}, + * {@link google.cloud.talent.v4beta1.Job.description|Job.description}, {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, {@link google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, + * {@link google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When disable keyword match is turned off, a * keyword match returns jobs that do not match given category filters when * there are matching keywords. For example, for the query "program manager," * a result is returned even if the job posting has the title "software @@ -1019,7 +1054,7 @@ export class JobServiceClient { * location specific ontology, jobs with "cloud" keyword matches are returned * regardless of this flag's value. * - * Use [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes] if + * Use {@link google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} if * company-specific globally matched custom field/attribute string values are * needed. Enabling keyword match improves recall of subsequent search * requests. @@ -1069,6 +1104,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.searchJobs(request, options, callback); } @@ -1162,6 +1198,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.batchCreateJobs(request, options, callback); } batchUpdateJobs( @@ -1206,16 +1243,16 @@ export class JobServiceClient { * Strongly recommended for the best service experience. Be aware that it will * also increase latency when checking the status of a batch operation. * - * If [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] is provided, only the specified fields in - * [Job][google.cloud.talent.v4beta1.Job] are updated. Otherwise all the fields are updated. + * If {@link google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} is provided, only the specified fields in + * {@link google.cloud.talent.v4beta1.Job|Job} are updated. Otherwise all the fields are updated. * * A field mask to restrict the fields that are updated. Only - * top level fields of [Job][google.cloud.talent.v4beta1.Job] are supported. + * top level fields of {@link google.cloud.talent.v4beta1.Job|Job} are supported. * - * If [update_mask][google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask] is provided, The [Job][google.cloud.talent.v4beta1.Job] inside - * [JobResult][google.cloud.talent.v4beta1.JobOperationResult.JobResult] + * If {@link google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} is provided, The {@link google.cloud.talent.v4beta1.Job|Job} inside + * {@link google.cloud.talent.v4beta1.JobOperationResult.JobResult|JobResult} * will only contains fields that is updated, plus the Id of the Job. - * Otherwise, [Job][google.cloud.talent.v4beta1.Job] will include all fields, which can yield a very + * Otherwise, {@link google.cloud.talent.v4beta1.Job|Job} will include all fields, which can yield a very * large response. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -1269,6 +1306,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.batchUpdateJobs(request, options, callback); } listJobs( @@ -1325,13 +1363,13 @@ export class JobServiceClient { * @param {number} request.pageSize * The maximum number of jobs to be returned per page of results. * - * If [job_view][google.cloud.talent.v4beta1.ListJobsRequest.job_view] is set to [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY], the maximum allowed + * If {@link google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, the maximum allowed * page size is 1000. Otherwise, the maximum allowed page size is 100. * * Default is 100 if empty or a number < 1 is specified. * @param {google.cloud.talent.v4beta1.JobView} request.jobView * The desired job attributes returned for jobs in the - * search response. Defaults to [JobView.JOB_VIEW_FULL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL] if no value is + * search response. Defaults to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no value is * specified. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -1388,6 +1426,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listJobs(request, options, callback); } @@ -1436,13 +1475,13 @@ export class JobServiceClient { * @param {number} request.pageSize * The maximum number of jobs to be returned per page of results. * - * If [job_view][google.cloud.talent.v4beta1.ListJobsRequest.job_view] is set to [JobView.JOB_VIEW_ID_ONLY][google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY], the maximum allowed + * If {@link google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, the maximum allowed * page size is 1000. Otherwise, the maximum allowed page size is 100. * * Default is 100 if empty or a number < 1 is specified. * @param {google.cloud.talent.v4beta1.JobView} request.jobView * The desired job attributes returned for jobs in the - * search response. Defaults to [JobView.JOB_VIEW_FULL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL] if no value is + * search response. Defaults to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no value is * specified. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -1463,6 +1502,7 @@ export class JobServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listJobs.createStream( this._innerApiCalls.listJobs as gax.GaxCall, request, @@ -1489,14 +1529,14 @@ export class JobServiceClient { > ): void; /** - * Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. + * Searches for jobs using the provided {@link google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. * * This API call is intended for the use case of targeting passive job * seekers (for example, job seekers who have signed up to receive email * alerts about potential job opportunities), and has different algorithmic * adjustments that are targeted to passive job seekers. * - * This call constrains the [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs + * This call constrains the {@link google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs * present in the database, and only returns jobs the caller has * permission to search against. * @@ -1511,7 +1551,7 @@ export class JobServiceClient { * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode * Mode of a search. * - * Defaults to [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH]. + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata * Required. The meta information collected about the job searcher, used to improve the * search quality of the service. The identifiers (such as `user_id`) are @@ -1548,7 +1588,7 @@ export class JobServiceClient { * * Data types: * - * * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+. + * * Histogram facet: facet names with format {@link a-zA-Z0-9_|a-zA-Z}+. * * String: string like "any string with backslash escape for quote(\")." * * Number: whole number and floating point number like 10, -1 and -0.01. * * List: list of elements with comma(,) separator surrounded by square @@ -1567,20 +1607,20 @@ export class JobServiceClient { * * Job histogram facets: * - * * company_display_name: histogram by [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name]. - * * employment_type: histogram by [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], for example, + * * company_display_name: histogram by {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by {@link google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, for example, * "FULL_TIME", "PART_TIME". - * * company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL", + * * company_size: histogram by {@link google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, "SMALL", * "MEDIUM", "BIG". - * * publish_time_in_month: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_month: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in months. * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_year: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in years. * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the [Job.degree_types][google.cloud.talent.v4beta1.Job.degree_types], for example, + * * degree_types: histogram by the {@link google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for example, * "Bachelors", "Masters". - * * job_level: histogram by the [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], for example, "Entry + * * job_level: histogram by the {@link google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, "Entry * Level". * * country: histogram by the country code of jobs, for example, "US", "FR". * * admin1: histogram by the admin1 code of jobs, which is a global @@ -1595,14 +1635,14 @@ export class JobServiceClient { * and longitude), for example, 37.4038522,-122.0987765. Since the * coordinates of a city center can change, customers may need to refresh * them periodically. - * * locale: histogram by the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], for example, "en-US", + * * locale: histogram by the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for example, "en-US", * "fr-FR". - * * language: histogram by the language subtag of the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], + * * language: histogram by the language subtag of the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, * for example, "en", "fr". - * * category: histogram by the [JobCategory][google.cloud.talent.v4beta1.JobCategory], for example, + * * category: histogram by the {@link google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, * "COMPUTER_AND_IT", "HEALTHCARE". * * base_compensation_unit: histogram by the - * [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit] of base + * {@link google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} of base * salary, for example, "WEEKLY", "MONTHLY". * * base_compensation: histogram by the base salary. Must specify list of * numeric buckets to group results by. @@ -1610,10 +1650,10 @@ export class JobServiceClient { * Must specify list of numeric buckets to group results by. * * annualized_total_compensation: histogram by the total annualized salary. * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * string_custom_attribute: histogram by string {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * numeric_custom_attribute: histogram by numeric {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to * group results by. @@ -1628,11 +1668,11 @@ export class JobServiceClient { * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])` * @param {google.cloud.talent.v4beta1.JobView} request.jobView * The desired job attributes returned for jobs in the search response. - * Defaults to [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL] if no value is specified. + * Defaults to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if no value is specified. * @param {number} request.offset * An integer that specifies the current offset (that is, starting result * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] is unset. + * results. This field is only considered if {@link google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is unset. * * The maximum allowed value is 5000. Otherwise an error is thrown. * @@ -1648,7 +1688,7 @@ export class JobServiceClient { * response time. The value can be between 1 and 100. * @param {string} request.pageToken * The token specifying the current offset within - * search results. See [SearchJobsResponse.next_page_token][google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token] for + * search results. See {@link google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} for * an explanation of how to obtain the next set of query results. * @param {string} request.orderBy * The criteria determining how search results are sorted. Default is @@ -1659,32 +1699,32 @@ export class JobServiceClient { * * `"relevance desc"`: By relevance descending, as determined by the API * algorithms. Relevance thresholding of query results is only available * with this ordering. - * * `"posting_publish_time desc"`: By [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * `"posting_publish_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * descending. - * * `"posting_update_time desc"`: By [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time] + * * `"posting_update_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} * descending. - * * `"title"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] ascending. - * * `"title desc"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] descending. + * * `"title"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} ascending. + * * `"title desc"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} descending. * * `"annualized_base_compensation"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_base_compensation desc"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation desc"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"custom_ranking desc"`: By the relevance score adjusted to the - * [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] with weight + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} with weight * factor assigned by - * [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level] in descending + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} in descending * order. * * Location sorting: Use the special syntax to order jobs by distance:
* `"distance_from('Hawaii')"`: Order by distance from Hawaii.
@@ -1700,7 +1740,7 @@ export class JobServiceClient { * don't have locations will be ranked at the bottom. Distance is calculated * with a precision of 11.3 meters (37.4 feet). Diversification strategy is * still applied unless explicitly disabled in - * [diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level]. + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel * Controls whether highly similar jobs are returned next to each other in * the search results. Jobs are identified as highly similar based on @@ -1709,15 +1749,15 @@ export class JobServiceClient { * displayed to the job seeker higher up in the results, with the other jobs * being displayed lower down in the results. * - * Defaults to [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] if no value + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} if no value * is specified. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo * Controls over how job documents get ranked on top of existing relevance * score (determined by API algorithm). * @param {boolean} request.disableKeywordMatch - * Controls whether to disable exact keyword match on [Job.title][google.cloud.talent.v4beta1.Job.title], - * [Job.description][google.cloud.talent.v4beta1.Job.description], [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], [Job.addresses][google.cloud.talent.v4beta1.Job.addresses], - * [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. When disable keyword match is turned off, a + * Controls whether to disable exact keyword match on {@link google.cloud.talent.v4beta1.Job.title|Job.title}, + * {@link google.cloud.talent.v4beta1.Job.description|Job.description}, {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, {@link google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, + * {@link google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When disable keyword match is turned off, a * keyword match returns jobs that do not match given category filters when * there are matching keywords. For example, for the query "program manager," * a result is returned even if the job posting has the title "software @@ -1728,7 +1768,7 @@ export class JobServiceClient { * location specific ontology, jobs with "cloud" keyword matches are returned * regardless of this flag's value. * - * Use [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes] if + * Use {@link google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} if * company-specific globally matched custom field/attribute string values are * needed. Enabling keyword match improves recall of subsequent search * requests. @@ -1789,6 +1829,7 @@ export class JobServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.searchJobsForAlert(request, options, callback); } @@ -1816,7 +1857,7 @@ export class JobServiceClient { * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode * Mode of a search. * - * Defaults to [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH]. + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata * Required. The meta information collected about the job searcher, used to improve the * search quality of the service. The identifiers (such as `user_id`) are @@ -1853,7 +1894,7 @@ export class JobServiceClient { * * Data types: * - * * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+. + * * Histogram facet: facet names with format {@link a-zA-Z0-9_|a-zA-Z}+. * * String: string like "any string with backslash escape for quote(\")." * * Number: whole number and floating point number like 10, -1 and -0.01. * * List: list of elements with comma(,) separator surrounded by square @@ -1872,20 +1913,20 @@ export class JobServiceClient { * * Job histogram facets: * - * * company_display_name: histogram by [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name]. - * * employment_type: histogram by [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], for example, + * * company_display_name: histogram by {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by {@link google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, for example, * "FULL_TIME", "PART_TIME". - * * company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL", + * * company_size: histogram by {@link google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, "SMALL", * "MEDIUM", "BIG". - * * publish_time_in_month: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_month: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in months. * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * publish_time_in_year: histogram by the {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * in years. * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the [Job.degree_types][google.cloud.talent.v4beta1.Job.degree_types], for example, + * * degree_types: histogram by the {@link google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for example, * "Bachelors", "Masters". - * * job_level: histogram by the [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], for example, "Entry + * * job_level: histogram by the {@link google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, "Entry * Level". * * country: histogram by the country code of jobs, for example, "US", "FR". * * admin1: histogram by the admin1 code of jobs, which is a global @@ -1900,14 +1941,14 @@ export class JobServiceClient { * and longitude), for example, 37.4038522,-122.0987765. Since the * coordinates of a city center can change, customers may need to refresh * them periodically. - * * locale: histogram by the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], for example, "en-US", + * * locale: histogram by the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for example, "en-US", * "fr-FR". - * * language: histogram by the language subtag of the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], + * * language: histogram by the language subtag of the {@link google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, * for example, "en", "fr". - * * category: histogram by the [JobCategory][google.cloud.talent.v4beta1.JobCategory], for example, + * * category: histogram by the {@link google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, * "COMPUTER_AND_IT", "HEALTHCARE". * * base_compensation_unit: histogram by the - * [CompensationInfo.CompensationUnit][google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit] of base + * {@link google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} of base * salary, for example, "WEEKLY", "MONTHLY". * * base_compensation: histogram by the base salary. Must specify list of * numeric buckets to group results by. @@ -1915,10 +1956,10 @@ export class JobServiceClient { * Must specify list of numeric buckets to group results by. * * annualized_total_compensation: histogram by the total annualized salary. * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * string_custom_attribute: histogram by string {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes]. + * * numeric_custom_attribute: histogram by numeric {@link google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. * Values can be accessed via square bracket notations like * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to * group results by. @@ -1933,11 +1974,11 @@ export class JobServiceClient { * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])` * @param {google.cloud.talent.v4beta1.JobView} request.jobView * The desired job attributes returned for jobs in the search response. - * Defaults to [JobView.JOB_VIEW_SMALL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL] if no value is specified. + * Defaults to {@link google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if no value is specified. * @param {number} request.offset * An integer that specifies the current offset (that is, starting result * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] is unset. + * results. This field is only considered if {@link google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is unset. * * The maximum allowed value is 5000. Otherwise an error is thrown. * @@ -1953,7 +1994,7 @@ export class JobServiceClient { * response time. The value can be between 1 and 100. * @param {string} request.pageToken * The token specifying the current offset within - * search results. See [SearchJobsResponse.next_page_token][google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token] for + * search results. See {@link google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} for * an explanation of how to obtain the next set of query results. * @param {string} request.orderBy * The criteria determining how search results are sorted. Default is @@ -1964,32 +2005,32 @@ export class JobServiceClient { * * `"relevance desc"`: By relevance descending, as determined by the API * algorithms. Relevance thresholding of query results is only available * with this ordering. - * * `"posting_publish_time desc"`: By [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time] + * * `"posting_publish_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} * descending. - * * `"posting_update_time desc"`: By [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time] + * * `"posting_update_time desc"`: By {@link google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} * descending. - * * `"title"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] ascending. - * * `"title desc"`: By [Job.title][google.cloud.talent.v4beta1.Job.title] descending. + * * `"title"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} ascending. + * * `"title desc"`: By {@link google.cloud.talent.v4beta1.Job.title|Job.title} descending. * * `"annualized_base_compensation"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_base_compensation desc"`: By job's - * [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] ascending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} ascending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"annualized_total_compensation desc"`: By job's - * [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] descending. Jobs + * {@link google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} descending. Jobs * whose annualized base compensation is unspecified are put at the end of * search results. * * `"custom_ranking desc"`: By the relevance score adjusted to the - * [SearchJobsRequest.CustomRankingInfo.ranking_expression][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression] with weight + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} with weight * factor assigned by - * [SearchJobsRequest.CustomRankingInfo.importance_level][google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level] in descending + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} in descending * order. * * Location sorting: Use the special syntax to order jobs by distance:
* `"distance_from('Hawaii')"`: Order by distance from Hawaii.
@@ -2005,7 +2046,7 @@ export class JobServiceClient { * don't have locations will be ranked at the bottom. Distance is calculated * with a precision of 11.3 meters (37.4 feet). Diversification strategy is * still applied unless explicitly disabled in - * [diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level]. + * {@link google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel * Controls whether highly similar jobs are returned next to each other in * the search results. Jobs are identified as highly similar based on @@ -2014,15 +2055,15 @@ export class JobServiceClient { * displayed to the job seeker higher up in the results, with the other jobs * being displayed lower down in the results. * - * Defaults to [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] if no value + * Defaults to {@link google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} if no value * is specified. * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo * Controls over how job documents get ranked on top of existing relevance * score (determined by API algorithm). * @param {boolean} request.disableKeywordMatch - * Controls whether to disable exact keyword match on [Job.title][google.cloud.talent.v4beta1.Job.title], - * [Job.description][google.cloud.talent.v4beta1.Job.description], [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], [Job.addresses][google.cloud.talent.v4beta1.Job.addresses], - * [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. When disable keyword match is turned off, a + * Controls whether to disable exact keyword match on {@link google.cloud.talent.v4beta1.Job.title|Job.title}, + * {@link google.cloud.talent.v4beta1.Job.description|Job.description}, {@link google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, {@link google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, + * {@link google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When disable keyword match is turned off, a * keyword match returns jobs that do not match given category filters when * there are matching keywords. For example, for the query "program manager," * a result is returned even if the job posting has the title "software @@ -2033,7 +2074,7 @@ export class JobServiceClient { * location specific ontology, jobs with "cloud" keyword matches are returned * regardless of this flag's value. * - * Use [Company.keyword_searchable_job_custom_attributes][google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes] if + * Use {@link google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} if * company-specific globally matched custom field/attribute string values are * needed. Enabling keyword match improves recall of subsequent search * requests. @@ -2058,6 +2099,7 @@ export class JobServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.searchJobsForAlert.createStream( this._innerApiCalls.searchJobsForAlert as gax.GaxCall, request, @@ -2440,8 +2482,9 @@ export class JobServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.jobServiceStub.then(stub => { + return this.jobServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/profile_service_client.ts b/packages/google-cloud-talent/src/v4beta1/profile_service_client.ts index fefdc06e3a0..074d9694d51 100644 --- a/packages/google-cloud-talent/src/v4beta1/profile_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/profile_service_client.ts @@ -45,8 +45,13 @@ export class ProfileServiceClient { 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; - profileServiceStub: Promise<{[name: string]: Function}>; + profileServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of ProfileServiceClient. @@ -70,8 +75,6 @@ export class ProfileServiceClient { * 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 ProfileServiceClient { // 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 ProfileServiceClient).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 ProfileServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -143,25 +149,25 @@ export class ProfileServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; @@ -170,7 +176,7 @@ export class ProfileServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listProfiles: new gaxModule.PageDescriptor( + listProfiles: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'profiles' @@ -178,7 +184,7 @@ export class ProfileServiceClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.ProfileService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -189,17 +195,35 @@ export class ProfileServiceClient { // 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.profileServiceStub) { + return this.profileServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.ProfileService. - this.profileServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.profileServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.ProfileService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.ProfileService, - opts + (this._protos as any).google.cloud.talent.v4beta1.ProfileService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -226,9 +250,9 @@ export class ProfileServiceClient { } ); - 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] @@ -242,6 +266,8 @@ export class ProfileServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.profileServiceStub; } /** @@ -372,6 +398,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createProfile(request, options, callback); } getProfile( @@ -448,6 +475,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getProfile(request, options, callback); } updateProfile( @@ -573,6 +601,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ 'profile.name': request.profile!.name || '', }); + this.initialize(); return this._innerApiCalls.updateProfile(request, options, callback); } deleteProfile( @@ -651,6 +680,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteProfile(request, options, callback); } searchProfiles( @@ -682,7 +712,7 @@ export class ProfileServiceClient { * For example, search by raw queries "software engineer in Mountain View" or * search by structured filters (location filter, education filter, etc.). * - * See [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] for more information. + * See {@link google.cloud.talent.v4beta1.SearchProfilesRequest|SearchProfilesRequest} for more information. * * @param {Object} request * The request object that will be sent. @@ -696,7 +726,7 @@ export class ProfileServiceClient { * to improve the search quality of the service. These values are provided by * users, and must be precise and consistent. * @param {google.cloud.talent.v4beta1.ProfileQuery} request.profileQuery - * Search query to execute. See [ProfileQuery][google.cloud.talent.v4beta1.ProfileQuery] for more details. + * Search query to execute. See {@link google.cloud.talent.v4beta1.ProfileQuery|ProfileQuery} for more details. * @param {number} request.pageSize * A limit on the number of profiles returned in the search results. * A value above the default value 10 can increase search response time. @@ -706,13 +736,13 @@ export class ProfileServiceClient { * The pageToken, similar to offset enables users of the API to paginate * through the search results. To retrieve the first page of results, set the * pageToken to empty. The search response includes a - * [nextPageToken][google.cloud.talent.v4beta1.SearchProfilesResponse.next_page_token] field that can be + * {@link google.cloud.talent.v4beta1.SearchProfilesResponse.next_page_token|nextPageToken} field that can be * used to populate the pageToken field for the next page of results. Using * pageToken instead of offset increases the performance of the API, * especially compared to larger offset values. * @param {number} request.offset * An integer that specifies the current offset (that is, starting result) in - * search results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchProfilesRequest.page_token] is unset. + * search results. This field is only considered if {@link google.cloud.talent.v4beta1.SearchProfilesRequest.page_token|page_token} is unset. * * The maximum allowed value is 5000. Otherwise an error is thrown. * @@ -732,17 +762,17 @@ export class ProfileServiceClient { * * * "relevance desc": By descending relevance, as determined by the API * algorithms. - * * "update_date desc": Sort by [Profile.update_time][google.cloud.talent.v4beta1.Profile.update_time] in descending order + * * "update_date desc": Sort by {@link google.cloud.talent.v4beta1.Profile.update_time|Profile.update_time} in descending order * (recently updated profiles first). - * * "create_date desc": Sort by [Profile.create_time][google.cloud.talent.v4beta1.Profile.create_time] in descending order + * * "create_date desc": Sort by {@link google.cloud.talent.v4beta1.Profile.create_time|Profile.create_time} in descending order * (recently created profiles first). - * * "first_name": Sort by [PersonName.PersonStructuredName.given_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name] in + * * "first_name": Sort by {@link google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name|PersonName.PersonStructuredName.given_name} in * ascending order. - * * "first_name desc": Sort by [PersonName.PersonStructuredName.given_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name] + * * "first_name desc": Sort by {@link google.cloud.talent.v4beta1.PersonName.PersonStructuredName.given_name|PersonName.PersonStructuredName.given_name} * in descending order. - * * "last_name": Sort by [PersonName.PersonStructuredName.family_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name] in + * * "last_name": Sort by {@link google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name|PersonName.PersonStructuredName.family_name} in * ascending order. - * * "last_name desc": Sort by [PersonName.PersonStructuredName.family_name][google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name] + * * "last_name desc": Sort by {@link google.cloud.talent.v4beta1.PersonName.PersonStructuredName.family_name|PersonName.PersonStructuredName.family_name} * in ascending order. * @param {boolean} request.caseSensitiveSort * When sort by field is based on alphabetical order, sort values case @@ -750,7 +780,7 @@ export class ProfileServiceClient { * is case in-sensitive sort (false). * @param {number[]} request.histogramQueries * A list of expressions specifies histogram requests against matching - * profiles for [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest]. + * profiles for {@link google.cloud.talent.v4beta1.SearchProfilesRequest|SearchProfilesRequest}. * * The expression syntax looks like a function definition with parameters. * @@ -758,7 +788,7 @@ export class ProfileServiceClient { * * Data types: * - * * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+. + * * Histogram facet: facet names with format {@link a-zA-Z0-9_|a-zA-Z}+. * * String: string like "any string with backslash escape for quote(\")." * * Number: whole number and floating point number like 10, -1 and -0.01. * * List: list of elements with comma(,) separator surrounded by square @@ -802,13 +832,13 @@ export class ProfileServiceClient { * * experience_in_months: experience in months. 0 means 0 month to 1 month * (exclusive). * * application_date: The application date specifies application start dates. - * See [ApplicationDateFilter][google.cloud.talent.v4beta1.ApplicationDateFilter] for more details. + * See {@link google.cloud.talent.v4beta1.ApplicationDateFilter|ApplicationDateFilter} for more details. * * application_outcome_notes: The application outcome reason specifies the * reasons behind the outcome of the job application. - * See [ApplicationOutcomeNotesFilter][google.cloud.talent.v4beta1.ApplicationOutcomeNotesFilter] for more details. + * See {@link google.cloud.talent.v4beta1.ApplicationOutcomeNotesFilter|ApplicationOutcomeNotesFilter} for more details. * * application_job_title: The application job title specifies the job * applied for in the application. - * See [ApplicationJobFilter][google.cloud.talent.v4beta1.ApplicationJobFilter] for more details. + * See {@link google.cloud.talent.v4beta1.ApplicationJobFilter|ApplicationJobFilter} for more details. * * hirable_status: Hirable status specifies the profile's hirable status. * * string_custom_attribute: String custom attributes. Values can be accessed * via square bracket notation like string_custom_attribute["key1"]. @@ -825,25 +855,25 @@ export class ProfileServiceClient { * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")]) * @param {string} request.resultSetId * An id that uniquely identifies the result set of a - * [SearchProfiles][google.cloud.talent.v4beta1.ProfileService.SearchProfiles] call. The id should be + * {@link google.cloud.talent.v4beta1.ProfileService.SearchProfiles|SearchProfiles} call. The id should be * retrieved from the - * [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse] message returned from a previous - * invocation of [SearchProfiles][google.cloud.talent.v4beta1.ProfileService.SearchProfiles]. + * {@link google.cloud.talent.v4beta1.SearchProfilesResponse|SearchProfilesResponse} message returned from a previous + * invocation of {@link google.cloud.talent.v4beta1.ProfileService.SearchProfiles|SearchProfiles}. * * A result set is an ordered list of search results. * * If this field is not set, a new result set is computed based on the - * [profile_query][google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query]. A new [result_set_id][google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id] is returned as a handle to + * {@link google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query|profile_query}. A new {@link google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id|result_set_id} is returned as a handle to * access this result set. * * If this field is set, the service will ignore the resource and - * [profile_query][google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query] values, and simply retrieve a page of results from the - * corresponding result set. In this case, one and only one of [page_token][google.cloud.talent.v4beta1.SearchProfilesRequest.page_token] - * or [offset][google.cloud.talent.v4beta1.SearchProfilesRequest.offset] must be set. + * {@link google.cloud.talent.v4beta1.SearchProfilesRequest.profile_query|profile_query} values, and simply retrieve a page of results from the + * corresponding result set. In this case, one and only one of {@link google.cloud.talent.v4beta1.SearchProfilesRequest.page_token|page_token} + * or {@link google.cloud.talent.v4beta1.SearchProfilesRequest.offset|offset} must be set. * - * A typical use case is to invoke [SearchProfilesRequest][google.cloud.talent.v4beta1.SearchProfilesRequest] without this - * field, then use the resulting [result_set_id][google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id] in - * [SearchProfilesResponse][google.cloud.talent.v4beta1.SearchProfilesResponse] to page through the results. + * A typical use case is to invoke {@link google.cloud.talent.v4beta1.SearchProfilesRequest|SearchProfilesRequest} without this + * field, then use the resulting {@link google.cloud.talent.v4beta1.SearchProfilesRequest.result_set_id|result_set_id} in + * {@link google.cloud.talent.v4beta1.SearchProfilesResponse|SearchProfilesResponse} to page through the results. * @param {boolean} request.strictKeywordsSearch * This flag is used to indicate whether the service will attempt to * understand synonyms and terms related to the search query or treat the @@ -906,6 +936,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.searchProfiles(request, options, callback); } @@ -959,7 +990,7 @@ export class ProfileServiceClient { * @param {string} request.pageToken * The token that specifies the current offset (that is, starting result). * - * Please set the value to [ListProfilesResponse.next_page_token][google.cloud.talent.v4beta1.ListProfilesResponse.next_page_token] to + * Please set the value to {@link google.cloud.talent.v4beta1.ListProfilesResponse.next_page_token|ListProfilesResponse.next_page_token} to * continue the list. * @param {number} request.pageSize * The maximum number of profiles to be returned, at most 100. @@ -1027,6 +1058,7 @@ export class ProfileServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listProfiles(request, options, callback); } @@ -1071,7 +1103,7 @@ export class ProfileServiceClient { * @param {string} request.pageToken * The token that specifies the current offset (that is, starting result). * - * Please set the value to [ListProfilesResponse.next_page_token][google.cloud.talent.v4beta1.ListProfilesResponse.next_page_token] to + * Please set the value to {@link google.cloud.talent.v4beta1.ListProfilesResponse.next_page_token|ListProfilesResponse.next_page_token} to * continue the list. * @param {number} request.pageSize * The maximum number of profiles to be returned, at most 100. @@ -1103,6 +1135,7 @@ export class ProfileServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listProfiles.createStream( this._innerApiCalls.listProfiles as gax.GaxCall, request, @@ -1462,8 +1495,9 @@ export class ProfileServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.profileServiceStub.then(stub => { + return this.profileServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts b/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts index 926ee5ec13b..031e98e7133 100644 --- a/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts @@ -44,8 +44,13 @@ export class TenantServiceClient { 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; - tenantServiceStub: Promise<{[name: string]: Function}>; + tenantServiceStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of TenantServiceClient. @@ -69,8 +74,6 @@ export class TenantServiceClient { * 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. */ @@ -100,25 +103,28 @@ export class TenantServiceClient { // 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 TenantServiceClient).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 TenantServiceClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -142,25 +148,25 @@ export class TenantServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - applicationPathTemplate: new gaxModule.PathTemplate( + applicationPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}' ), - profilePathTemplate: new gaxModule.PathTemplate( + profilePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/profiles/{profile}' ), - projectCompanyPathTemplate: new gaxModule.PathTemplate( + projectCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/companies/{company}' ), - projectJobPathTemplate: new gaxModule.PathTemplate( + projectJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/jobs/{job}' ), - projectTenantCompanyPathTemplate: new gaxModule.PathTemplate( + projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/companies/{company}' ), - projectTenantJobPathTemplate: new gaxModule.PathTemplate( + projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}/jobs/{job}' ), - tenantPathTemplate: new gaxModule.PathTemplate( + tenantPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/tenants/{tenant}' ), }; @@ -169,7 +175,7 @@ export class TenantServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listTenants: new gaxModule.PageDescriptor( + listTenants: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'tenants' @@ -177,7 +183,7 @@ export class TenantServiceClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.talent.v4beta1.TenantService', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -188,17 +194,35 @@ export class TenantServiceClient { // 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.tenantServiceStub) { + return this.tenantServiceStub; + } // Put together the "service stub" for // google.cloud.talent.v4beta1.TenantService. - this.tenantServiceStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.tenantServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.cloud.talent.v4beta1.TenantService' ) : // tslint:disable-next-line no-any - (protos as any).google.cloud.talent.v4beta1.TenantService, - opts + (this._protos as any).google.cloud.talent.v4beta1.TenantService, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -224,9 +248,9 @@ export class TenantServiceClient { } ); - 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] @@ -240,6 +264,8 @@ export class TenantServiceClient { return apiCall(argument, callOptions, callback); }; } + + return this.tenantServiceStub; } /** @@ -370,6 +396,7 @@ export class TenantServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createTenant(request, options, callback); } getTenant( @@ -444,6 +471,7 @@ export class TenantServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getTenant(request, options, callback); } updateTenant( @@ -475,11 +503,11 @@ export class TenantServiceClient { * @param {google.protobuf.FieldMask} request.updateMask * Strongly recommended for the best service experience. * - * If [update_mask][google.cloud.talent.v4beta1.UpdateTenantRequest.update_mask] is provided, only the specified fields in - * [tenant][google.cloud.talent.v4beta1.UpdateTenantRequest.tenant] are updated. Otherwise all the fields are updated. + * If {@link google.cloud.talent.v4beta1.UpdateTenantRequest.update_mask|update_mask} is provided, only the specified fields in + * {@link google.cloud.talent.v4beta1.UpdateTenantRequest.tenant|tenant} are updated. Otherwise all the fields are updated. * * A field mask to specify the tenant fields to be updated. Only - * top level fields of [Tenant][google.cloud.talent.v4beta1.Tenant] are supported. + * top level fields of {@link google.cloud.talent.v4beta1.Tenant|Tenant} are supported. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -524,6 +552,7 @@ export class TenantServiceClient { ] = gax.routingHeader.fromParams({ 'tenant.name': request.tenant!.name || '', }); + this.initialize(); return this._innerApiCalls.updateTenant(request, options, callback); } deleteTenant( @@ -599,6 +628,7 @@ export class TenantServiceClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteTenant(request, options, callback); } @@ -691,6 +721,7 @@ export class TenantServiceClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listTenants(request, options, callback); } @@ -738,6 +769,7 @@ export class TenantServiceClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listTenants.createStream( this._innerApiCalls.listTenants as gax.GaxCall, request, @@ -1097,8 +1129,9 @@ export class TenantServiceClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.tenantServiceStub.then(stub => { + return this.tenantServiceStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-talent/synth.metadata b/packages/google-cloud-talent/synth.metadata index 625f8d18f6c..bb889efa578 100644 --- a/packages/google-cloud-talent/synth.metadata +++ b/packages/google-cloud-talent/synth.metadata @@ -1,13 +1,13 @@ { - "updateTime": "2020-02-29T12:45:30.182209Z", + "updateTime": "2020-03-05T23:17:01.870823Z", "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\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-talent/test/gapic-application_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-application_service-v4beta1.ts index e11c85d9fa1..ee5679c78f6 100644 --- a/packages/google-cloud-talent/test/gapic-application_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-application_service-v4beta1.ts @@ -85,6 +85,26 @@ describe('v4beta1.ApplicationServiceClient', () => { ); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new applicationserviceModule.v4beta1.ApplicationServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.applicationServiceStub, undefined); + await client.initialize(); + assert(client.applicationServiceStub); + }); + it('has close method', () => { + const client = new applicationserviceModule.v4beta1.ApplicationServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); describe('createApplication', () => { it('invokes createApplication without error', done => { const client = new applicationserviceModule.v4beta1.ApplicationServiceClient( @@ -93,6 +113,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateApplicationRequest = {}; request.parent = ''; @@ -118,6 +140,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateApplicationRequest = {}; request.parent = ''; @@ -145,6 +169,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetApplicationRequest = {}; request.name = ''; @@ -170,6 +196,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetApplicationRequest = {}; request.name = ''; @@ -197,6 +225,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateApplicationRequest = {}; request.application = {}; @@ -223,6 +253,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateApplicationRequest = {}; request.application = {}; @@ -251,6 +283,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteApplicationRequest = {}; request.name = ''; @@ -276,6 +310,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteApplicationRequest = {}; request.name = ''; @@ -303,6 +339,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListApplicationsRequest = {}; request.parent = ''; @@ -332,6 +370,8 @@ describe('v4beta1.ApplicationServiceClient', () => { projectId: 'bogus', } ); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListApplicationsRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-company_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-company_service-v4beta1.ts index 2d10d0ff895..46e25b6d480 100644 --- a/packages/google-cloud-talent/test/gapic-company_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-company_service-v4beta1.ts @@ -83,12 +83,30 @@ describe('v4beta1.CompanyServiceClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.companyServiceStub, undefined); + await client.initialize(); + assert(client.companyServiceStub); + }); + it('has close method', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createCompany', () => { it('invokes createCompany without error', done => { const client = new companyserviceModule.v4beta1.CompanyServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateCompanyRequest = {}; request.parent = ''; @@ -112,6 +130,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateCompanyRequest = {}; request.parent = ''; @@ -137,6 +157,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetCompanyRequest = {}; request.name = ''; @@ -160,6 +182,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetCompanyRequest = {}; request.name = ''; @@ -185,6 +209,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateCompanyRequest = {}; request.company = {}; @@ -209,6 +235,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateCompanyRequest = {}; request.company = {}; @@ -235,6 +263,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteCompanyRequest = {}; request.name = ''; @@ -258,6 +288,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteCompanyRequest = {}; request.name = ''; @@ -283,6 +315,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListCompaniesRequest = {}; request.parent = ''; @@ -310,6 +344,8 @@ describe('v4beta1.CompanyServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListCompaniesRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-completion-v4beta1.ts b/packages/google-cloud-talent/test/gapic-completion-v4beta1.ts index d1824696871..36764d3b495 100644 --- a/packages/google-cloud-talent/test/gapic-completion-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-completion-v4beta1.ts @@ -81,12 +81,30 @@ describe('v4beta1.CompletionClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionStub, undefined); + await client.initialize(); + assert(client.completionStub); + }); + it('has close method', () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('completeQuery', () => { it('invokes completeQuery without error', done => { const client = new completionModule.v4beta1.CompletionClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICompleteQueryRequest = {}; request.parent = ''; @@ -110,6 +128,8 @@ describe('v4beta1.CompletionClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICompleteQueryRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-event_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-event_service-v4beta1.ts index f0f141a4245..b2addea605a 100644 --- a/packages/google-cloud-talent/test/gapic-event_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-event_service-v4beta1.ts @@ -83,12 +83,30 @@ describe('v4beta1.EventServiceClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.eventServiceStub, undefined); + await client.initialize(); + assert(client.eventServiceStub); + }); + it('has close method', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createClientEvent', () => { it('invokes createClientEvent without error', done => { const client = new eventserviceModule.v4beta1.EventServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateClientEventRequest = {}; request.parent = ''; @@ -112,6 +130,8 @@ describe('v4beta1.EventServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateClientEventRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-job_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-job_service-v4beta1.ts index b823311cf66..e40327a1ff8 100644 --- a/packages/google-cloud-talent/test/gapic-job_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-job_service-v4beta1.ts @@ -102,12 +102,30 @@ describe('v4beta1.JobServiceClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.jobServiceStub, undefined); + await client.initialize(); + assert(client.jobServiceStub); + }); + it('has close method', () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createJob', () => { it('invokes createJob without error', done => { const client = new jobserviceModule.v4beta1.JobServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateJobRequest = {}; request.parent = ''; @@ -131,6 +149,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateJobRequest = {}; request.parent = ''; @@ -156,6 +176,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetJobRequest = {}; request.name = ''; @@ -179,6 +201,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetJobRequest = {}; request.name = ''; @@ -200,6 +224,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateJobRequest = {}; request.job = {}; @@ -224,6 +250,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateJobRequest = {}; request.job = {}; @@ -250,6 +278,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteJobRequest = {}; request.name = ''; @@ -273,6 +303,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteJobRequest = {}; request.name = ''; @@ -298,6 +330,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest = {}; request.parent = ''; @@ -321,6 +355,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest = {}; request.parent = ''; @@ -346,6 +382,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchJobsRequest = {}; request.parent = ''; @@ -369,6 +407,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchJobsRequest = {}; request.parent = ''; @@ -394,6 +434,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchCreateJobsRequest = {}; request.parent = ''; @@ -424,6 +466,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchCreateJobsRequest = {}; request.parent = ''; @@ -457,6 +501,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest = {}; request.parent = ''; @@ -487,6 +533,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest = {}; request.parent = ''; @@ -520,6 +568,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListJobsRequest = {}; request.parent = ''; @@ -547,6 +597,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListJobsRequest = {}; request.parent = ''; @@ -579,6 +631,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchJobsRequest = {}; request.parent = ''; @@ -606,6 +660,8 @@ describe('v4beta1.JobServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchJobsRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-profile_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-profile_service-v4beta1.ts index 0fa46de23e4..fe524e90d50 100644 --- a/packages/google-cloud-talent/test/gapic-profile_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-profile_service-v4beta1.ts @@ -83,12 +83,30 @@ describe('v4beta1.ProfileServiceClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new profileserviceModule.v4beta1.ProfileServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.profileServiceStub, undefined); + await client.initialize(); + assert(client.profileServiceStub); + }); + it('has close method', () => { + const client = new profileserviceModule.v4beta1.ProfileServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createProfile', () => { it('invokes createProfile without error', done => { const client = new profileserviceModule.v4beta1.ProfileServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateProfileRequest = {}; request.parent = ''; @@ -112,6 +130,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateProfileRequest = {}; request.parent = ''; @@ -137,6 +157,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetProfileRequest = {}; request.name = ''; @@ -160,6 +182,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetProfileRequest = {}; request.name = ''; @@ -185,6 +209,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateProfileRequest = {}; request.profile = {}; @@ -209,6 +235,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateProfileRequest = {}; request.profile = {}; @@ -235,6 +263,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteProfileRequest = {}; request.name = ''; @@ -258,6 +288,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteProfileRequest = {}; request.name = ''; @@ -283,6 +315,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchProfilesRequest = {}; request.parent = ''; @@ -306,6 +340,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ISearchProfilesRequest = {}; request.parent = ''; @@ -331,6 +367,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListProfilesRequest = {}; request.parent = ''; @@ -358,6 +396,8 @@ describe('v4beta1.ProfileServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListProfilesRequest = {}; request.parent = ''; diff --git a/packages/google-cloud-talent/test/gapic-tenant_service-v4beta1.ts b/packages/google-cloud-talent/test/gapic-tenant_service-v4beta1.ts index 51fafa6b3b8..77fab354453 100644 --- a/packages/google-cloud-talent/test/gapic-tenant_service-v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic-tenant_service-v4beta1.ts @@ -83,12 +83,30 @@ describe('v4beta1.TenantServiceClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tenantServiceStub, undefined); + await client.initialize(); + assert(client.tenantServiceStub); + }); + it('has close method', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('createTenant', () => { it('invokes createTenant without error', done => { const client = new tenantserviceModule.v4beta1.TenantServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateTenantRequest = {}; request.parent = ''; @@ -112,6 +130,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.ICreateTenantRequest = {}; request.parent = ''; @@ -137,6 +157,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetTenantRequest = {}; request.name = ''; @@ -160,6 +182,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IGetTenantRequest = {}; request.name = ''; @@ -185,6 +209,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateTenantRequest = {}; request.tenant = {}; @@ -209,6 +235,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IUpdateTenantRequest = {}; request.tenant = {}; @@ -235,6 +263,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteTenantRequest = {}; request.name = ''; @@ -258,6 +288,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IDeleteTenantRequest = {}; request.name = ''; @@ -283,6 +315,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListTenantsRequest = {}; request.parent = ''; @@ -310,6 +344,8 @@ describe('v4beta1.TenantServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.cloud.talent.v4beta1.IListTenantsRequest = {}; request.parent = '';