Google Cloud Talent Solution通过requisitionId获取工作 [英] Google Cloud Talent Solution fetch a job by requisitionId
问题描述
我想知道是否可以通过Google Cloud Talent Solution中的requisitionId来获取作业. requisitionId
在所有工作中必须是唯一的,因此看起来很自然地适合找工作.
I am wondering if it is possible to fetch a job by requisitionId in Google Cloud Talent Solution. requisitionId
has to be unique across jobs so it seems like a natural candidate for looking a job up.
创建作业后,api返回一个作业name
,可用于查找该作业:
When a job is created the api returns a job name
that can be used to look the job up:
您可以通过将GET请求发送到Cloud Talent Solution来检索先前插入的作业的详细信息. URI应该包含原始创建请求返回的先前插入的作业名称,作为URL参数.
You can retrieve the details of a previously inserted job by sending a GET request to the Cloud Talent Solution. The URI should include the previously inserted job name returned by the original create request, as a URL parameter.
如果可能的话,我想避免存储这些名称.在我看来,存储它们会增加不必要的复杂性,因为我已经有一个唯一的requisitionId
.需要明确的是,API不允许您添加重复的requisitionId
:
I'd like to avoid storing these names if possible. In my view storing them adds unnecessary complexity since I already have a unique requisitionId
. To be clear the API does not let you add jobs with a duplicate requisitionId
:
职位项目/{my_app_id}/职位/{google_assigned_id}已经存在.跟踪的请求ID:...相关的工作申请ID:...
Job projects/{my_app_id}/jobs/{google_assigned_id} already exists. Request ID for tracking: ... Related Job requisition ID: ...
我可以按requisitionId
查找作业吗?
我可以解析返回的错误消息以获取工作名称.但这似乎很脆弱.
I could parse the error message that's returned to get the job name..but that seems pretty brittle.
推荐答案
事实证明list
方法需要requisitionId
,因此对于一个完整的,读取-创建-更新周期,我们可以做到:
It turns out the list
method takes requisitionId
so for a full, read-create-update cycle we can do:
const listRequest = {
parent: `projects/${projectId}`,
'filter': `companyName="${companyName}" AND requisitionId="${requisitionId}"`
}
const listResult = await jobService.projects.jobs.list(listRequest)
const existingJobs = listResult.data.jobs || [];
let existingJob = null
if (existingJobs && existingJobs.length > 0) {
existingJob = existingJobs[0]
}
let googleJob
if (!existingJob) {
const createRequest = {
'parent': `projects/${projectId}`,
'resource': {
'job': {
companyName,
requisitionId,
title,
description,
applicationInfo: {
emails: ['email@example.com']
}
}
}
}
googleJob = await jobService.projects.jobs.create(createRequest)
.then(result => result)
.catch(resp => {
console.error("ERROR")
console.error(resp)
})
} else {
const patchRequest = {
'name': existingJob.name,
'resource': {
'job': {
companyName,
requisitionId,
title,
description,
applicationInfo: {
emails: ['email@example.com']
}
}
}
}
googleJob = await jobService.projects.jobs.patch(patchRequest)
.then(result => result)
.catch(resp => {
console.error("ERROR")
console.error(resp)
})
}
注意:
-
filter
参数中的双引号很重要.它将不接受单引号,并会给出一条错误的错误消息. - 即使其他所有内容都需要父参数,补丁请求也不能采用
parent
参数.
- The double quotes in the
filter
parameter are important. It will not accept single quotes and will give a cryptic error message. - The patch request cannot take a
parent
parameter even though everything else requires a parent parameter...
这篇关于Google Cloud Talent Solution通过requisitionId获取工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!