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 8c2cf4a

Browse filesBrowse files
author
Rebecca Taylor
committed
Additional Talent v4beta1 samples
1 parent 224a496 commit 8c2cf4a
Copy full SHA for 8c2cf4a

File tree

Expand file treeCollapse file tree

2 files changed

+214
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+214
-0
lines changed
+115Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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_client_event")
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_client_event]
25+
26+
from google.cloud import talent_v4beta1
27+
from google.cloud.talent_v4beta1 import enums
28+
import six
29+
30+
31+
def sample_create_client_event(project_id, tenant_id, request_id, event_id):
32+
"""
33+
Creates a client event
34+
35+
Args:
36+
project_id Your Google Cloud Project ID
37+
tenant_id Identifier of the Tenant
38+
request_id A unique ID generated in the API responses.
39+
Value should be set to the request_id from an API response.
40+
event_id A unique identifier, generated by the client application
41+
"""
42+
# [START job_search_create_client_event_core]
43+
44+
client = talent_v4beta1.EventServiceClient()
45+
46+
# project_id = 'Your Google Cloud Project ID'
47+
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
48+
# request_id = '[request_id from ResponseMetadata]'
49+
# event_id = '[Set this to a unique identifier]'
50+
51+
if isinstance(project_id, six.binary_type):
52+
project_id = project_id.decode('utf-8')
53+
if isinstance(tenant_id, six.binary_type):
54+
tenant_id = tenant_id.decode('utf-8')
55+
if isinstance(request_id, six.binary_type):
56+
request_id = request_id.decode('utf-8')
57+
if isinstance(event_id, six.binary_type):
58+
event_id = event_id.decode('utf-8')
59+
parent = client.tenant_path(project_id, tenant_id)
60+
61+
# The timestamp of the event as seconds of UTC time since Unix epoch
62+
# For more information on how to create google.protobuf.Timestamps
63+
# See:
64+
# https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
65+
seconds = 0
66+
create_time = {'seconds': seconds}
67+
68+
# The type of event attributed to the behavior of the end user
69+
type_ = enums.JobEvent.JobEventType.VIEW
70+
71+
# List of job names associated with this event
72+
jobs_element = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]'
73+
jobs_element_2 = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]'
74+
jobs = [jobs_element, jobs_element_2]
75+
job_event = {'type': type_, 'jobs': jobs}
76+
client_event = {
77+
'request_id': request_id,
78+
'event_id': event_id,
79+
'create_time': create_time,
80+
'job_event': job_event
81+
}
82+
83+
response = client.create_client_event(parent, client_event)
84+
print(response)
85+
86+
# [END job_search_create_client_event_core]
87+
88+
89+
# [END job_search_create_client_event]
90+
91+
92+
def main():
93+
import argparse
94+
95+
parser = argparse.ArgumentParser()
96+
parser.add_argument('--project_id',
97+
type=str,
98+
default='Your Google Cloud Project ID')
99+
parser.add_argument('--tenant_id',
100+
type=str,
101+
default='Your Tenant ID (using tenancy is optional)')
102+
parser.add_argument('--request_id',
103+
type=str,
104+
default='[request_id from ResponseMetadata]')
105+
parser.add_argument('--event_id',
106+
type=str,
107+
default='[Set this to a unique identifier]')
108+
args = parser.parse_args()
109+
110+
sample_create_client_event(args.project_id, args.tenant_id,
111+
args.request_id, args.event_id)
112+
113+
114+
if __name__ == '__main__':
115+
main()
+99Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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_histogram_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_histogram_search]
25+
26+
from google.cloud import talent_v4beta1
27+
import six
28+
29+
30+
def sample_search_jobs(project_id, tenant_id, query):
31+
"""
32+
Search Jobs with histogram queries
33+
34+
Args:
35+
query Histogram query
36+
More info on histogram facets, constants, and built-in functions:
37+
https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest
38+
"""
39+
# [START job_search_histogram_search_core]
40+
41+
client = talent_v4beta1.JobServiceClient()
42+
43+
# project_id = 'Your Google Cloud Project ID'
44+
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
45+
# query = 'count(base_compensation, [bucket(12, 20)])'
46+
47+
if isinstance(project_id, six.binary_type):
48+
project_id = project_id.decode('utf-8')
49+
if isinstance(tenant_id, six.binary_type):
50+
tenant_id = tenant_id.decode('utf-8')
51+
if isinstance(query, six.binary_type):
52+
query = query.decode('utf-8')
53+
parent = client.tenant_path(project_id, tenant_id)
54+
domain = 'www.example.com'
55+
session_id = 'Hashed session identifier'
56+
user_id = 'Hashed user identifier'
57+
request_metadata = {
58+
'domain': domain,
59+
'session_id': session_id,
60+
'user_id': user_id
61+
}
62+
histogram_queries_element = {'histogram_query': query}
63+
histogram_queries = [histogram_queries_element]
64+
65+
# Iterate over all results
66+
for response_item in client.search_jobs(
67+
parent, request_metadata, histogram_queries=histogram_queries):
68+
print('Job summary: {}'.format(response_item.job_summary))
69+
print('Job title snippet: {}'.format(response_item.job_title_snippet))
70+
job = response_item.job
71+
print('Job name: {}'.format(job.name))
72+
print('Job title: {}'.format(job.title))
73+
74+
# [END job_search_histogram_search_core]
75+
76+
77+
# [END job_search_histogram_search]
78+
79+
80+
def main():
81+
import argparse
82+
83+
parser = argparse.ArgumentParser()
84+
parser.add_argument('--project_id',
85+
type=str,
86+
default='Your Google Cloud Project ID')
87+
parser.add_argument('--tenant_id',
88+
type=str,
89+
default='Your Tenant ID (using tenancy is optional)')
90+
parser.add_argument('--query',
91+
type=str,
92+
default='count(base_compensation, [bucket(12, 20)])')
93+
args = parser.parse_args()
94+
95+
sample_search_jobs(args.project_id, args.tenant_id, args.query)
96+
97+
98+
if __name__ == '__main__':
99+
main()

0 commit comments

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