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
docs(samples): Talent API Sample Revision & Test #1546
Merged
JustinBeckwith
merged 20 commits into
googleapis:master
from
josecervino:samples/talentapi
Jan 30, 2019
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6d23aae
Jobs sample & test start
josecervino 49f2dec
README commit
josecervino 06179e0
Talent API Simple Sample
josecervino 5d5ba1b
Cleaning logs
josecervino 1b1acb1
Merge branch 'master' of https://github.com/googleapis/google-api-nod…
josecervino a275307
Delete Sample README
69d517e
Changes to 'OAuth 2 client' section
2119366
Merge pull request #2 from JCIV-SE/samples/talentapi
21112dc
Merge branch 'master' into master
JustinBeckwith f7cb56d
Samples: Talent API Sample Revision & Test
josecervino f6dc2ba
Merge branch 'master' of https://github.com/JCIV-SE/google-api-nodejs…
josecervino 49f651f
Merge branch 'master' into samples/talentapi
JustinBeckwith 978ee07
Merge branch 'master' into master
JustinBeckwith 6fec6b3
Merge branch 'master' of https://github.com/googleapis/google-api-nod…
josecervino c4c4ba9
docs(samples): Talent API test .skip
josecervino c3cec25
Merge branch origin 'master' of https://github.com/JCIV-SE/google-api…
josecervino 90bdc6f
Merge pull request #3 from JCIV-SE/samples/talentapi
4068727
--Lint fix--
josecervino fc16bcf
Merge branch 'master' of https://github.com/JCIV-SE/google-api-nodejs…
josecervino 37f5753
Merge branch 'master' into samples/talentapi
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2016, 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 {google} = require('googleapis'); | ||
const sampleClient = require('../sampleclient'); | ||
|
||
const jobService = google.jobs({ | ||
version: 'v3', | ||
auth: sampleClient.oAuth2Client, | ||
}); | ||
|
||
async function runSample() { | ||
const projectId = await google.auth.getProjectId(); | ||
const res = await jobService.projects.companies.create({ | ||
parent: `project/${projectId}`, | ||
requestBody: { | ||
company: { | ||
displayName: 'ABC co.', | ||
externalId: '12345', | ||
}, | ||
}, | ||
}); | ||
console.log(res.data); | ||
return res.data; | ||
} | ||
|
||
if (module === require.main) { | ||
const scopes = [ | ||
'https://www.googleapis.com/auth/jobs', | ||
'https://www.googleapis.com/auth/cloud-platform', | ||
]; | ||
sampleClient | ||
.authenticate(scopes) | ||
.then(runSample) | ||
.catch(console.error); | ||
} | ||
|
||
module.exports = { | ||
runSample, | ||
client: sampleClient.oAuth2Client, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// 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. | ||
|
||
import * as assert from 'assert'; | ||
import * as nock from 'nock'; | ||
import {Utils} from '../utils'; | ||
|
||
nock.disableNetConnect(); | ||
|
||
// tslint:disable: no-any | ||
const samples: any = { | ||
jobs: require('../../../samples/jobs/jobs.js'), | ||
}; | ||
|
||
for (const p in samples) { | ||
if (samples[p]) { | ||
samples.jobs.client.credentials = {access_token: 'not-a-token'}; | ||
} | ||
} | ||
|
||
describe('Talent API Samples', () => { | ||
afterEach(() => { | ||
nock.cleanAll(); | ||
}); | ||
|
||
it('should create a company', async () => { | ||
const scope = nock(Utils.baseUrl) | ||
.post(`/v3/jobs/project/project-id/companies`) | ||
.reply(200, {}); | ||
const data = await samples.jobs.runSample(); | ||
assert(data); | ||
scope.done(); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I think this is the problem. For this url, can you use
${process.env.GCLOUD_PROJECT}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I tried it several different ways though and I'm still getting:
🎊
I accepted the invitation (thanks!), I'll try pushing a branch upstream once auth allows it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh weird. Share your updated code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Here's version 1:
version 2:
I tried a few other ways but the above two are the ones that make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, v1 looks right to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some logging revealed that
GCLOUD_PROJECT
isundefined
until we go into runSample's scope where we call on the auth service to generate a project Id - copying the same code (const projectId = await google.auth.getProjectId();
) into the test's scope gives usundefined
too so.. any chance we can erase this test and push the sample up anyway? A bit anarchistic but I noticed there are a few other APIs without themThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the test, just put a
.skip
on it :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Done!