Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebrand Cloud Job Discovery to Cloud Talent Solution and add the V3 code samples #701

Closed
44 changes: 44 additions & 0 deletions jobs/v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include yarn instructions.


[prereq]: ../README.md#prerequisites
[run]: ../README.md#how-to-run-a-sample
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this path is correct.


## 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't include yarn.

31 changes: 31 additions & 0 deletions jobs/v2/package.json
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Node 8

},
"scripts": {
"lint": "repo-tools lint",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete lint and pretest scripts.

"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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete semistandard.

}
}
62 changes: 62 additions & 0 deletions jobs/v2/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* 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');

// Acquires credentials
google.auth.getApplicationDefault((err, authClient) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use simple auth with google.auth.getClient

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;
}

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]
24 changes: 24 additions & 0 deletions jobs/v2/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
@@ -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`));
});
44 changes: 44 additions & 0 deletions jobs/v3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# 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
31 changes: 31 additions & 0 deletions jobs/v3/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
67 changes: 67 additions & 0 deletions jobs/v3/quickstart.js
Original file line number Diff line number Diff line change
@@ -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]
24 changes: 24 additions & 0 deletions jobs/v3/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
@@ -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`));
});