Job basics

A Job resource represents a single job posting (also referred to as a "job listing" or "job requisition"). A job belongs to a Company resource that represents the hiring entity responsible for the job.

You can access a job using the LIST and GET methods and manipulate it using CREATE, UPDATE, and DELETE methods. It can take several minutes for the Cloud Talent Solution index to reflect changes.

Jobs are contained within the scope of a service account. Only search requests authenticated using the credentials of a particular service account can be used to access the content of these jobs.

For easy troubleshooting and triaging, synchronize the Cloud Talent Solution job index with your own job index, and maintain a relationship between the name generated by Cloud Talent Solution and the unique job identifier in your system. As jobs change or are introduced into your system, the appropriate CRUD call should be sent to CTS in real time to ensure that these changes are reflected immediately. The CTS index must be added to the existing job ingestion pipeline.

Create a job

You can create a Job using the code sample below. See Quickstart: Create companies and jobs for more details.

Go

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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.CreateJobRequest;
 * import com.google.cloud.talent.v4beta1.Job;
 * import com.google.cloud.talent.v4beta1.Job.ApplicationInfo;
 * import com.google.cloud.talent.v4beta1.JobServiceClient;
 * import com.google.cloud.talent.v4beta1.TenantName;
 * import com.google.cloud.talent.v4beta1.TenantOrProjectName;
 * import java.util.Arrays;
 * import java.util.List;
 */

/**
 * Create Job
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleCreateJob(
    String projectId,
    String tenantId,
    String companyName,
    String requisitionId,
    String title,
    String description,
    String jobApplicationUrl,
    String addressOne,
    String addressTwo,
    String languageCode) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // companyName = "Company name, e.g. projects/your-project/companies/company-id";
    // requisitionId = "Job requisition ID, aka Posting ID. Unique per job.";
    // title = "Software Engineer";
    // description = "This is a description of this <i>wonderful</i> job!";
    // jobApplicationUrl = "https://www.example.org/job-posting/123";
    // addressOne = "1600 Amphitheatre Parkway, Mountain View, CA 94043";
    // addressTwo = "111 8th Avenue, New York, NY 10011";
    // languageCode = "en-US";
    TenantOrProjectName parent = TenantName.of(projectId, tenantId);
    List<String> uris = Arrays.asList(jobApplicationUrl);
    Job.ApplicationInfo applicationInfo =
        Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
    List<String> addresses = Arrays.asList(addressOne, addressTwo);
    Job job =
        Job.newBuilder()
            .setCompany(companyName)
            .setRequisitionId(requisitionId)
            .setTitle(title)
            .setDescription(description)
            .setApplicationInfo(applicationInfo)
            .addAllAddresses(addresses)
            .setLanguageCode(languageCode)
            .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());
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

/**
 * 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);
    });
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;
use Google\Cloud\Talent\V4beta1\Job;
use Google\Cloud\Talent\V4beta1\Job_ApplicationInfo;

/**
 * Create Job.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleCreateJob($projectId, $tenantId, $companyName, $requisitionId, $title, $description, $jobApplicationUrl, $addressOne, $addressTwo, $languageCode)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $companyName = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $title = 'Software Engineer';
    // $description = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrl = 'https://www.example.org/job-posting/123';
    // $addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
    // $addressTwo = '111 8th Avenue, New York, NY 10011';
    // $languageCode = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $uris = [$jobApplicationUrl];
    $applicationInfo = new Job_ApplicationInfo();
    $applicationInfo->setUris($uris);
    $addresses = [$addressOne, $addressTwo];
    $job = new Job();
    $job->setCompany($companyName);
    $job->setRequisitionId($requisitionId);
    $job->setTitle($title);
    $job->setDescription($description);
    $job->setApplicationInfo($applicationInfo);
    $job->setAddresses($addresses);
    $job->setLanguageCode($languageCode);

    try {
        $response = $jobServiceClient->createJob($formattedParent, $job);
        printf('Created job: %s'.PHP_EOL, $response->getName());
    } finally {
        $jobServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


from google.cloud import talent_v4beta1
import six


def sample_create_job(project_id, tenant_id, company_name, requisition_id,
                      title, description, job_application_url, address_one,
                      address_two, language_code):
    """Create Job"""

    client = talent_v4beta1.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_name = '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, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode('utf-8')
    if isinstance(company_name, six.binary_type):
        company_name = company_name.decode('utf-8')
    if isinstance(requisition_id, six.binary_type):
        requisition_id = requisition_id.decode('utf-8')
    if isinstance(title, six.binary_type):
        title = title.decode('utf-8')
    if isinstance(description, six.binary_type):
        description = description.decode('utf-8')
    if isinstance(job_application_url, six.binary_type):
        job_application_url = job_application_url.decode('utf-8')
    if isinstance(address_one, six.binary_type):
        address_one = address_one.decode('utf-8')
    if isinstance(address_two, six.binary_type):
        address_two = address_two.decode('utf-8')
    if isinstance(language_code, six.binary_type):
        language_code = language_code.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)
    uris = [job_application_url]
    application_info = {'uris': uris}
    addresses = [address_one, address_two]
    job = {
        'company': company_name,
        'requisition_id': requisition_id,
        'title': title,
        'description': description,
        'application_info': application_info,
        'addresses': addresses,
        'language_code': language_code
    }

    response = client.create_job(parent, job)
    print('Created job: {}'.format(response.name))


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


 # Create Job
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenant
def sample_create_job(project_id, tenant_id, company_name, requisition_id, title, description, job_application_url, address_one, address_two, language_code)
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # company_name = "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"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  uris = [job_application_url]
  application_info = { uris: uris }
  addresses = [address_one, address_two]
  job = {
    company: company_name,
    requisition_id: requisition_id,
    title: title,
    description: description,
    application_info: application_info,
    addresses: addresses,
    language_code: language_code
  }

  response = job_client.create_job(formatted_parent, job)
  puts "Created job: #{response.name}"

end

Required fields

The following fields are required during Job creation and update:

  • companyName: The resource name of the company that owns the job, such as projects/[project_id]/tenants/[tenant_id]/companies/[company_id].

  • requisitionId: The requisition ID, also referred to as the posting ID, is a value that you assign to identify a job. You can use this field for client identification and requisition tracking. The maximum number of allowed characters is 225.

    The uniqueness of a job posting is determined using a combination of the requisitionID, the companyName, and location. If a job is created with a specific key of these attributes, this key is stored in the Cloud Talent Solution index and no other jobs with these same fields can be created until the job is deleted.

  • title: The job title, for example "Software Engineer." The maximum number of allowed characters is 500.

    To fix the problem of missed search results due to non-standard job titles, Cloud Talent Solution leverages all job fields to understand the context of the job and internally store a "clean" job title. When a search request is sent to the service, the query of the search is also cleaned, and the ontologies are used to map the cleaned query to relevant clean jobs.

  • description: The description of the job, which typically includes a multi-paragraph description of the company and related information. Separate fields are provided on the Job object for responsibilities, qualifications, and other job characteristics. Use of these separate fields is recommended.

    This field accepts and sanitizes HTML input, and accepts bold, italic, ordered list, and unordered list markup tags. The maximum number of allowed characters is 100,000.

One of the following:

  • applicationInfo.uris: The URL(s) of the application page(s).

  • applicationInfo.emails: Email address(es) to which resumes or applications should be sent.

  • applicationInfo.instruction: Application instructions, such as "Mail your application to ...". This field accepts and sanitizes HTML input, and accepts bold, italic, ordered list, and unordered list markup tags. The maximum number of allowed characters is 3,000.

Commonly used fields

  • postingExpireTime: The time, based on the timestamp, when the job posting expires. After this time occurs, the job is marked as expired and won't appear in search results. This date should be before 2100/12/31 in UTC timezone. Invalid dates (such as past dates) are ignored. The default date when the job expires is 30 days after the job creation time in UTC time zone.

    The content of expired jobs can still be retrieved up to 60 days after the job has expired by using the GET operator. After this 60 day deadline, the job won't be returned through a GET operation.

  • addresses: Job location(s). Providing the full street address(es) of the hiring location is recommended to enable better Job Search results, including searches by commute time. The maximum number of allowed characters is 500. More information about addresses is available in the Best practices section below.

  • promotionValue: A value greater than 0 defines this job as a "featured job", which is returned only in searches of type FEATURED_JOBS. Higher values are returned higher in the featured search results. See Featured Jobs for more information.

Using custom job fields

Cloud Talent Solution includes several job fields that are built in to its API schemas. However, you may need additional fields that aren't present in the out-of-the-box options. While we recommended that you use the out-of-the box fields wherever possible, Cloud Talent Solution also provides some customAttributes fields for a job. These can be filterable or non-filterable. Refer to the customAttributes documentation for more information.

  • customAttributes: This field stores up to 100 custom attributes used to store custom data about the job. These fields can be filtered against using a search request specifying the jobQuery field. Additionally, any of these fields can be set in the keywordSearchableJobCustomAttributes attribute of the company, so a search term that has an exact match in any of the fields in keywordSearchableJobCustomAttributes returns any Job that includes the match.

The following code example shows how to create a job with a customAttribute:

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"github.com/gofrs/uuid"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
	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: %v", err)
	}

	// 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: %v", 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.CreateJobRequest;
 * import com.google.cloud.talent.v4beta1.Job;
 * import com.google.cloud.talent.v4beta1.JobServiceClient;
 * import com.google.cloud.talent.v4beta1.TenantName;
 * import com.google.cloud.talent.v4beta1.TenantOrProjectName;
 */

/**
 * Create Job with Custom Attributes
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 */
public static void sampleCreateJob(
    String projectId,
    String tenantId,
    String companyName,
    String requisitionId,
    String languageCode) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // companyName = "Company name, e.g. projects/your-project/companies/company-id";
    // requisitionId = "Job requisition ID, aka Posting ID. Unique per job.";
    // languageCode = "en-US";
    TenantOrProjectName parent = TenantName.of(projectId, tenantId);
    Job job =
        Job.newBuilder()
            .setCompany(companyName)
            .setRequisitionId(requisitionId)
            .setLanguageCode(languageCode)
            .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());
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

/**
 * 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);
    });
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;
use Google\Cloud\Talent\V4beta1\Job;

/**
 * Create Job with Custom Attributes.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenantd
 */
function sampleCreateJob($projectId, $tenantId, $companyName, $requisitionId, $languageCode)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $companyName = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $languageCode = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $job = new Job();
    $job->setCompany($companyName);
    $job->setRequisitionId($requisitionId);
    $job->setLanguageCode($languageCode);

    try {
        $response = $jobServiceClient->createJob($formattedParent, $job);
        printf('Created job: %s'.PHP_EOL, $response->getName());
    } finally {
        $jobServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


from google.cloud import talent_v4beta1
import six


def sample_create_job(project_id, tenant_id, company_name, requisition_id,
                      language_code):
    """Create Job with Custom Attributes"""

    client = talent_v4beta1.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_name = '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, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode('utf-8')
    if isinstance(company_name, six.binary_type):
        company_name = company_name.decode('utf-8')
    if isinstance(requisition_id, six.binary_type):
        requisition_id = requisition_id.decode('utf-8')
    if isinstance(language_code, six.binary_type):
        language_code = language_code.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)
    job = {
        'company': company_name,
        'requisition_id': requisition_id,
        'language_code': language_code
    }

    response = client.create_job(parent, job)
    print('Created job: {}'.format(response.name))


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


 # Create Job with Custom Attributes
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenantd
def sample_create_job(project_id, tenant_id, company_name, requisition_id, language_code)
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # company_name = "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"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  job = {
    company: company_name,
    requisition_id: requisition_id,
    language_code: language_code
  }

  response = job_client.create_job(formatted_parent, job)
  puts "Created job: #{response.name}"

end

Retrieve a job

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.GetJobRequest;
 * import com.google.cloud.talent.v4beta1.Job;
 * import com.google.cloud.talent.v4beta1.JobName;
 * import com.google.cloud.talent.v4beta1.JobServiceClient;
 * import com.google.cloud.talent.v4beta1.JobWithTenantName;
 */

/** Get Job */
public static void sampleGetJob(String projectId, String tenantId, String jobId) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // jobId = "Job ID";
    JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
    GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
    Job response = jobServiceClient.getJob(request);
    System.out.printf("Job name: %s\n", response.getName());
    System.out.printf("Requisition ID: %s\n", response.getRequisitionId());
    System.out.printf("Title: %s\n", response.getTitle());
    System.out.printf("Description: %s\n", response.getDescription());
    System.out.printf("Posting language: %s\n", response.getLanguageCode());
    for (String address : response.getAddressesList()) {
      System.out.printf("Address: %s\n", address);
    }
    for (String email : response.getApplicationInfo().getEmailsList()) {
      System.out.printf("Email: %s\n", email);
    }
    for (String websiteUri : response.getApplicationInfo().getUrisList()) {
      System.out.printf("Website: %s\n", websiteUri);
    }
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

/** 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);
    });
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/** Get Job */
function sampleGetJob($projectId, $tenantId, $jobId)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $jobId = 'Job ID';
    $formattedName = $jobServiceClient->jobName($projectId, $tenantId, $jobId);

    try {
        $response = $jobServiceClient->getJob($formattedName);
        printf('Job name: %s'.PHP_EOL, $response->getName());
        printf('Requisition ID: %s'.PHP_EOL, $response->getRequisitionId());
        printf('Title: %s'.PHP_EOL, $response->getTitle());
        printf('Description: %s'.PHP_EOL, $response->getDescription());
        printf('Posting language: %s'.PHP_EOL, $response->getLanguageCode());
        foreach ($response->getAddresses() as $address) {
            printf('Address: %s'.PHP_EOL, $address);
        }
        foreach ($response->getApplicationInfo()->getEmails() as $email) {
            printf('Email: %s'.PHP_EOL, $email);
        }
        foreach ($response->getApplicationInfo()->getUris() as $websiteUri) {
            printf('Website: %s'.PHP_EOL, $websiteUri);
        }
    } finally {
        $jobServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


from google.cloud import talent_v4beta1
import six


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

    client = talent_v4beta1.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, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode('utf-8')
    if isinstance(job_id, six.binary_type):
        job_id = job_id.decode('utf-8')
    name = client.job_path(project_id, tenant_id, job_id)

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


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


# Get Job
def sample_get_job(project_id, tenant_id, job_id)
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # job_id = "Job ID"
  formatted_name = job_client.class.job_path(project_id, tenant_id, job_id)

  response = job_client.get_job(formatted_name)
  puts "Job name: #{response.name}"
  puts "Requisition ID: #{response.requisition_id}"
  puts "Title: #{response.title}"
  puts "Description: #{response.description}"
  puts "Posting language: #{response.language_code}"
  response.addresses.each do |address|
    puts "Address: #{address}"
  end
  response.application_info.emails.each do |email|
    puts "Email: #{email}"
  end
  response.application_info.uris.each do |website_uri|
    puts "Website: #{website_uri}"
  end

end

List jobs

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.Job;
 * import com.google.cloud.talent.v4beta1.JobServiceClient;
 * import com.google.cloud.talent.v4beta1.ListJobsRequest;
 * import com.google.cloud.talent.v4beta1.TenantName;
 * import com.google.cloud.talent.v4beta1.TenantOrProjectName;
 */

/**
 * List Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListJobs(String projectId, String tenantId, String filter) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // filter = "companyName=projects/my-project/companies/company-id";
    TenantOrProjectName parent = TenantName.of(projectId, tenantId);
    ListJobsRequest request =
        ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
    for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
      System.out.printf("Job name: %s\n", responseItem.getName());
      System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId());
      System.out.printf("Job title: %s\n", responseItem.getTitle());
      System.out.printf("Job description: %s\n", responseItem.getDescription());
    }
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

/**
 * 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);
    });
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/**
 * List Jobs.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleListJobs($projectId, $tenantId, $filter)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $filter = 'companyName=projects/my-project/companies/company-id';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);

    try {
        // Iterate through all elements
        $pagedResponse = $jobServiceClient->listJobs($formattedParent, $filter);
        foreach ($pagedResponse->iterateAllElements() as $responseItem) {
            printf('Job name: %s'.PHP_EOL, $responseItem->getName());
            printf('Job requisition ID: %s'.PHP_EOL, $responseItem->getRequisitionId());
            printf('Job title: %s'.PHP_EOL, $responseItem->getTitle());
            printf('Job description: %s'.PHP_EOL, $responseItem->getDescription());
        }
    } finally {
        $jobServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


from google.cloud import talent_v4beta1
import six


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

    client = talent_v4beta1.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, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode('utf-8')
    if isinstance(filter_, six.binary_type):
        filter_ = filter_.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)

    # Iterate over all results
    for response_item in client.list_jobs(parent, filter_):
        print('Job name: {}'.format(response_item.name))
        print('Job requisition ID: {}'.format(response_item.requisition_id))
        print('Job title: {}'.format(response_item.title))
        print('Job description: {}'.format(response_item.description))


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


 # List Jobs
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenant
def sample_list_jobs(project_id, tenant_id, filter)
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # filter = "companyName=projects/my-project/companies/company-id"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)

  # Iterate over all results.
  job_client.list_jobs(formatted_parent, filter).each do |element|
    puts "Job name: #{element.name}"
    puts "Job requisition ID: #{element.requisition_id}"
    puts "Job title: #{element.title}"
    puts "Job description: #{element.description}"
  end

end

Delete a job

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.DeleteJobRequest;
 * import com.google.cloud.talent.v4beta1.JobName;
 * import com.google.cloud.talent.v4beta1.JobServiceClient;
 * import com.google.cloud.talent.v4beta1.JobWithTenantName;
 */

/** Delete Job */
public static void sampleDeleteJob(String projectId, String tenantId, String jobId) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // jobId = "Company ID";
    JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
    DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name.toString()).build();
    jobServiceClient.deleteJob(request);
    System.out.println("Deleted job.");
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

/** 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.`);
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/** Delete Job */
function sampleDeleteJob($projectId, $tenantId, $jobId)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $jobId = 'Company ID';
    $formattedName = $jobServiceClient->jobName($projectId, $tenantId, $jobId);

    try {
        $jobServiceClient->deleteJob($formattedName);
        printf('Deleted job.'.PHP_EOL);
    } finally {
        $jobServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


from google.cloud import talent_v4beta1
import six


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

    client = talent_v4beta1.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, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode('utf-8')
    if isinstance(job_id, six.binary_type):
        job_id = job_id.decode('utf-8')
    name = client.job_path(project_id, tenant_id, job_id)

    client.delete_job(name)
    print('Deleted job.')


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


# Delete Job
def sample_delete_job(project_id, tenant_id, job_id)
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # job_id = "Company ID"
  formatted_name = job_client.class.job_path(project_id, tenant_id, job_id)

  job_client.delete_job(formatted_name)

  puts "Deleted job."

end

Best practices

Location fields

Whenever possible, we recommend providing the street address of a job in the addresses field. This helps with location detection and relevance. When a street-level address isn't available, enter as much information as possible. Addresses are supported up to the country level. Region designations (such as "Pacific Northwest") are not supported.

Cloud Talent Solution uses the data in the addresses field to populate the (output only) derivedInfo.locations field. When a full address isn't provided, the service uses other signals, such as the company name, to determine if a more complete address can be inferred for the job posting.

For example, if the location of a software position is specified as Mountain View, and the company to which the job is associated is Google, the service looks up the company object to see if a better street address is provided in the headquartersAddress field and whether that street address is in the same city as the job posting. If so, the service understands that the job is "likely" located at that street address and fills in the derivedInfo.locations field appropriately.

If company address data isn't available, the service uses a combination of proprietary knowledge and job/company information to inform the derivedInfo.locations field.

Because the derivedInfo.locations value is a best-guess effort, you may wish to use the derivedInfo.locations data, or the addresses field, when displaying the job address.

A job posting may have no more than 50 locations associated with it. If a job has more locations you can split the job into multiple jobs, each with a unique requisitionId (for example, 'ReqA' , 'ReqA-1', 'ReqA-2', and so on). Having multiple jobs with the same requisitionId, , companyName and languageCode is not allowed. If the original requisitionId must be preserved, a CustomAttribute should be used for storage. It's recommended you group the locations closest to each other in the same job for a better search experience.

Supported addresses

Any address that is recognized by the Google Maps Geocoding API (in the formattedAddress field) is accepted by Cloud Talent Solution. The service returns a 400 error if you attempt to create a Job or execute a search using an unrecognized address.

If a business address is listed incorrectly in the Google Maps Geocoding API, file a bug to have it corrected. Corrections may take up to 5 days to take effect.

Address autocompletion

Cloud Talent Solution does not provide autocomplete suggestions for locations. Use the Google Maps Places API, or other similar location services, to populate autocomplete suggestions.

Statewide, nationwide, and telecommute jobs

Jobs can be specified as statewide, nationwide, or telecommute by using the postingRegion field.

  • ADMINISTRATIVE_AREA and NATION Jobs are returned for any search with a specified location inside the state/country of the job posting. For example, if an ADMINISTRATIVE_AREA job has a location of "WA, USA" it is returned for searches with LocationFilter specifing "Seattle".

  • TELECOMMUTE Jobs are returned in any location-related search, but are treated as less relevant. They can be targeted in a search by setting the telecommutePreference flag to TELECOMMUTE_ALLOWED in the search's LocationFilter.

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Job Search documentation