Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 224a496

Browse filesBrowse files
author
Rebecca Taylor
committed
Add Talent v4beta1 generated samples (w/o tests)
1 parent 7880577 commit 224a496
Copy full SHA for 224a496
Expand file treeCollapse file tree

17 files changed

+1344
-0
lines changed
+94Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# DO NOT EDIT! This is a generated sample ("Request", "job_search_autocomplete_job_title")
18+
19+
# To install the latest published package dependency, execute the following:
20+
# pip install google-cloud-talent
21+
22+
import sys
23+
24+
# [START job_search_autocomplete_job_title]
25+
26+
from google.cloud import talent_v4beta1
27+
from google.cloud.talent_v4beta1 import enums
28+
import six
29+
30+
31+
def sample_complete_query(project_id, tenant_id, query, num_results,
32+
language_code):
33+
"""Complete job title given partial text (autocomplete)"""
34+
# [START job_search_autocomplete_job_title_core]
35+
36+
client = talent_v4beta1.CompletionClient()
37+
38+
# project_id = 'Your Google Cloud Project ID'
39+
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
40+
# query = '[partially typed job title]'
41+
# num_results = 5
42+
# language_code = 'en-US'
43+
44+
if isinstance(project_id, six.binary_type):
45+
project_id = project_id.decode('utf-8')
46+
if isinstance(tenant_id, six.binary_type):
47+
tenant_id = tenant_id.decode('utf-8')
48+
if isinstance(query, six.binary_type):
49+
query = query.decode('utf-8')
50+
51+
if isinstance(language_code, six.binary_type):
52+
language_code = language_code.decode('utf-8')
53+
parent = client.tenant_path(project_id, tenant_id)
54+
language_codes = [language_code]
55+
56+
response = client.complete_query(parent,
57+
query,
58+
num_results,
59+
language_codes=language_codes)
60+
for result in response.completion_results:
61+
print('Suggested title: {}'.format(result.suggestion))
62+
# Suggestion type is JOB_TITLE or COMPANY_TITLE
63+
print('Suggestion type: {}'.format(
64+
enums.CompleteQueryRequest.CompletionType(result.type).name))
65+
66+
# [END job_search_autocomplete_job_title_core]
67+
68+
69+
# [END job_search_autocomplete_job_title]
70+
71+
72+
def main():
73+
import argparse
74+
75+
parser = argparse.ArgumentParser()
76+
parser.add_argument('--project_id',
77+
type=str,
78+
default='Your Google Cloud Project ID')
79+
parser.add_argument('--tenant_id',
80+
type=str,
81+
default='Your Tenant ID (using tenancy is optional)')
82+
parser.add_argument('--query',
83+
type=str,
84+
default='[partially typed job title]')
85+
parser.add_argument('--num_results', type=int, default=5)
86+
parser.add_argument('--language_code', type=str, default='en-US')
87+
args = parser.parse_args()
88+
89+
sample_complete_query(args.project_id, args.tenant_id, args.query,
90+
args.num_results, args.language_code)
91+
92+
93+
if __name__ == '__main__':
94+
main()

‎jobs/v4/job_search_commute_search.py

Copy file name to clipboard
+98Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# DO NOT EDIT! This is a generated sample ("RequestPagedAll", "job_search_commute_search")
18+
19+
# To install the latest published package dependency, execute the following:
20+
# pip install google-cloud-talent
21+
22+
import sys
23+
24+
# [START job_search_commute_search]
25+
26+
from google.cloud import talent_v4beta1
27+
from google.cloud.talent_v4beta1 import enums
28+
import six
29+
30+
31+
def sample_search_jobs(project_id, tenant_id):
32+
"""Search Jobs using commute distance"""
33+
# [START job_search_commute_search_core]
34+
35+
client = talent_v4beta1.JobServiceClient()
36+
37+
# project_id = 'Your Google Cloud Project ID'
38+
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
39+
40+
if isinstance(project_id, six.binary_type):
41+
project_id = project_id.decode('utf-8')
42+
if isinstance(tenant_id, six.binary_type):
43+
tenant_id = tenant_id.decode('utf-8')
44+
parent = client.tenant_path(project_id, tenant_id)
45+
domain = 'www.example.com'
46+
session_id = 'Hashed session identifier'
47+
user_id = 'Hashed user identifier'
48+
request_metadata = {
49+
'domain': domain,
50+
'session_id': session_id,
51+
'user_id': user_id
52+
}
53+
commute_method = enums.CommuteMethod.TRANSIT
54+
seconds = 1800
55+
travel_duration = {'seconds': seconds}
56+
latitude = 37.422408
57+
longitude = 122.084068
58+
start_coordinates = {'latitude': latitude, 'longitude': longitude}
59+
commute_filter = {
60+
'commute_method': commute_method,
61+
'travel_duration': travel_duration,
62+
'start_coordinates': start_coordinates
63+
}
64+
job_query = {'commute_filter': commute_filter}
65+
66+
# Iterate over all results
67+
for response_item in client.search_jobs(parent,
68+
request_metadata,
69+
job_query=job_query):
70+
print('Job summary: {}'.format(response_item.job_summary))
71+
print('Job title snippet: {}'.format(response_item.job_title_snippet))
72+
job = response_item.job
73+
print('Job name: {}'.format(job.name))
74+
print('Job title: {}'.format(job.title))
75+
76+
# [END job_search_commute_search_core]
77+
78+
79+
# [END job_search_commute_search]
80+
81+
82+
def main():
83+
import argparse
84+
85+
parser = argparse.ArgumentParser()
86+
parser.add_argument('--project_id',
87+
type=str,
88+
default='Your Google Cloud Project ID')
89+
parser.add_argument('--tenant_id',
90+
type=str,
91+
default='Your Tenant ID (using tenancy is optional)')
92+
args = parser.parse_args()
93+
94+
sample_search_jobs(args.project_id, args.tenant_id)
95+
96+
97+
if __name__ == '__main__':
98+
main()

‎jobs/v4/job_search_create_company.py

Copy file name to clipboard
+85Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# DO NOT EDIT! This is a generated sample ("Request", "job_search_create_company")
18+
19+
# To install the latest published package dependency, execute the following:
20+
# pip install google-cloud-talent
21+
22+
import sys
23+
24+
# [START job_search_create_company]
25+
26+
from google.cloud import talent_v4beta1
27+
import six
28+
29+
30+
def sample_create_company(project_id, tenant_id, display_name, external_id):
31+
"""Create Company"""
32+
# [START job_search_create_company_core]
33+
34+
client = talent_v4beta1.CompanyServiceClient()
35+
36+
# project_id = 'Your Google Cloud Project ID'
37+
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
38+
# display_name = 'My Company Name'
39+
# external_id = 'Identifier of this company in my system'
40+
41+
if isinstance(project_id, six.binary_type):
42+
project_id = project_id.decode('utf-8')
43+
if isinstance(tenant_id, six.binary_type):
44+
tenant_id = tenant_id.decode('utf-8')
45+
if isinstance(display_name, six.binary_type):
46+
display_name = display_name.decode('utf-8')
47+
if isinstance(external_id, six.binary_type):
48+
external_id = external_id.decode('utf-8')
49+
parent = client.tenant_path(project_id, tenant_id)
50+
company = {'display_name': display_name, 'external_id': external_id}
51+
52+
response = client.create_company(parent, company)
53+
print('Created Company')
54+
print('Name: {}'.format(response.name))
55+
print('Display Name: {}'.format(response.display_name))
56+
print('External ID: {}'.format(response.external_id))
57+
58+
# [END job_search_create_company_core]
59+
60+
61+
# [END job_search_create_company]
62+
63+
64+
def main():
65+
import argparse
66+
67+
parser = argparse.ArgumentParser()
68+
parser.add_argument('--project_id',
69+
type=str,
70+
default='Your Google Cloud Project ID')
71+
parser.add_argument('--tenant_id',
72+
type=str,
73+
default='Your Tenant ID (using tenancy is optional)')
74+
parser.add_argument('--display_name', type=str, default='My Company Name')
75+
parser.add_argument('--external_id',
76+
type=str,
77+
default='Identifier of this company in my system')
78+
args = parser.parse_args()
79+
80+
sample_create_company(args.project_id, args.tenant_id, args.display_name,
81+
args.external_id)
82+
83+
84+
if __name__ == '__main__':
85+
main()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.