From 5d3df7ce9cf095dfce2dc351a1c38f9bbf3f4945 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Tue, 3 Jul 2018 16:39:25 -0700 Subject: [PATCH 1/7] First CJD sample --- jobs/cjd_sample/quickstart.js | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 jobs/cjd_sample/quickstart.js diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js new file mode 100644 index 0000000000..4c16afbfd9 --- /dev/null +++ b/jobs/cjd_sample/quickstart.js @@ -0,0 +1,59 @@ +/** + * Copyright 2017, Google, Inc. + * 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 + * + * http://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 quickstart] +// Imports the Google APIs client library +const {google} = require('googleapis'); + +// Acquires credentials +google.auth.getApplicationDefault((err, authClient) => { + if (err) { + console.error('Failed to acquire credentials'); + console.error(err) + return; + } + + if (authClient.createScopedRequired && authClient.createScopedRequired()) { + authClient = authClient.createScoped([ + "https://www.googleapis.com/auth/jobs" + ]); + } + + // Instantiates an authorized client + const jobs = google.jobs({ + version: 'v2', + auth: authClient + }); + + // Lists companies + jobs.companies.list((err, result) => { + if (err) { + console.error(err); + return; + } + + const companies = result.data.companies || []; + + if (companies.length) { + console.log('Companies:'); + companies.forEach((company) => console.log(company)); + } else { + console.log(`No companies found.`); + } + }); +}); +// [END quickstart] From 9f38e5d76827b7825a168905052a8ab389e389a9 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Thu, 12 Jul 2018 11:09:30 -0700 Subject: [PATCH 2/7] Add README --- jobs/cjd_sample/README.md | 44 +++++++++++++++++++++++++++++++++++ jobs/cjd_sample/quickstart.js | 6 +++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 jobs/cjd_sample/README.md mode change 100644 => 100755 jobs/cjd_sample/quickstart.js diff --git a/jobs/cjd_sample/README.md b/jobs/cjd_sample/README.md new file mode 100755 index 0000000000..bd329ba4da --- /dev/null +++ b/jobs/cjd_sample/README.md @@ -0,0 +1,44 @@ +Google Cloud Platform logo + +# Google Cloud Job Discovery API Samples + +Cloud Job Discovery is part of Google for Jobs - a Google-wide commitment to help +people find jobs more easily. Job Discovery provides plug and play access to +Google’s search and machine learning capabilities, enabling the entire recruiting +ecosystem - company career sites, job boards, applicant tracking systems, and +staffing agencies to improve job site engagement and candidate conversion. + +## Table of Contents + +* [Setup](#setup) +* [Running the tests](#running-the-tests) + +## Setup + +1. Read [Prerequisites][prereq] and [How to run a sample][run] first. +1. Install dependencies: + + With **npm**: + + npm install + + With **yarn**: + + yarn install + +[prereq]: ../README.md#prerequisites +[run]: ../README.md#how-to-run-a-sample + +## Running the tests + +1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. + +1. Run the tests: + + With **npm**: + + npm test + + With **yarn**: + + yarn test diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js old mode 100644 new mode 100755 index 4c16afbfd9..9371159492 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -23,7 +23,7 @@ const {google} = require('googleapis'); google.auth.getApplicationDefault((err, authClient) => { if (err) { console.error('Failed to acquire credentials'); - console.error(err) + console.error(err); return; } @@ -46,11 +46,13 @@ google.auth.getApplicationDefault((err, authClient) => { return; } + console.log("Request ID: " + result.data.metadata.requestId); + const companies = result.data.companies || []; if (companies.length) { console.log('Companies:'); - companies.forEach((company) => console.log(company)); + companies.forEach((company) => console.log(company.name)); } else { console.log(`No companies found.`); } From 5e89d3a3d268ad9ab48c52cfa483a62c0336ee91 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Thu, 12 Jul 2018 11:13:45 -0700 Subject: [PATCH 3/7] fix the lint issue --- jobs/cjd_sample/quickstart.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js index 9371159492..9c4009670d 100755 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -16,6 +16,7 @@ 'use strict'; // [START quickstart] + // Imports the Google APIs client library const {google} = require('googleapis'); @@ -29,7 +30,7 @@ google.auth.getApplicationDefault((err, authClient) => { if (authClient.createScopedRequired && authClient.createScopedRequired()) { authClient = authClient.createScoped([ - "https://www.googleapis.com/auth/jobs" + 'https://www.googleapis.com/auth/jobs' ]); } From 6945b24d7b7fee063582938090315ac180382cd7 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Thu, 12 Jul 2018 13:55:53 -0700 Subject: [PATCH 4/7] Add test --- jobs/cjd_sample/package.json | 31 +++++++++++++++++++ jobs/cjd_sample/quickstart.js | 2 +- .../cjd_sample/system-test/quickstart.test.js | 24 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 jobs/cjd_sample/package.json create mode 100644 jobs/cjd_sample/system-test/quickstart.test.js diff --git a/jobs/cjd_sample/package.json b/jobs/cjd_sample/package.json new file mode 100644 index 0000000000..6a88737938 --- /dev/null +++ b/jobs/cjd_sample/package.json @@ -0,0 +1,31 @@ +{ + "name": "nodejs-docs-samples-jobs", + "version": "0.0.1", + "private": true, + "license": "Apache-2.0", + "author": "Google Inc.", + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": ">=4.3.2" + }, + "scripts": { + "lint": "repo-tools lint", + "pretest": "npm run lint", + "test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js" + }, + "dependencies": { + "googleapis": "27.0.0", + "safe-buffer": "5.1.1", + "uuid": "^3.2.1", + "yargs": "11.0.0" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "2.2.5", + "ava": "0.25.0", + "proxyquire": "2.0.1", + "semistandard": "^12.0.1" + } +} diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js index 9c4009670d..4feaa84c27 100755 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -47,7 +47,7 @@ google.auth.getApplicationDefault((err, authClient) => { return; } - console.log("Request ID: " + result.data.metadata.requestId); + console.log('Request ID: ' + result.data.metadata.requestId); const companies = result.data.companies || []; diff --git a/jobs/cjd_sample/system-test/quickstart.test.js b/jobs/cjd_sample/system-test/quickstart.test.js new file mode 100644 index 0000000000..8420f860e7 --- /dev/null +++ b/jobs/cjd_sample/system-test/quickstart.test.js @@ -0,0 +1,24 @@ +/** + * Copyright 2017, Google, Inc. + * 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 + * + * http://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 test = require(`ava`); +const tools = require(`@google-cloud/nodejs-repo-tools`); + +test(`should list companies`, async t => { + const output = await tools.runAsync(`node quickstart.js`); + t.true(output.includes(`Request ID`)); +}); From 6a410374bd6ca4fadccbc3e1b51ae4ee612ea177 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Fri, 13 Jul 2018 14:05:03 -0700 Subject: [PATCH 5/7] Modify the sample --- jobs/cjd_sample/quickstart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js index 4feaa84c27..59f0ac32cf 100755 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -47,7 +47,7 @@ google.auth.getApplicationDefault((err, authClient) => { return; } - console.log('Request ID: ' + result.data.metadata.requestId); + console.log(`Request ID: ${result.data.metadata.requestId}`); const companies = result.data.companies || []; From 91318268d47eaaa0897a1b611765cfc213765a48 Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Mon, 16 Jul 2018 14:56:25 -0700 Subject: [PATCH 6/7] Modify the copyright --- jobs/cjd_sample/quickstart.js | 2 +- jobs/cjd_sample/system-test/quickstart.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js index 59f0ac32cf..8d9729a75e 100755 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2018, 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 diff --git a/jobs/cjd_sample/system-test/quickstart.test.js b/jobs/cjd_sample/system-test/quickstart.test.js index 8420f860e7..2d0b70096f 100644 --- a/jobs/cjd_sample/system-test/quickstart.test.js +++ b/jobs/cjd_sample/system-test/quickstart.test.js @@ -1,5 +1,5 @@ /** - * Copyright 2017, Google, Inc. + * Copyright 2018, 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 From c95e8d040b632e9e3d2f7a6894ba219c90c45c6a Mon Sep 17 00:00:00 2001 From: xinyunh0929 Date: Tue, 31 Jul 2018 13:51:07 -0700 Subject: [PATCH 7/7] Add v3 samples and move v2 samples to jobs/v2/ --- jobs/{cjd_sample => v2}/README.md | 6 +- jobs/{cjd_sample => v2}/package.json | 0 jobs/{cjd_sample => v2}/quickstart.js | 0 .../system-test/quickstart.test.js | 0 jobs/v3/README.md | 44 ++++++++++++ jobs/v3/package.json | 31 +++++++++ jobs/v3/quickstart.js | 67 +++++++++++++++++++ jobs/v3/system-test/quickstart.test.js | 24 +++++++ 8 files changed, 169 insertions(+), 3 deletions(-) rename jobs/{cjd_sample => v2}/README.md (82%) rename jobs/{cjd_sample => v2}/package.json (100%) rename jobs/{cjd_sample => v2}/quickstart.js (100%) rename jobs/{cjd_sample => v2}/system-test/quickstart.test.js (100%) create mode 100755 jobs/v3/README.md create mode 100644 jobs/v3/package.json create mode 100755 jobs/v3/quickstart.js create mode 100644 jobs/v3/system-test/quickstart.test.js diff --git a/jobs/cjd_sample/README.md b/jobs/v2/README.md similarity index 82% rename from jobs/cjd_sample/README.md rename to jobs/v2/README.md index bd329ba4da..26e505da65 100755 --- a/jobs/cjd_sample/README.md +++ b/jobs/v2/README.md @@ -1,9 +1,9 @@ Google Cloud Platform logo -# Google Cloud Job Discovery API Samples +# Google Cloud Talent Solution API Samples -Cloud Job Discovery is part of Google for Jobs - a Google-wide commitment to help -people find jobs more easily. Job Discovery provides plug and play access to +Cloud Talent Solution is part of Google for Jobs - a Google-wide commitment to help +people find jobs more easily. Talent Solution provides plug and play access to Google’s search and machine learning capabilities, enabling the entire recruiting ecosystem - company career sites, job boards, applicant tracking systems, and staffing agencies to improve job site engagement and candidate conversion. diff --git a/jobs/cjd_sample/package.json b/jobs/v2/package.json similarity index 100% rename from jobs/cjd_sample/package.json rename to jobs/v2/package.json diff --git a/jobs/cjd_sample/quickstart.js b/jobs/v2/quickstart.js similarity index 100% rename from jobs/cjd_sample/quickstart.js rename to jobs/v2/quickstart.js diff --git a/jobs/cjd_sample/system-test/quickstart.test.js b/jobs/v2/system-test/quickstart.test.js similarity index 100% rename from jobs/cjd_sample/system-test/quickstart.test.js rename to jobs/v2/system-test/quickstart.test.js diff --git a/jobs/v3/README.md b/jobs/v3/README.md new file mode 100755 index 0000000000..26e505da65 --- /dev/null +++ b/jobs/v3/README.md @@ -0,0 +1,44 @@ +Google Cloud Platform logo + +# Google Cloud Talent Solution API Samples + +Cloud Talent Solution is part of Google for Jobs - a Google-wide commitment to help +people find jobs more easily. Talent Solution provides plug and play access to +Google’s search and machine learning capabilities, enabling the entire recruiting +ecosystem - company career sites, job boards, applicant tracking systems, and +staffing agencies to improve job site engagement and candidate conversion. + +## Table of Contents + +* [Setup](#setup) +* [Running the tests](#running-the-tests) + +## Setup + +1. Read [Prerequisites][prereq] and [How to run a sample][run] first. +1. Install dependencies: + + With **npm**: + + npm install + + With **yarn**: + + yarn install + +[prereq]: ../README.md#prerequisites +[run]: ../README.md#how-to-run-a-sample + +## Running the tests + +1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. + +1. Run the tests: + + With **npm**: + + npm test + + With **yarn**: + + yarn test diff --git a/jobs/v3/package.json b/jobs/v3/package.json new file mode 100644 index 0000000000..6a88737938 --- /dev/null +++ b/jobs/v3/package.json @@ -0,0 +1,31 @@ +{ + "name": "nodejs-docs-samples-jobs", + "version": "0.0.1", + "private": true, + "license": "Apache-2.0", + "author": "Google Inc.", + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": ">=4.3.2" + }, + "scripts": { + "lint": "repo-tools lint", + "pretest": "npm run lint", + "test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js" + }, + "dependencies": { + "googleapis": "27.0.0", + "safe-buffer": "5.1.1", + "uuid": "^3.2.1", + "yargs": "11.0.0" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "2.2.5", + "ava": "0.25.0", + "proxyquire": "2.0.1", + "semistandard": "^12.0.1" + } +} diff --git a/jobs/v3/quickstart.js b/jobs/v3/quickstart.js new file mode 100755 index 0000000000..f71c31a65f --- /dev/null +++ b/jobs/v3/quickstart.js @@ -0,0 +1,67 @@ +/** + * Copyright 2018, 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 + * + * http://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 quickstart] + +// Imports the Google APIs client library +const {google} = require('googleapis'); +const projectId = process.env.GOOGLE_CLOUD_PROJECT; + +// Acquires credentials +google.auth.getApplicationDefault((err, authClient) => { + if (err) { + console.error('Failed to acquire credentials'); + console.error(err); + return; + } + + if (authClient.createScopedRequired && authClient.createScopedRequired()) { + authClient = authClient.createScoped([ + 'https://www.googleapis.com/auth/jobs' + ]); + } + + // Instantiates an authorized client + const jobService = google.jobs({ + version: 'v3', + auth: authClient + }); + + const request = { + parent: `projects/${projectId}`, + }; + + // Lists companies + jobService.projects.companies.list(request, function (err, result) { + if (err) { + console.error('Failed to retrieve companies! ' + err); + throw err; + } + console.log(`Request ID: ${result.data.metadata.requestId}`); + + const companies = result.data.companies || []; + + if (companies.length) { + console.log('Companies:'); + companies.forEach((company) => console.log(company.name)); + } else { + console.log(`No companies found.`); + } + }); +}); + +// [END quickstart] diff --git a/jobs/v3/system-test/quickstart.test.js b/jobs/v3/system-test/quickstart.test.js new file mode 100644 index 0000000000..2d0b70096f --- /dev/null +++ b/jobs/v3/system-test/quickstart.test.js @@ -0,0 +1,24 @@ +/** + * Copyright 2018, 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 + * + * http://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 test = require(`ava`); +const tools = require(`@google-cloud/nodejs-repo-tools`); + +test(`should list companies`, async t => { + const output = await tools.runAsync(`node quickstart.js`); + t.true(output.includes(`Request ID`)); +});