工作基本資訊

Job 資源代表單一職缺公告 (亦稱為「徵才資訊」或「工作申請」)。職缺屬於 Company 資源,代表負責該職缺的聘僱實體。

您可以使用 LIST 和 GET 方法存取職缺,並使用 CREATE、UPDATE 和 DELETE 方法操作職缺。Cloud Talent Solution 索引最多可能需要幾分鐘才能讓這些變更生效。

職缺位於服務帳戶的範圍內。只有透過特定服務帳戶的憑證完成驗證的搜尋要求,才能用來存取這些職缺的內容。

為了方便進行疑難排解與錯誤分級,請讓 Cloud Talent Solution 職缺索引與您自己的職缺索引同步,並維持 Cloud Talent Solution 產生的 name 與您系統中的職缺唯一識別碼之間的關聯。當職缺變更或將職缺導入系統時,服務會將 CRUD 呼叫即時傳送至 CTS,確保變更能夠立即反映。您也必須將 CTS 索引加入現有的職缺擷取管道中。

建立工作

您可以使用下列程式碼範例建立 Job。 詳情請參閱「快速入門:建立公司和職缺」。此外,我們也提供影片教學課程和互動式程式碼研究室。

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// createJob create a job as given.
func createJob(w io.Writer, projectID, companyID, requisitionID, title, URI, description, address1, address2, languageCode string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return nil, err
	}

	jobToCreate := &talentpb.Job{
		CompanyName:   fmt.Sprintf("projects/%s/companies/%s", projectID, companyID),
		RequisitionId: requisitionID,
		Title:         title,
		ApplicationInfo: &talentpb.Job_ApplicationInfo{
			Uris: []string{URI},
		},
		Description:  description,
		Addresses:    []string{address1, address2},
		LanguageCode: languageCode,
	}

	// Construct a createJob request.
	req := &talentpb.CreateJobRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Job:    jobToCreate,
	}

	resp, err := c.CreateJob(ctx, req)
	if err != nil {
		fmt.Printf("Failed to create job: %v\n", err)
		return nil, err
	}

	fmt.Printf("Created job: %q\n", resp.GetName())

	return resp, nil
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4.CreateJobRequest;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class JobSearchCreateJob {

  public static void createJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    String requisitionId = "your-unique-req-id";
    String jobApplicationUrl = "your-job-url";
    // String projectId = "me-qa-1";
    // String tenantId = "8ed97629-27ee-4215-909b-18cfe3b7e8e3";
    // String companyId = "05317758-b30e-4b26-a57d-d9e54e4cccd8";
    // String requisitionId = "test-requisitionid-1";
    // String jobApplicationUrl = "http://job.url";
    createJob(projectId, tenantId, companyId, requisitionId, jobApplicationUrl);
  }

  // Create a job.
  public static void createJob(
      String projectId,
      String tenantId,
      String companyId,
      String requisitionId,
      String jobApplicationUrl)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      Job.ApplicationInfo applicationInfo =
          Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build();

      List<String> addresses =
          Arrays.asList(
              "1600 Amphitheatre Parkway, Mountain View, CA 94043",
              "111 8th Avenue, New York, NY 10011");

      // By default, job will expire in 30 days.
      // https://cloud.google.com/talent-solution/job-search/docs/jobs
      Job job =
          Job.newBuilder()
              .setCompany(companyId)
              .setRequisitionId(requisitionId)
              .setTitle("Software Developer")
              .setDescription("Develop, maintain the software solutions.")
              .setApplicationInfo(applicationInfo)
              .addAllAddresses(addresses)
              .setLanguageCode("en-US")
              .build();

      CreateJobRequest request =
          CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();

      Job response = jobServiceClient.createJob(request);
      System.out.format("Created job: %s%n", response.getName());
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/**
 * Create Job
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
function sampleCreateJob(
  projectId,
  tenantId,
  companyName,
  requisitionId,
  title,
  description,
  jobApplicationUrl,
  addressOne,
  addressTwo,
  languageCode
) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const companyName = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const title = 'Software Engineer';
  // const description = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrl = 'https://www.example.org/job-posting/123';
  // const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
  // const addressTwo = '111 8th Avenue, New York, NY 10011';
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const uris = [jobApplicationUrl];
  const applicationInfo = {
    uris: uris,
  };
  const addresses = [addressOne, addressTwo];
  const job = {
    company: companyName,
    requisitionId: requisitionId,
    title: title,
    description: description,
    applicationInfo: applicationInfo,
    addresses: addresses,
    languageCode: languageCode,
  };
  const request = {
    parent: formattedParent,
    job: job,
  };
  client
    .createJob(request)
    .then(responses => {
      const response = responses[0];
      console.log(`Created job: ${response.name}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent


def create_job(
    project_id,
    tenant_id,
    company_id,
    requisition_id,
    job_application_url,
):
    """Create Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id = 'Job requisition ID, aka Posting ID. Unique per job.'
    # title = 'Software Engineer'
    # description = 'This is a description of this <i>wonderful</i> job!'
    # job_application_url = 'https://www.example.org/job-posting/123'
    # address_one = '1600 Amphitheatre Parkway, Mountain View, CA 94043'
    # address_two = '111 8th Avenue, New York, NY 10011'
    # language_code = 'en-US'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, bytes):
        company_id = company_id.decode("utf-8")
    if isinstance(requisition_id, bytes):
        requisition_id = requisition_id.decode("utf-8")
    if isinstance(job_application_url, bytes):
        job_application_url = job_application_url.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    uris = [job_application_url]
    application_info = {"uris": uris}
    addresses = [
        "1600 Amphitheatre Parkway, Mountain View, CA 94043",
        "111 8th Avenue, New York, NY 10011",
    ]
    job = {
        "company": company_id,
        "requisition_id": requisition_id,
        "title": "Software Developer",
        "description": "Develop, maintain the software solutions.",
        "application_info": application_info,
        "addresses": addresses,
        "language_code": "en-US",
    }

    response = client.create_job(parent=parent, job=job)
    print(f"Created job: {response.name}")
    return response.name

必填欄位

以下為建立及更新職缺時的必填欄位:

  • companyName:擁有職缺的公司資源名稱,例如 companyName=\"projects/{ProjectId}/companies/{CompanyId}\"

  • requisitionId:申請 ID (亦稱為公告 ID) 是您指派的值,用於識別職缺。您可以使用此欄位識別用戶端及追蹤申請。允許的字元數上限為 225 個字元。

    職缺公告的唯一性是由 requisitionIDcompanyName 和地點組合而成。使用這些屬性的某個特定鍵建立職缺時,該鍵會儲存在 Cloud Talent Solution 索引中。在該職缺刪除之前,將無法建立具備相同欄位的其他職缺。

  • title:工作職稱,例如「軟體工程師」。允許的字元數上限為 500 個字元。

    為解決非標準工作職稱導致搜尋結果缺漏的問題,Cloud Talent Solution 會運用所有職缺欄位來瞭解職缺內容,並在內部儲存一個「清理版」的工作職稱。當您向服務傳送搜尋要求時,也會清理該搜尋的查詢,並運用本體論技術將清理後的查詢對應至相關的清理版職缺。

  • description:職缺的說明,通常包含多個段落的公司和相關資訊說明。此外,職缺物件還會提供其他欄位,如職責、資歷和其他工作特性等。建議使用這些額外欄位。

    此欄位可接受並處理 HTML 輸入,也接受粗體、斜體、已排序清單和未排序清單標記標籤。允許的字元數上限為 100,000 個字元。

可以是下列其中一項:

  • applicationInfo.uris:申請頁面的網址。

  • applicationInfo.emails:履歷或申請函的電子郵件收件地址。

  • applicationInfo.instruction:申請說明,例如「請將您的申請寄至...」。此欄位可接受並處理 HTML 輸入,也接受粗體、斜體、已排序清單和未排序清單標記標籤。允許的字元數上限為 3,000 個字元。

常用欄位

  • postingExpireTime:職缺公告的到期時間,以時間戳記為準。 時間到之後,服務會將職缺標記為到期,到期的職缺不會出現在搜尋結果中。此日期應在世界標準時間 (UTC) 2100/12/31 之前。 服務會忽略無效的日期 (如過去的日期)。預設的到期日為職缺建立後的 30 天 (使用世界標準時間)。

    職缺到期後的 90 天內,您仍可使用 GET 運算子來擷取到期職缺的內容。過了這個 90 天的期限後,即無法透過 GET 運算子擷取該職缺。

  • addresses:工作地點。我們建議提供招聘地點的完整街道地址,以取得更好的職缺搜尋結果,包括按照通勤時間搜尋職缺。允許的字元數上限為 500 個字元。如要進一步瞭解 addresses,請參閱下方的最佳做法一節。

  • promotionValue:大於 0 的值會將此職缺定義為「精選職缺」,只會在搜尋 FEATURED_JOBS 類型的職缺時傳回結果。值越大,在精選職缺搜尋結果中的位置就會越前面。詳情請參閱精選職缺

使用自訂工作欄位

Cloud Talent Solution 包含多個內建於 API 結構定義的職缺欄位,不過,您可能需要現成選項中沒有的其他欄位。雖然我們建議您盡可能使用預設的欄位,但 Cloud Talent Solution 還是會為職缺提供幾個 customAttributes 欄位。您不一定可以篩選這些屬性。詳情請參閱customAttributes說明文件。

  • customAttributes:此欄位最多可儲存 100 個自訂屬性,用來儲存與職缺相關的自訂資料。您可以使用指定 jobQuery 欄位的搜尋要求,對這些欄位進行篩選。此外,您可以在 companykeywordSearchableJobCustomAttributes 屬性中設定任何這些欄位,因此如果搜尋字詞與 keywordSearchableJobCustomAttributes 中任何欄位完全相符,系統就會傳回包含相符項目的任何 Job。

以下程式碼範例顯示如何使用 customAttribute 建立職缺:

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
	"github.com/gofrs/uuid"
	money "google.golang.org/genproto/googleapis/type/money"
)

// createJobWithCustomAttributes creates a job with custom attributes.
func createJobWithCustomAttributes(w io.Writer, projectID, companyID, jobTitle string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a job service client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewJobClient: %w", err)
	}
	defer c.Close()

	// requisitionID shoud be the unique ID in your system
	requisitionID := fmt.Sprintf("job-with-custom-attribute-%s", uuid.Must(uuid.NewV4()).String())
	jobToCreate := &talentpb.Job{
		Company:       fmt.Sprintf("projects/%s/companies/%s", projectID, companyID),
		RequisitionId: requisitionID,
		Title:         jobTitle,
		ApplicationInfo: &talentpb.Job_ApplicationInfo{
			Uris: []string{"https://googlesample.com/career"},
		},
		Description:     "Design, devolop, test, deploy, maintain and improve software.",
		LanguageCode:    "en-US",
		PromotionValue:  2,
		EmploymentTypes: []talentpb.EmploymentType{talentpb.EmploymentType_FULL_TIME},
		Addresses:       []string{"Mountain View, CA"},
		CustomAttributes: map[string]*talentpb.CustomAttribute{
			"someFieldString": {
				Filterable:   true,
				StringValues: []string{"someStrVal"},
			},
			"someFieldLong": {
				Filterable: true,
				LongValues: []int64{900},
			},
		},
		CompensationInfo: &talentpb.CompensationInfo{
			Entries: []*talentpb.CompensationInfo_CompensationEntry{
				{
					Type: talentpb.CompensationInfo_BASE,
					Unit: talentpb.CompensationInfo_HOURLY,
					CompensationAmount: &talentpb.CompensationInfo_CompensationEntry_Amount{
						Amount: &money.Money{
							CurrencyCode: "USD",
							Units:        1,
						},
					},
				},
			},
		},
	}

	// Construct a createJob request.
	req := &talentpb.CreateJobRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Job:    jobToCreate,
	}

	resp, err := c.CreateJob(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("CreateJob: %w", err)
	}

	fmt.Fprintf(w, "Created job with custom attributres: %q\n", resp.GetName())
	fmt.Fprintf(w, "Custom long field has value: %v\n", resp.GetCustomAttributes()["someFieldLong"].GetLongValues())

	return resp, nil
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4.CreateJobRequest;
import com.google.cloud.talent.v4.CustomAttribute;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class JobSearchCreateJobCustomAttributes {

  public static void createJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    String requisitionId = "your-unique-req-id";
    createJob(projectId, tenantId, companyId, requisitionId);
  }

  // Create Job with Custom Attributes.
  public static void createJob(
      String projectId, String tenantId, String companyId, String requisitionId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);

      // Custom attribute can be string or numeric value, and can be filtered in search queries.
      // https://cloud.google.com/talent-solution/job-search/docs/custom-attributes
      CustomAttribute customAttribute =
          CustomAttribute.newBuilder()
              .addStringValues("Internship")
              .addStringValues("Apprenticeship")
              .setFilterable(true)
              .build();

      Job job =
          Job.newBuilder()
              .setCompany(companyId)
              .setTitle("Software Developer I")
              .setDescription("This is a description of this <i>wonderful</i> job!")
              .putCustomAttributes("FOR_STUDENTS", customAttribute)
              .setRequisitionId(requisitionId)
              .setLanguageCode("en-US")
              .build();

      CreateJobRequest request =
          CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
      Job response = jobServiceClient.createJob(request);
      System.out.printf("Created job: %s\n", response.getName());
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/**
 * Create Job with Custom Attributes
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenantd
 */
function sampleCreateJob(
  projectId,
  tenantId,
  companyName,
  requisitionId,
  languageCode
) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const companyName = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const job = {
    company: companyName,
    requisitionId: requisitionId,
    languageCode: languageCode,
  };
  const request = {
    parent: formattedParent,
    job: job,
  };
  client
    .createJob(request)
    .then(responses => {
      const response = responses[0];
      console.log(`Created job: ${response.name}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent


def create_job(project_id, tenant_id, company_id, requisition_id):
    """Create Job with Custom Attributes"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id = 'Job requisition ID, aka Posting ID. Unique per job.'
    # language_code = 'en-US'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, bytes):
        company_id = company_id.decode("utf-8")

    # Custom attribute can be string or numeric value,
    # and can be filtered in search queries.
    # https://cloud.google.com/talent-solution/job-search/docs/custom-attributes
    custom_attribute = talent.CustomAttribute()
    custom_attribute.filterable = True
    custom_attribute.string_values.append("Intern")
    custom_attribute.string_values.append("Apprenticeship")

    parent = f"projects/{project_id}/tenants/{tenant_id}"

    job = talent.Job(
        company=company_id,
        title="Software Engineer",
        requisition_id=requisition_id,
        description="This is a description of this job",
        language_code="en-us",
        custom_attributes={"FOR_STUDENTS": custom_attribute},
    )

    response = client.create_job(parent=parent, job=job)
    print(f"Created job: {response.name}")
    return response.name

擷取職缺

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// getJob gets an existing job by its resource name.
func getJob(w io.Writer, projectID, jobID string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return nil, err
	}

	// Construct a getJob request.
	jobName := fmt.Sprintf("projects/%s/jobs/%s", projectID, jobID)
	req := &talentpb.GetJobRequest{
		// The resource name of the job to retrieve.
		// The format is "projects/{project_id}/jobs/{job_id}".
		Name: jobName,
	}

	resp, err := c.GetJob(ctx, req)
	if err != nil {
		fmt.Printf("Failed to get job %s: %v\n", jobName, err)
		return nil, err
	}

	fmt.Fprintf(w, "Job: %q\n", resp.GetName())
	fmt.Fprintf(w, "Job title: %v\n", resp.GetTitle())

	return resp, err
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4.GetJobRequest;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobName;
import com.google.cloud.talent.v4.JobServiceClient;
import java.io.IOException;

public class JobSearchGetJob {

  public static void getJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String jobId = "your-job-id";
    getJob(projectId, tenantId, jobId);
  }

  // Get Job.
  public static void getJob(String projectId, String tenantId, String jobId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.of(projectId, tenantId, jobId);

      GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();

      Job response = jobServiceClient.getJob(request);
      System.out.format("Job name: %s%n", response.getName());
      System.out.format("Requisition ID: %s%n", response.getRequisitionId());
      System.out.format("Title: %s%n", response.getTitle());
      System.out.format("Description: %s%n", response.getDescription());
      System.out.format("Posting language: %s%n", response.getLanguageCode());
      for (String address : response.getAddressesList()) {
        System.out.format("Address: %s%n", address);
      }
      for (String email : response.getApplicationInfo().getEmailsList()) {
        System.out.format("Email: %s%n", email);
      }
      for (String websiteUri : response.getApplicationInfo().getUrisList()) {
        System.out.format("Website: %s%n", websiteUri);
      }
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/** Get Job */
function sampleGetJob(projectId, tenantId, jobId) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobId = 'Job ID';
  const formattedName = client.jobPath(projectId, tenantId, jobId);
  client
    .getJob({name: formattedName})
    .then(responses => {
      const response = responses[0];
      console.log(`Job name: ${response.name}`);
      console.log(`Requisition ID: ${response.requisitionId}`);
      console.log(`Title: ${response.title}`);
      console.log(`Description: ${response.description}`);
      console.log(`Posting language: ${response.languageCode}`);
      for (const address of response.addresses) {
        console.log(`Address: ${address}`);
      }
      for (const email of response.applicationInfo.emails) {
        console.log(`Email: ${email}`);
      }
      for (const websiteUri of response.applicationInfo.uris) {
        console.log(`Website: ${websiteUri}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent


def get_job(project_id, tenant_id, job_id):
    """Get Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_id = 'Job ID'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(job_id, bytes):
        job_id = job_id.decode("utf-8")
    name = client.job_path(project_id, tenant_id, job_id)

    response = client.get_job(name=name)
    print(f"Job name: {response.name}")
    print(f"Requisition ID: {response.requisition_id}")
    print(f"Title: {response.title}")
    print(f"Description: {response.description}")
    print(f"Posting language: {response.language_code}")
    for address in response.addresses:
        print(f"Address: {address}")
    for email in response.application_info.emails:
        print(f"Email: {email}")
    for website_uri in response.application_info.uris:
        print(f"Website: {website_uri}")

列出工作

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"google.golang.org/api/iterator"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// listJobs lists jobs with a filter, for example
// `companyName="projects/my-project/companies/123"`.
func listJobs(w io.Writer, projectID, companyID string) error {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return err
	}

	// Construct a listJobs request.
	companyName := fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)
	req := &talentpb.ListJobsRequest{
		Parent: "projects/" + projectID,
		Filter: fmt.Sprintf("companyName=%q", companyName),
	}

	it := c.ListJobs(ctx, req)

	for {
		resp, err := it.Next()
		if err == iterator.Done {
			return nil
		}
		if err != nil {
			fmt.Printf("it.Next: %v\n", err)
			return err
		}
		fmt.Fprintf(w, "Listing job: %v\n", resp.GetName())
		fmt.Fprintf(w, "Job title: %v\n", resp.GetTitle())
	}
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.ListJobsRequest;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class JobSearchListJobs {

  public static void listJobs() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String query = "count(base_compensation, [bucket(12, 20)])";
    listJobs(projectId, tenantId, query);
  }

  // Search Jobs with histogram queries.
  public static void listJobs(String projectId, String tenantId, String filter) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      ListJobsRequest request =
          ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
      for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
        System.out.format("Job name: %s%n", responseItem.getName());
        System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId());
        System.out.format("Job title: %s%n", responseItem.getTitle());
        System.out.format("Job description: %s%n", responseItem.getDescription());
      }
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/**
 * List Jobs
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
function sampleListJobs(projectId, tenantId, filter) {
  const client = new talent.JobServiceClient();
  // Iterate over all elements.
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const filter = 'companyName=projects/my-project/companies/company-id';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const request = {
    parent: formattedParent,
    filter: filter,
  };

  client
    .listJobs(request)
    .then(responses => {
      const resources = responses[0];
      for (const resource of resources) {
        console.log(`Job name: ${resource.name}`);
        console.log(`Job requisition ID: ${resource.requisitionId}`);
        console.log(`Job title: ${resource.title}`);
        console.log(`Job description: ${resource.description}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent


def list_jobs(project_id, tenant_id, filter_):
    """List Jobs"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # filter_ = 'companyName=projects/my-project/companies/company-id'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(filter_, bytes):
        filter_ = filter_.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"

    # Iterate over all results
    results = []
    for job in client.list_jobs(parent=parent, filter=filter_):
        results.append(job.name)
        print("Job name: {job.name}")
        print("Job requisition ID: {job.requisition_id}")
        print("Job title: {job.title}")
        print("Job description: {job.description}")
    return results

刪除工作

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// deleteJob deletes an existing job by its resource name.
func deleteJob(w io.Writer, projectID, jobID string) error {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return err
	}

	// Construct a deleteJob request.
	jobName := fmt.Sprintf("projects/%s/jobs/%s", projectID, jobID)
	req := &talentpb.DeleteJobRequest{
		// The resource name of the job to be deleted.
		// The format is "projects/{project_id}/jobs/{job_id}".
		Name: jobName,
	}

	if err := c.DeleteJob(ctx, req); err != nil {
		fmt.Printf("Delete(%s): %v\n", jobName, err)
		return err
	}

	fmt.Printf("Deleted job: %q\n", jobName)

	return err
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4.DeleteJobRequest;
import com.google.cloud.talent.v4.JobName;
import com.google.cloud.talent.v4.JobServiceClient;
import java.io.IOException;

public class JobSearchDeleteJob {

  public static void deleteJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String jobId = "your-job-id";
    deleteJob(projectId, tenantId, jobId);
  }

  // Delete Job.
  public static void deleteJob(String projectId, String tenantId, String jobId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.of(projectId, tenantId, jobId);

      DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name.toString()).build();

      jobServiceClient.deleteJob(request);
      System.out.println("Deleted job.");
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/** Delete Job */
function sampleDeleteJob(projectId, tenantId, jobId) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobId = 'Company ID';
  const formattedName = client.jobPath(projectId, tenantId, jobId);
  client.deleteJob({name: formattedName}).catch(err => {
    console.error(err);
  });
  console.log('Deleted job.');
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent


def delete_job(project_id, tenant_id, job_id):
    """Delete Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_id = 'Company ID'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(job_id, bytes):
        job_id = job_id.decode("utf-8")
    name = client.job_path(project_id, tenant_id, job_id)

    client.delete_job(name=name)
    print("Deleted job.")

最佳做法

地點欄位

我們建議您盡可能在 addresses 欄位中提供職缺所在地的街道地址,以利提供地點偵測並掌握關聯性。若無法提供街道地址,請儘可能輸入詳細資訊。 服務可支援最高至國家層級的地址,不支援地區 (如「太平洋西北地區」)。

Cloud Talent Solution 會使用 addresses 欄位中的資料來填寫 derivedInfo.locations 欄位 (僅限輸出)。在未提供完整地址的情況下,服務會使用其他資訊 (如公司名稱) 來判斷是否能為該職缺公告推論出更完整的地址。

舉例來說,如果軟體職缺的地點指定為 Mountain View,且與該職缺相關聯的公司為 Google,服務會查詢 company 物件,查看 headquartersAddress 欄位是否提供更合適的街道地址,以及該街道地址是否與職缺位於同一城市。如果是,服務會推論該職缺「大概」位於這個街道地址,並填入 derivedInfo.locations 欄位。

如果沒有可用的公司地址資料時,服務會運用專屬知識加上職缺/公司資訊,組合出填入 derivedInfo.locations 欄位的資訊。

由於 derivedInfo.locations 值是最佳猜測,您也可以使用 derivedInfo.locations 資料或 addresses 欄位,做為顯示的職缺地址。

職缺公告最多可有 50 個相關聯的地點。如果職缺的地點超過此數目,您可以將這個職缺拆成多個職缺,每個職缺都有一個唯一的 requisitionId (例如「ReqA」、「ReqA-1」、「ReqA-2」等)。不得有多個工作具有相同的 requisitionIdcompanyNamelanguageCode。如果您一定要保留原本的 requisitionId,請在儲存時使用 CustomAttribute。我們建議您將鄰近的地點分配到同一個職缺,以獲得更好的搜尋體驗。

支援的地址

Cloud Talent Solution 接受 Google Maps Geocoding API 能辨識的任何地址 (在 formattedAddress 欄位中)。若您試圖使用無法辨識的地址建立職缺或執行搜尋,服務會傳回錯誤代碼 400。

如果 Google Maps Geocoding API 中所列的公司地址不正確,請回報錯誤進行更正。更正的地址最多可能需要 5 天才會生效。

地址自動完成

Cloud Talent Solution 不提供地點自動完成建議。請使用 Google Maps Places API 或其他類似的定位服務,來填入自動完成建議。

全州、全國範圍的工作和遠距工作

您可以使用 postingRegion 欄位,指定全州/全國範圍的工作或遠距工作。

  • 若搜尋的地點在職缺公告的州/國家內,會傳回 ADMINISTRATIVE_AREANATION 職缺。舉例來說,如果 ADMINISTRATIVE_AREA 職缺的地點為「美國華盛頓州」,當您使用 LocationFilter 指定「西雅圖」進行搜尋時,將會傳回該職缺。

  • TELECOMMUTE 任何與地點相關的搜尋都會傳回職缺,但關聯性較低。telecommutePreference 標記設為 TELECOMMUTE_ALLOWED,即可在搜尋的 LocationFilter 中指定這類職缺。