diff --git a/talent/package.json b/talent/package.json index 743b01d6b9..0f35f1dcb5 100644 --- a/talent/package.json +++ b/talent/package.json @@ -12,13 +12,19 @@ "*.js" ], "scripts": { - "test": "mocha --timeout 600000" + "test": "mocha --timeout 600000", + "lint": "eslint src --ext .ts", + "lint:fix": "npm run lint -- --fix" }, "dependencies": { - "@google-cloud/talent": "^3.0.0" + "@google-cloud/talent": "^3.0.0", + "uuid": "^8.3.1", + "yargs": "^16.0.3" }, "devDependencies": { + "@types/mocha": "^8.0.0", + "@types/node": "^12.0.0", "chai": "^4.2.0", - "mocha": "^8.0.0" + "mocha": "^8.1.3" } } diff --git a/talent/snippet/job_search_autocomplete_job_title.js b/talent/snippet/job_search_autocomplete_job_title.js new file mode 100644 index 0000000000..04767653f8 --- /dev/null +++ b/talent/snippet/job_search_autocomplete_job_title.js @@ -0,0 +1,94 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_autocomplete_job_title] + +const talent = require('@google-cloud/talent').v4; + +/** + * Complete job title given partial text (autocomplete) + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the TenantId + */ +function sampleCompleteQuery( + projectId, + tenantId, + query, + numResults, + languageCode +) { + const client = new talent.CompletionClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const query = '[partially typed job title]'; + // const numResults = 5; + // const languageCode = 'en-US'; + const formattedParent = client.tenantPath(projectId, tenantId); + const languageCodes = [languageCode]; + const request = { + parent: formattedParent, + query: query, + pageSize: numResults, + languageCodes: languageCodes, + }; + client + .completeQuery(request) + .then(responses => { + const response = responses[0]; + for (const result of response.completionResults) { + console.log(`Suggested title: ${result.suggestion}`); + // Suggestion type is JOB_TITLE or COMPANY_TITLE + console.log(`Suggestion type: ${result.type}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_autocomplete_job_title] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('query', { + default: '[partially typed job title]', + string: true, + }) + .option('num_results', { + default: 5, + number: true, + }) + .option('language_code', { + default: 'en-US', + string: true, + }).argv; + +sampleCompleteQuery( + argv.project_id, + argv.tenant_id, + argv.query, + argv.num_results, + argv.language_code +); diff --git a/talent/snippet/job_search_batch_delete_job.js b/talent/snippet/job_search_batch_delete_job.js new file mode 100644 index 0000000000..e64dc216fb --- /dev/null +++ b/talent/snippet/job_search_batch_delete_job.js @@ -0,0 +1,63 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_batch_delete_job] + +const talent = require('@google-cloud/talent').v4; + +/** + * Batch delete jobs using a filter + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenantd + * @param filter {string} The filter string specifies the jobs to be deleted. + * For example: + * companyName = "projects/api-test-project/companies/123" AND equisitionId = "req-1" + */ +function sampleBatchDeleteJobs(projectId, tenantId, filter) { + const client = new talent.JobServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const filter = '[Query]'; + const formattedParent = client.tenantPath(projectId, tenantId); + const request = { + parent: formattedParent, + filter: filter, + }; + client.batchDeleteJobs(request).catch(err => { + console.error(err); + }); + console.log('Batch deleted jobs from filter'); +} + +// [END job_search_batch_delete_job] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('filter', { + default: '[Query]', + string: true, + }).argv; + +sampleBatchDeleteJobs(argv.project_id, argv.tenant_id, argv.filter); diff --git a/talent/snippet/job_search_commute_search.js b/talent/snippet/job_search_commute_search.js new file mode 100644 index 0000000000..e8da1eef67 --- /dev/null +++ b/talent/snippet/job_search_commute_search.js @@ -0,0 +1,91 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_commute_search] + +const talent = require('@google-cloud/talent').v4; + +/** Search Jobs using commute distance */ +function sampleSearchJobs(projectId, tenantId) { + const client = new talent.JobServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + const formattedParent = client.tenantPath(projectId, tenantId); + const domain = 'www.example.com'; + const sessionId = 'Hashed session identifier'; + const userId = 'Hashed user identifier'; + const requestMetadata = { + domain: domain, + sessionId: sessionId, + userId: userId, + }; + const commuteMethod = 'TRANSIT'; + const seconds = 1800; + const travelDuration = { + seconds: seconds, + }; + const latitude = 37.422408; + const longitude = 122.084068; + const startCoordinates = { + latitude: latitude, + longitude: longitude, + }; + const commuteFilter = { + commuteMethod: commuteMethod, + travelDuration: travelDuration, + startCoordinates: startCoordinates, + }; + const jobQuery = { + commuteFilter: commuteFilter, + }; + const request = { + parent: formattedParent, + requestMetadata: requestMetadata, + jobQuery: jobQuery, + }; + + client + .searchJobs(request) + .then(responses => { + const resources = responses[0]; + for (const resource of resources) { + console.log(`Job summary: ${resource.jobSummary}`); + console.log(`Job title snippet: ${resource.jobTitleSnippet}`); + const job = resource.job; + console.log(`Job name: ${job.name}`); + console.log(`Job title: ${job.title}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_commute_search] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }).argv; + +sampleSearchJobs(argv.project_id, argv.tenant_id); diff --git a/talent/snippet/job_search_create_client_event.js b/talent/snippet/job_search_create_client_event.js new file mode 100644 index 0000000000..53d8af0b01 --- /dev/null +++ b/talent/snippet/job_search_create_client_event.js @@ -0,0 +1,106 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_create_client_event] + +const talent = require('@google-cloud/talent').v4; + +/** + * Creates a client event + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenant + * @param requestId {string} A unique ID generated in the API responses. + * Value should be set to the request_id from an API response. + * @param eventId {string} A unique identifier, generated by the client application + */ +function sampleCreateClientEvent(projectId, tenantId, requestId, eventId) { + const client = new talent.EventServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const requestId = '[request_id from ResponseMetadata]'; + // const eventId = '[Set this to a unique identifier]'; + const formattedParent = client.tenantPath(projectId, tenantId); + + // The timestamp of the event as seconds of UTC time since Unix epoch + // For more information on how to create google.protobuf.Timestamps + // See: https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto + const seconds = 0; + const createTime = { + seconds: seconds, + }; + + // The type of event attributed to the behavior of the end user + const type = 'VIEW'; + + // List of job names associated with this event + const jobsElement = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]'; + const jobsElement2 = + 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]'; + const jobs = [jobsElement, jobsElement2]; + const jobEvent = { + type: type, + jobs: jobs, + }; + const clientEvent = { + requestId: requestId, + eventId: eventId, + createTime: createTime, + jobEvent: jobEvent, + }; + const request = { + parent: formattedParent, + clientEvent: clientEvent, + }; + client + .createClientEvent(request) + .then(responses => { + const response = responses[0]; + console.log('Created client event'); + console.log(`Response: ${response}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_create_client_event] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('request_id', { + default: '[request_id from ResponseMetadata]', + string: true, + }) + .option('event_id', { + default: '[Set this to a unique identifier]', + string: true, + }).argv; + +sampleCreateClientEvent( + argv.project_id, + argv.tenant_id, + argv.request_id, + argv.event_id +); diff --git a/talent/snippet/job_search_create_company.js b/talent/snippet/job_search_create_company.js new file mode 100644 index 0000000000..00ed4274ce --- /dev/null +++ b/talent/snippet/job_search_create_company.js @@ -0,0 +1,82 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_create_company] + +const talent = require('@google-cloud/talent').v4; + +/** + * Create Company + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenant + */ +function sampleCreateCompany(projectId, tenantId, displayName, externalId) { + const client = new talent.CompanyServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const displayName = 'My Company Name'; + // const externalId = 'Identifier of this company in my system'; + const formattedParent = client.tenantPath(projectId, tenantId); + const company = { + displayName: displayName, + externalId: externalId, + }; + const request = { + parent: formattedParent, + company: company, + }; + client + .createCompany(request) + .then(responses => { + const response = responses[0]; + console.log('Created Company'); + console.log(`Name: ${response.name}`); + console.log(`Display Name: ${response.displayName}`); + console.log(`External ID: ${response.externalId}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_create_company] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('display_name', { + default: 'My Company Name', + string: true, + }) + .option('external_id', { + default: 'Identifier of this company in my system', + string: true, + }).argv; + +sampleCreateCompany( + argv.project_id, + argv.tenant_id, + argv.display_name, + argv.external_id +); diff --git a/talent/snippet/job_search_create_job.js b/talent/snippet/job_search_create_job.js new file mode 100644 index 0000000000..8d1f1bf815 --- /dev/null +++ b/talent/snippet/job_search_create_job.js @@ -0,0 +1,136 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_create_job] + +const talent = require('@google-cloud/talent').v4; + +/** + * Create Job + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenant + */ +function sampleCreateJob( + projectId, + tenantId, + companyName, + requisitionId, + title, + description, + jobApplicationUrl, + addressOne, + addressTwo, + languageCode +) { + const client = new talent.JobServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const companyName = 'Company name, e.g. projects/your-project/companies/company-id'; + // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.'; + // const title = 'Software Engineer'; + // const description = 'This is a description of this wonderful job!'; + // const jobApplicationUrl = 'https://www.example.org/job-posting/123'; + // const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043'; + // const addressTwo = '111 8th Avenue, New York, NY 10011'; + // const languageCode = 'en-US'; + const formattedParent = client.tenantPath(projectId, tenantId); + const uris = [jobApplicationUrl]; + const applicationInfo = { + uris: uris, + }; + const addresses = [addressOne, addressTwo]; + const job = { + company: companyName, + requisitionId: requisitionId, + title: title, + description: description, + applicationInfo: applicationInfo, + addresses: addresses, + languageCode: languageCode, + }; + const request = { + parent: formattedParent, + job: job, + }; + client + .createJob(request) + .then(responses => { + const response = responses[0]; + console.log(`Created job: ${response.name}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_create_job] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('company_name', { + default: 'Company name, e.g. projects/your-project/companies/company-id', + string: true, + }) + .option('requisition_id', { + default: 'Job requisition ID, aka Posting ID. Unique per job.', + string: true, + }) + .option('title', { + default: 'Software Engineer', + string: true, + }) + .option('description', { + default: 'This is a description of this wonderful job!', + string: true, + }) + .option('job_application_url', { + default: 'https://www.example.org/job-posting/123', + string: true, + }) + .option('address_one', { + default: '1600 Amphitheatre Parkway, Mountain View, CA 94043', + string: true, + }) + .option('address_two', { + default: '111 8th Avenue, New York, NY 10011', + string: true, + }) + .option('language_code', { + default: 'en-US', + string: true, + }).argv; + +sampleCreateJob( + argv.project_id, + argv.tenant_id, + argv.company_name, + argv.requisition_id, + argv.title, + argv.description, + argv.job_application_url, + argv.address_one, + argv.address_two, + argv.language_code +); diff --git a/talent/snippet/job_search_create_job_custom_attributes.js b/talent/snippet/job_search_create_job_custom_attributes.js new file mode 100644 index 0000000000..00b9bbab79 --- /dev/null +++ b/talent/snippet/job_search_create_job_custom_attributes.js @@ -0,0 +1,92 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_create_job_custom_attributes] + +const talent = require('@google-cloud/talent').v4; + +/** + * Create Job with Custom Attributes + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenantd + */ +function sampleCreateJob( + projectId, + tenantId, + companyName, + requisitionId, + languageCode +) { + const client = new talent.JobServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const companyName = 'Company name, e.g. projects/your-project/companies/company-id'; + // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.'; + // const languageCode = 'en-US'; + const formattedParent = client.tenantPath(projectId, tenantId); + const job = { + company: companyName, + requisitionId: requisitionId, + languageCode: languageCode, + }; + const request = { + parent: formattedParent, + job: job, + }; + client + .createJob(request) + .then(responses => { + const response = responses[0]; + console.log(`Created job: ${response.name}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_create_job_custom_attributes] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('company_name', { + default: 'Company name, e.g. projects/your-project/companies/company-id', + string: true, + }) + .option('requisition_id', { + default: 'Job requisition ID, aka Posting ID. Unique per job.', + string: true, + }) + .option('language_code', { + default: 'en-US', + string: true, + }).argv; + +sampleCreateJob( + argv.project_id, + argv.tenant_id, + argv.company_name, + argv.requisition_id, + argv.language_code +); diff --git a/talent/snippet/job_search_create_tenant.js b/talent/snippet/job_search_create_tenant.js new file mode 100644 index 0000000000..bfc3b5671d --- /dev/null +++ b/talent/snippet/job_search_create_tenant.js @@ -0,0 +1,60 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_create_tenant] + +const talent = require('@google-cloud/talent').v4; + +/** Create Tenant for scoping resources, e.g. companies and jobs */ +function sampleCreateTenant(projectId, externalId) { + const client = new talent.TenantServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const externalId = 'Your Unique Identifier for Tenant'; + const formattedParent = client.projectPath(projectId); + const tenant = { + externalId: externalId, + }; + const request = { + parent: formattedParent, + tenant: tenant, + }; + client + .createTenant(request) + .then(responses => { + const response = responses[0]; + console.log('Created Tenant'); + console.log(`Name: ${response.name}`); + console.log(`External ID: ${response.externalId}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_create_tenant] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('external_id', { + default: 'Your Unique Identifier for Tenant', + string: true, + }).argv; + +sampleCreateTenant(argv.project_id, argv.external_id); diff --git a/talent/snippet/job_search_custom_ranking_search.js b/talent/snippet/job_search_custom_ranking_search.js new file mode 100644 index 0000000000..136dc5911a --- /dev/null +++ b/talent/snippet/job_search_custom_ranking_search.js @@ -0,0 +1,85 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_custom_ranking_search] + +const talent = require('@google-cloud/talent').v4; + +/** + * Search Jobs using custom rankings + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenantd + */ +function sampleSearchJobs(projectId, tenantId) { + const client = new talent.JobServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + const formattedParent = client.tenantPath(projectId, tenantId); + const domain = 'www.example.com'; + const sessionId = 'Hashed session identifier'; + const userId = 'Hashed user identifier'; + const requestMetadata = { + domain: domain, + sessionId: sessionId, + userId: userId, + }; + const importanceLevel = 'EXTREME'; + const rankingExpression = '(someFieldLong + 25) * 0.25'; + const customRankingInfo = { + importanceLevel: importanceLevel, + rankingExpression: rankingExpression, + }; + const orderBy = 'custom_ranking desc'; + const request = { + parent: formattedParent, + requestMetadata: requestMetadata, + customRankingInfo: customRankingInfo, + orderBy: orderBy, + }; + + client + .searchJobs(request) + .then(responses => { + const resources = responses[0]; + for (const resource of resources.matchingJobs) { + console.log(`Job summary: ${resource.jobSummary}`); + console.log(`Job title snippet: ${resource.jobTitleSnippet}`); + const job = resource.job; + console.log(`Job name: ${job.name}`); + console.log(`Job title: ${job.title}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_custom_ranking_search] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }).argv; + +sampleSearchJobs(argv.project_id, argv.tenant_id); diff --git a/talent/snippet/job_search_delete_company.js b/talent/snippet/job_search_delete_company.js new file mode 100644 index 0000000000..96ed877355 --- /dev/null +++ b/talent/snippet/job_search_delete_company.js @@ -0,0 +1,51 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_delete_company] + +const talent = require('@google-cloud/talent').v4; + +/** Delete Company */ +function sampleDeleteCompany(projectId, tenantId, companyId) { + const client = new talent.CompanyServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const companyId = 'ID of the company to delete'; + const formattedName = client.companyPath(projectId, tenantId, companyId); + client.deleteCompany({name: formattedName}).catch(err => { + console.error(err); + }); + console.log('Deleted company'); +} + +// [END job_search_delete_company] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('company_id', { + default: 'ID of the company to delete', + string: true, + }).argv; + +sampleDeleteCompany(argv.project_id, argv.tenant_id, argv.company_id); diff --git a/talent/snippet/job_search_delete_job.js b/talent/snippet/job_search_delete_job.js new file mode 100644 index 0000000000..37ffc1a269 --- /dev/null +++ b/talent/snippet/job_search_delete_job.js @@ -0,0 +1,51 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_delete_job] + +const talent = require('@google-cloud/talent').v4; + +/** Delete Job */ +function sampleDeleteJob(projectId, tenantId, jobId) { + const client = new talent.JobServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const jobId = 'Company ID'; + const formattedName = client.jobPath(projectId, tenantId, jobId); + client.deleteJob({name: formattedName}).catch(err => { + console.error(err); + }); + console.log('Deleted job.'); +} + +// [END job_search_delete_job] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('job_id', { + default: 'Company ID', + string: true, + }).argv; + +sampleDeleteJob(argv.project_id, argv.tenant_id, argv.job_id); diff --git a/talent/snippet/job_search_delete_tenant.js b/talent/snippet/job_search_delete_tenant.js new file mode 100644 index 0000000000..dc1921e851 --- /dev/null +++ b/talent/snippet/job_search_delete_tenant.js @@ -0,0 +1,46 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_delete_tenant] + +const talent = require('@google-cloud/talent').v4; + +/** Delete Tenant */ +function sampleDeleteTenant(projectId, tenantId) { + const client = new talent.TenantServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID)'; + const formattedName = client.tenantPath(projectId, tenantId); + client.deleteTenant({name: formattedName}).catch(err => { + console.error(err); + }); + console.log('Deleted Tenant.'); +} + +// [END job_search_delete_tenant] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID)', + string: true, + }).argv; + +sampleDeleteTenant(argv.project_id, argv.tenant_id); diff --git a/talent/snippet/job_search_get_company.js b/talent/snippet/job_search_get_company.js new file mode 100644 index 0000000000..12c22a0b57 --- /dev/null +++ b/talent/snippet/job_search_get_company.js @@ -0,0 +1,57 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_get_company] + +const talent = require('@google-cloud/talent').v4; + +/** Get Company */ +function sampleGetCompany(projectId, tenantId, companyId) { + const client = new talent.CompanyServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const companyId = 'Company ID'; + const formattedName = client.companyPath(projectId, tenantId, companyId); + client + .getCompany({name: formattedName}) + .then(responses => { + const response = responses[0]; + console.log(`Company name: ${response.name}`); + console.log(`Display name: ${response.displayName}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_get_company] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('company_id', { + default: 'Company ID', + string: true, + }).argv; + +sampleGetCompany(argv.project_id, argv.tenant_id, argv.company_id); diff --git a/talent/snippet/job_search_get_job.js b/talent/snippet/job_search_get_job.js new file mode 100644 index 0000000000..c49de33920 --- /dev/null +++ b/talent/snippet/job_search_get_job.js @@ -0,0 +1,69 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_get_job] + +const talent = require('@google-cloud/talent').v4; + +/** Get Job */ +function sampleGetJob(projectId, tenantId, jobId) { + const client = new talent.JobServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const jobId = 'Job ID'; + const formattedName = client.jobPath(projectId, tenantId, jobId); + client + .getJob({name: formattedName}) + .then(responses => { + const response = responses[0]; + console.log(`Job name: ${response.name}`); + console.log(`Requisition ID: ${response.requisitionId}`); + console.log(`Title: ${response.title}`); + console.log(`Description: ${response.description}`); + console.log(`Posting language: ${response.languageCode}`); + for (const address of response.addresses) { + console.log(`Address: ${address}`); + } + for (const email of response.applicationInfo.emails) { + console.log(`Email: ${email}`); + } + for (const websiteUri of response.applicationInfo.uris) { + console.log(`Website: ${websiteUri}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_get_job] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('job_id', { + default: 'Job ID', + string: true, + }).argv; + +sampleGetJob(argv.project_id, argv.tenant_id, argv.job_id); diff --git a/talent/snippet/job_search_get_tenant.js b/talent/snippet/job_search_get_tenant.js new file mode 100644 index 0000000000..ed76917c6b --- /dev/null +++ b/talent/snippet/job_search_get_tenant.js @@ -0,0 +1,52 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_get_tenant] + +const talent = require('@google-cloud/talent').v4; + +/** Get Tenant by name */ +function sampleGetTenant(projectId, tenantId) { + const client = new talent.TenantServiceClient(); + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID'; + const formattedName = client.tenantPath(projectId, tenantId); + client + .getTenant({name: formattedName}) + .then(responses => { + const response = responses[0]; + console.log(`Name: ${response.name}`); + console.log(`External ID: ${response.externalId}`); + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_get_tenant] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID', + string: true, + }).argv; + +sampleGetTenant(argv.project_id, argv.tenant_id); diff --git a/talent/snippet/job_search_histogram_search.js b/talent/snippet/job_search_histogram_search.js new file mode 100644 index 0000000000..69282fccdb --- /dev/null +++ b/talent/snippet/job_search_histogram_search.js @@ -0,0 +1,87 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_histogram_search] + +const talent = require('@google-cloud/talent').v4; + +/** + * Search Jobs with histogram queries + * + * @param query {string} Histogram query + * More info on histogram facets, constants, and built-in functions: + * https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest + */ +function sampleSearchJobs(projectId, tenantId, query) { + const client = new talent.JobServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const query = 'count(base_compensation, [bucket(12, 20)])'; + const formattedParent = client.tenantPath(projectId, tenantId); + const domain = 'www.example.com'; + const sessionId = 'Hashed session identifier'; + const userId = 'Hashed user identifier'; + const requestMetadata = { + domain: domain, + sessionId: sessionId, + userId: userId, + }; + const histogramQueriesElement = { + histogramQuery: query, + }; + const histogramQueries = [histogramQueriesElement]; + const request = { + parent: formattedParent, + requestMetadata: requestMetadata, + histogramQueries: histogramQueries, + }; + + client + .searchJobs(request) + .then(responses => { + const resources = responses[0]; + for (const resource of resources.matchingJobs) { + console.log(`Job summary: ${resource.jobSummary}`); + console.log(`Job title snippet: ${resource.jobTitleSnippet}`); + const job = resource.job; + console.log(`Job name: ${job.name}`); + console.log(`Job title: ${job.title}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_histogram_search] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('query', { + default: 'count(base_compensation, [bucket(12, 20)])', + string: true, + }).argv; + +sampleSearchJobs(argv.project_id, argv.tenant_id, argv.query); diff --git a/talent/snippet/job_search_list_companies.js b/talent/snippet/job_search_list_companies.js new file mode 100644 index 0000000000..96cc6ffcef --- /dev/null +++ b/talent/snippet/job_search_list_companies.js @@ -0,0 +1,62 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_list_companies] + +const talent = require('@google-cloud/talent').v4; + +/** + * List Companies + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenant + */ +function sampleListCompanies(projectId, tenantId) { + const client = new talent.CompanyServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + const formattedParent = client.tenantPath(projectId, tenantId); + + client + .listCompanies({parent: formattedParent}) + .then(responses => { + const resources = responses[0]; + for (const resource of resources) { + console.log(`Company Name: ${resource.name}`); + console.log(`Display Name: ${resource.displayName}`); + console.log(`External ID: ${resource.externalId}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_list_companies] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }).argv; + +sampleListCompanies(argv.project_id, argv.tenant_id); diff --git a/talent/snippet/job_search_list_jobs.js b/talent/snippet/job_search_list_jobs.js new file mode 100644 index 0000000000..62d08f309c --- /dev/null +++ b/talent/snippet/job_search_list_jobs.js @@ -0,0 +1,72 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_list_jobs] + +const talent = require('@google-cloud/talent').v4; + +/** + * List Jobs + * + * @param projectId {string} Your Google Cloud Project ID + * @param tenantId {string} Identifier of the Tenant + */ +function sampleListJobs(projectId, tenantId, filter) { + const client = new talent.JobServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + // const tenantId = 'Your Tenant ID (using tenancy is optional)'; + // const filter = 'companyName=projects/my-project/companies/company-id'; + const formattedParent = client.tenantPath(projectId, tenantId); + const request = { + parent: formattedParent, + filter: filter, + }; + + client + .listJobs(request) + .then(responses => { + const resources = responses[0]; + for (const resource of resources) { + console.log(`Job name: ${resource.name}`); + console.log(`Job requisition ID: ${resource.requisitionId}`); + console.log(`Job title: ${resource.title}`); + console.log(`Job description: ${resource.description}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_list_jobs] +// tslint:disable-next-line:no-any + +const argv = require('yargs') + .option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, + }) + .option('tenant_id', { + default: 'Your Tenant ID (using tenancy is optional)', + string: true, + }) + .option('filter', { + default: 'companyName=projects/my-project/companies/company-id', + string: true, + }).argv; + +sampleListJobs(argv.project_id, argv.tenant_id, argv.filter); diff --git a/talent/snippet/job_search_list_tenants.js b/talent/snippet/job_search_list_tenants.js new file mode 100644 index 0000000000..aba625d9d5 --- /dev/null +++ b/talent/snippet/job_search_list_tenants.js @@ -0,0 +1,50 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START job_search_list_tenants] + +const talent = require('@google-cloud/talent').v4; + +/** List Tenants */ +function sampleListTenants(projectId) { + const client = new talent.TenantServiceClient(); + // Iterate over all elements. + // const projectId = 'Your Google Cloud Project ID'; + const formattedParent = client.projectPath(projectId); + + client + .listTenants({parent: formattedParent}) + .then(responses => { + const resources = responses[0]; + for (const resource of resources) { + console.log(`Tenant Name: ${resource.name}`); + console.log(`External ID: ${resource.externalId}`); + } + }) + .catch(err => { + console.error(err); + }); +} + +// [END job_search_list_tenants] +// tslint:disable-next-line:no-any + +const argv = require('yargs').option('project_id', { + default: 'Your Google Cloud Project ID', + string: true, +}).argv; + +sampleListTenants(argv.project_id); diff --git a/talent/test/no-test.js b/talent/test/no-test.js deleted file mode 100644 index 665d93e66f..0000000000 --- a/talent/test/no-test.js +++ /dev/null @@ -1 +0,0 @@ -console.log('no test yet'); diff --git a/talent/test/talent.test.js b/talent/test/talent.test.js new file mode 100644 index 0000000000..353f129fb0 --- /dev/null +++ b/talent/test/talent.test.js @@ -0,0 +1,140 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const cp = require('child_process'); +const {v4} = require('uuid'); +const {describe, it, before, after} = require('mocha'); + +const talent = require('@google-cloud/talent').v4; +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Talent Solution Jobs API v4 samples', () => { + const projectId = process.env.GCLOUD_PROJECT; + const tenantService = new talent.TenantServiceClient(); + const companyService = new talent.CompanyServiceClient(); + const jobService = new talent.JobServiceClient(); + + let tenant; + let company; + let job; + + let tenantId; + let companyId; + let jobId; + + before(async () => { + const formattedParent = tenantService.projectPath(projectId); + + [tenant] = await tenantService.createTenant({ + parent: formattedParent, + tenant: { + externalId: `${Date.now()}-${v4()}`, + }, + }); + tenantId = tenant.name.split('/').slice(-1)[0]; + console.log(`created tenant: ${tenant.name}`); + + [company] = await companyService.createCompany({ + parent: tenant.name, + company: { + displayName: 'Google', + externalId: `${Date.now()}-${v4()}`, + }, + }); + console.log(`created company: ${company.name}`); + companyId = company.name.split('/').slice(-1)[0]; + + const applicationInfo = { + uris: ['http://test.url'], + }; + + const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043'; + const addressTwo = '111 8th Avenue, New York, NY 10011'; + + const jobRequest = { + company: company.name, + requisitionId: v4(), + title: 'Software engineer', + description: 'Nodejs engineer', + applicationInfo: applicationInfo, + addresses: [addressOne, addressTwo], + languageCode: 'en-US', + }; + + [job] = await jobService.createJob({ + parent: tenant.name, + job: jobRequest, + }); + console.log(`created job: ${job.name}`); + jobId = job.name.split('/').slice(-1)[0]; + }); + + after(async () => { + await jobService.deleteJob({name: job.name}); + await companyService.deleteCompany({name: company.name}); + await tenantService.deleteTenant({name: tenant.name}); + }); + + it('Gets a job', async () => { + console.log( + `node snippet/job_search_get_job.js --project_id=${projectId} --tenant_id=${tenantId} --job_id=${jobId}` + ); + const output = execSync( + `node snippet/job_search_get_job.js --project_id=${projectId} --tenant_id=${tenantId} --job_id=${jobId}` + ); + assert.match(output, new RegExp('Job name')); + }); + it('Gets a company', async () => { + console.log( + `node snippet/job_search_get_company.js --project_id=${projectId} --tenant_id=${tenantId} --company_id=${companyId}` + ); + const output = execSync( + `node snippet/job_search_get_company.js --project_id=${projectId} --tenant_id=${tenantId} --company_id=${companyId}` + ); + assert.match(output, new RegExp('Company name')); + }); + + it('Gets a tenant', async () => { + console.log( + `node snippet/job_search_get_tenant.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + const output = execSync( + `node snippet/job_search_get_tenant.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + assert.match(output, new RegExp('Name')); + }); + + it('Searches for a job with custom ranking search', async () => { + console.log( + `node snippet/job_search_custom_ranking_search.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + const output = execSync( + `node snippet/job_search_custom_ranking_search.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + assert.match(output, new RegExp('Job summary')); + }); + + it('Searches for a job with histogram', async () => { + console.log( + `node snippet/job_search_histogram_search.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + const output = execSync( + `node snippet/job_search_histogram_search.js --project_id=${projectId} --tenant_id=${tenantId}` + ); + assert.match(output, new RegExp('Job summary')); + }); +});