Batch operations

Cloud Talent Solution supports asynchronous batch operations, which allows you to put multiple API calls into a single HTTP request. The returned response type is google.longrunning.operation. The detailed status of the batch operation can be retrieved by calling the GetOperation method using the name field in google.longrunning.operation.

Using batching yields decreased latency in the API response time and higher throughput. Note that successfully receiving a batch API response indicates only that the batch request has been created. Actual data processing is done asynchronously. Batch operations created more than 30 days ago will be no longer accessible by the GetOperation method.

Each batch is limited to 200 requests.

Batch operation progress indicator

The google.longrunning.operation created by calling the batch create or update method falls under one of the following states:

  • STATE_UNSPECIFIED (the default value)
  • INITIALIZING
  • PROCESSING
  • SUCCEEDED
  • FAILED

In state INITIALIZING, success_count, failure_count, and total_count fields are set to 0. If the operation is in state PROCESSING the success_count and failure_count may increase. In state SUCCEEDED, success_count + failure_count is always equal to total_count, and success_count > 0. In state FAILED, success_count is always 0.

Batch create jobs

The following code sample demonstrates how to batch create jobs:

Java


public List<Job> batchCreateJobs(List<Job> jobs)
    throws ApiException, ExecutionException, InterruptedException {
  try {
    BatchCreateJobsRequest batchCreateJobsRequest =
        BatchCreateJobsRequest.newBuilder().setParent(FORMATTED_PARENT).addAllJobs(jobs).build();

    JobOperationResult jobOperationResult = jobServiceClient
        .batchCreateJobsAsync(batchCreateJobsRequest).get();
    System.out.println("======jobOperationResult======\n" + jobOperationResult);
    List<Job> jobsCreated = new ArrayList<>();
    for (JobResult jobResult : jobOperationResult.getJobResultsList()) {
      jobsCreated.add(jobResult.getJob());
    }
    System.out.println("======Jobs created======\n" + jobsCreated);
    return jobsCreated;
  } catch (ApiException e) {
    System.out.println("Got exception while batch creating jobs");
    throw e;
  }
}

PHP

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

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

/**
 * Batch Create Jobs.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleBatchCreateJobs($projectId, $tenantId, $companyNameOne, $requisitionIdOne, $titleOne, $descriptionOne, $jobApplicationUrlOne, $addressOne, $languageCodeOne, $companyNameTwo, $requisitionIdTwo, $titleTwo, $descriptionTwo, $jobApplicationUrlTwo, $addressTwo, $languageCodeTwo)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $companyNameOne = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionIdOne = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $titleOne = 'Software Engineer';
    // $descriptionOne = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrlOne = 'https://www.example.org/job-posting/123';
    // $addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
    // $languageCodeOne = 'en-US';
    // $companyNameTwo = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionIdTwo = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $titleTwo = 'Quality Assurance';
    // $descriptionTwo = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrlTwo = 'https://www.example.org/job-posting/123';
    // $addressTwo = '111 8th Avenue, New York, NY 10011';
    // $languageCodeTwo = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $uris = [$jobApplicationUrlOne];
    $applicationInfo = new Job_ApplicationInfo();
    $applicationInfo->setUris($uris);
    $addresses = [$addressOne];
    $jobsElement = new Job();
    $jobsElement->setCompany($companyNameOne);
    $jobsElement->setRequisitionId($requisitionIdOne);
    $jobsElement->setTitle($titleOne);
    $jobsElement->setDescription($descriptionOne);
    $jobsElement->setApplicationInfo($applicationInfo);
    $jobsElement->setAddresses($addresses);
    $jobsElement->setLanguageCode($languageCodeOne);
    $uris2 = [$jobApplicationUrlTwo];
    $applicationInfo2 = new Job_ApplicationInfo();
    $applicationInfo2->setUris($uris2);
    $addresses2 = [$addressTwo];
    $jobsElement2 = new Job();
    $jobsElement2->setCompany($companyNameTwo);
    $jobsElement2->setRequisitionId($requisitionIdTwo);
    $jobsElement2->setTitle($titleTwo);
    $jobsElement2->setDescription($descriptionTwo);
    $jobsElement2->setApplicationInfo($applicationInfo2);
    $jobsElement2->setAddresses($addresses2);
    $jobsElement2->setLanguageCode($languageCodeTwo);
    $jobs = [$jobsElement, $jobsElement2];

    try {
        $operationResponse = $jobServiceClient->batchCreateJobs($formattedParent, $jobs);
        $operationResponse->pollUntilComplete();
        if ($operationResponse->operationSucceeded()) {
            $response = $operationResponse->getResult();
            printf('Batch response: %s'.PHP_EOL, print_r($response, true));
        } else {
            $error = $operationResponse->getError();
            // handleError($error)
        }
    } finally {
        $jobServiceClient->close();
    }

}

Node.js


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

/**
 * Batch Create Jobs
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
async function sampleBatchCreateJobs(projectId, tenantId, companyNameOne, requisitionIdOne, titleOne, descriptionOne, jobApplicationUrlOne, addressOne, languageCodeOne, companyNameTwo, requisitionIdTwo, titleTwo, descriptionTwo, jobApplicationUrlTwo, addressTwo, languageCodeTwo) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const companyNameOne = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionIdOne = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const titleOne = 'Software Engineer';
  // const descriptionOne = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrlOne = 'https://www.example.org/job-posting/123';
  // const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
  // const languageCodeOne = 'en-US';
  // const companyNameTwo = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionIdTwo = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const titleTwo = 'Quality Assurance';
  // const descriptionTwo = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrlTwo = 'https://www.example.org/job-posting/123';
  // const addressTwo = '111 8th Avenue, New York, NY 10011';
  // const languageCodeTwo = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const uris = [jobApplicationUrlOne];
  const applicationInfo = {
    uris: uris,
  };
  const addresses = [addressOne];
  const jobsElement = {
    company: companyNameOne,
    requisitionId: requisitionIdOne,
    title: titleOne,
    description: descriptionOne,
    applicationInfo: applicationInfo,
    addresses: addresses,
    languageCode: languageCodeOne,
  };
  const uris2 = [jobApplicationUrlTwo];
  const applicationInfo2 = {
    uris: uris2,
  };
  const addresses2 = [addressTwo];
  const jobsElement2 = {
    company: companyNameTwo,
    requisitionId: requisitionIdTwo,
    title: titleTwo,
    description: descriptionTwo,
    applicationInfo: applicationInfo2,
    addresses: addresses2,
    languageCode: languageCodeTwo,
  };
  const jobs = [jobsElement, jobsElement2];
  const request = {
    parent: formattedParent,
    jobs: jobs,
  };

  // Create a job whose results you can either wait for now, or get later
  const [operation] = await client.batchCreateJobs(request);

  // Get a Promise representation of the final result of the job
  const [response] = await operation.promise();

  console.log(`Batch response: ${response}`);
}

Python


from google.cloud import talent_v4beta1
import six


def sample_batch_create_jobs(project_id, tenant_id, company_name_one,
                             requisition_id_one, title_one, description_one,
                             job_application_url_one, address_one,
                             language_code_one, company_name_two,
                             requisition_id_two, title_two, description_two,
                             job_application_url_two, address_two,
                             language_code_two):
    """
    Batch Create Jobs

    Args:
      project_id Your Google Cloud Project ID
      tenant_id Identifier of the Tenant
    """

    client = talent_v4beta1.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_name_one = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id_one = 'Job requisition ID, aka Posting ID. Unique per job.'
    # title_one = 'Software Engineer'
    # description_one = 'This is a description of this <i>wonderful</i> job!'
    # job_application_url_one = 'https://www.example.org/job-posting/123'
    # address_one = '1600 Amphitheatre Parkway, Mountain View, CA 94043'
    # language_code_one = 'en-US'
    # company_name_two = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id_two = 'Job requisition ID, aka Posting ID. Unique per job.'
    # title_two = 'Quality Assurance'
    # description_two = 'This is a description of this <i>wonderful</i> job!'
    # job_application_url_two = 'https://www.example.org/job-posting/123'
    # address_two = '111 8th Avenue, New York, NY 10011'
    # language_code_two = '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_one, six.binary_type):
        company_name_one = company_name_one.decode('utf-8')
    if isinstance(requisition_id_one, six.binary_type):
        requisition_id_one = requisition_id_one.decode('utf-8')
    if isinstance(title_one, six.binary_type):
        title_one = title_one.decode('utf-8')
    if isinstance(description_one, six.binary_type):
        description_one = description_one.decode('utf-8')
    if isinstance(job_application_url_one, six.binary_type):
        job_application_url_one = job_application_url_one.decode('utf-8')
    if isinstance(address_one, six.binary_type):
        address_one = address_one.decode('utf-8')
    if isinstance(language_code_one, six.binary_type):
        language_code_one = language_code_one.decode('utf-8')
    if isinstance(company_name_two, six.binary_type):
        company_name_two = company_name_two.decode('utf-8')
    if isinstance(requisition_id_two, six.binary_type):
        requisition_id_two = requisition_id_two.decode('utf-8')
    if isinstance(title_two, six.binary_type):
        title_two = title_two.decode('utf-8')
    if isinstance(description_two, six.binary_type):
        description_two = description_two.decode('utf-8')
    if isinstance(job_application_url_two, six.binary_type):
        job_application_url_two = job_application_url_two.decode('utf-8')
    if isinstance(address_two, six.binary_type):
        address_two = address_two.decode('utf-8')
    if isinstance(language_code_two, six.binary_type):
        language_code_two = language_code_two.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)
    uris = [job_application_url_one]
    application_info = {'uris': uris}
    addresses = [address_one]
    jobs_element = {
        'company': company_name_one,
        'requisition_id': requisition_id_one,
        'title': title_one,
        'description': description_one,
        'application_info': application_info,
        'addresses': addresses,
        'language_code': language_code_one
    }
    uris_2 = [job_application_url_two]
    application_info_2 = {'uris': uris_2}
    addresses_2 = [address_two]
    jobs_element_2 = {
        'company': company_name_two,
        'requisition_id': requisition_id_two,
        'title': title_two,
        'description': description_two,
        'application_info': application_info_2,
        'addresses': addresses_2,
        'language_code': language_code_two
    }
    jobs = [jobs_element, jobs_element_2]

    operation = client.batch_create_jobs(parent, jobs)

    print('Waiting for operation to complete...')
    response = operation.result()

    print('Batch response: {}'.format(response))


Ruby


 # Batch Create Jobs
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenant
def sample_batch_create_jobs(project_id, tenant_id, company_name_one, requisition_id_one, title_one, description_one, job_application_url_one, address_one, language_code_one, company_name_two, requisition_id_two, title_two, description_two, job_application_url_two, address_two, language_code_two)
  # Instantiate a client
  job_client = Google::Cloud::Talent::Job.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # company_name_one = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id_one = "Job requisition ID, aka Posting ID. Unique per job."
  # title_one = "Software Engineer"
  # description_one = "This is a description of this <i>wonderful</i> job!"
  # job_application_url_one = "https://www.example.org/job-posting/123"
  # address_one = "1600 Amphitheatre Parkway, Mountain View, CA 94043"
  # language_code_one = "en-US"
  # company_name_two = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id_two = "Job requisition ID, aka Posting ID. Unique per job."
  # title_two = "Quality Assurance"
  # description_two = "This is a description of this <i>wonderful</i> job!"
  # job_application_url_two = "https://www.example.org/job-posting/123"
  # address_two = "111 8th Avenue, New York, NY 10011"
  # language_code_two = "en-US"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  uris = [job_application_url_one]
  application_info = { uris: uris }
  addresses = [address_one]
  jobs_element = {
    company: company_name_one,
    requisition_id: requisition_id_one,
    title: title_one,
    description: description_one,
    application_info: application_info,
    addresses: addresses,
    language_code: language_code_one
  }
  uris_2 = [job_application_url_two]
  application_info_2 = { uris: uris_2 }
  addresses_2 = [address_two]
  jobs_element_2 = {
    company: company_name_two,
    requisition_id: requisition_id_two,
    title: title_two,
    description: description_two,
    application_info: application_info_2,
    addresses: addresses_2,
    language_code: language_code_two
  }
  jobs = [jobs_element, jobs_element_2]

  # Make the long-running operation request
  operation = job_client.batch_create_jobs(formatted_parent, jobs)

  # Block until operation complete
  operation.wait_until_done!

  raise operation.results.message if operation.error?

  results = operation.response.results

  puts "Batch response: #{response}"

end

Batch update jobs

The following code sample demonstrates how to batch update jobs:

Java


public List<Job> batchUpdateJobs(List<Job> jobs)
    throws ApiException, ExecutionException, InterruptedException {
  try {
    BatchUpdateJobsRequest batchUpdateJobsRequest =
        BatchUpdateJobsRequest.newBuilder().setParent(FORMATTED_PARENT).addAllJobs(jobs).build();

    JobOperationResult jobOperationResult = jobServiceClient
        .batchUpdateJobsAsync(batchUpdateJobsRequest).get();
    List<Job> jobsUpdated = new ArrayList<>();
    for (JobResult jobResult : jobOperationResult.getJobResultsList()) {
      jobsUpdated.add(jobResult.getJob());
    }
    System.out.println("======Jobs updated======\n" + jobsUpdated);
    return jobsUpdated;
  } catch (ApiException e) {
    System.out.println("Got exception while batch updating jobs");
    throw e;
  }
}

PHP

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

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

/**
 * Batch Update Jobs.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleBatchUpdateJobs($projectId, $tenantId, $jobNameOne, $companyNameOne, $requisitionIdOne, $titleOne, $descriptionOne, $jobApplicationUrlOne, $addressOne, $languageCodeOne, $jobNameTwo, $companyNameTwo, $requisitionIdTwo, $titleTwo, $descriptionTwo, $jobApplicationUrlTwo, $addressTwo, $languageCodeTwo)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $jobNameOne = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id';
    // $companyNameOne = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionIdOne = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $titleOne = 'Software Engineer';
    // $descriptionOne = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrlOne = 'https://www.example.org/job-posting/123';
    // $addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
    // $languageCodeOne = 'en-US';
    // $jobNameTwo = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id';
    // $companyNameTwo = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionIdTwo = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $titleTwo = 'Quality Assurance';
    // $descriptionTwo = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrlTwo = 'https://www.example.org/job-posting/123';
    // $addressTwo = '111 8th Avenue, New York, NY 10011';
    // $languageCodeTwo = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $uris = [$jobApplicationUrlOne];
    $applicationInfo = new Job_ApplicationInfo();
    $applicationInfo->setUris($uris);
    $addresses = [$addressOne];
    $jobsElement = new Job();
    $jobsElement->setName($jobNameOne);
    $jobsElement->setCompany($companyNameOne);
    $jobsElement->setRequisitionId($requisitionIdOne);
    $jobsElement->setTitle($titleOne);
    $jobsElement->setDescription($descriptionOne);
    $jobsElement->setApplicationInfo($applicationInfo);
    $jobsElement->setAddresses($addresses);
    $jobsElement->setLanguageCode($languageCodeOne);
    $uris2 = [$jobApplicationUrlTwo];
    $applicationInfo2 = new Job_ApplicationInfo();
    $applicationInfo2->setUris($uris2);
    $addresses2 = [$addressTwo];
    $jobsElement2 = new Job();
    $jobsElement2->setName($jobNameTwo);
    $jobsElement2->setCompany($companyNameTwo);
    $jobsElement2->setRequisitionId($requisitionIdTwo);
    $jobsElement2->setTitle($titleTwo);
    $jobsElement2->setDescription($descriptionTwo);
    $jobsElement2->setApplicationInfo($applicationInfo2);
    $jobsElement2->setAddresses($addresses2);
    $jobsElement2->setLanguageCode($languageCodeTwo);
    $jobs = [$jobsElement, $jobsElement2];

    try {
        $operationResponse = $jobServiceClient->batchUpdateJobs($formattedParent, $jobs);
        $operationResponse->pollUntilComplete();
        if ($operationResponse->operationSucceeded()) {
            $response = $operationResponse->getResult();
            printf('Batch response: %s'.PHP_EOL, print_r($response, true));
        } else {
            $error = $operationResponse->getError();
            // handleError($error)
        }
    } finally {
        $jobServiceClient->close();
    }

}

Node.js


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

/**
 * Batch Update Jobs
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
async function sampleBatchUpdateJobs(projectId, tenantId, jobNameOne, companyNameOne, requisitionIdOne, titleOne, descriptionOne, jobApplicationUrlOne, addressOne, languageCodeOne, jobNameTwo, companyNameTwo, requisitionIdTwo, titleTwo, descriptionTwo, jobApplicationUrlTwo, addressTwo, languageCodeTwo) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobNameOne = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id';
  // const companyNameOne = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionIdOne = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const titleOne = 'Software Engineer';
  // const descriptionOne = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrlOne = 'https://www.example.org/job-posting/123';
  // const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
  // const languageCodeOne = 'en-US';
  // const jobNameTwo = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id';
  // const companyNameTwo = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionIdTwo = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const titleTwo = 'Quality Assurance';
  // const descriptionTwo = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrlTwo = 'https://www.example.org/job-posting/123';
  // const addressTwo = '111 8th Avenue, New York, NY 10011';
  // const languageCodeTwo = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const uris = [jobApplicationUrlOne];
  const applicationInfo = {
    uris: uris,
  };
  const addresses = [addressOne];
  const jobsElement = {
    name: jobNameOne,
    company: companyNameOne,
    requisitionId: requisitionIdOne,
    title: titleOne,
    description: descriptionOne,
    applicationInfo: applicationInfo,
    addresses: addresses,
    languageCode: languageCodeOne,
  };
  const uris2 = [jobApplicationUrlTwo];
  const applicationInfo2 = {
    uris: uris2,
  };
  const addresses2 = [addressTwo];
  const jobsElement2 = {
    name: jobNameTwo,
    company: companyNameTwo,
    requisitionId: requisitionIdTwo,
    title: titleTwo,
    description: descriptionTwo,
    applicationInfo: applicationInfo2,
    addresses: addresses2,
    languageCode: languageCodeTwo,
  };
  const jobs = [jobsElement, jobsElement2];
  const request = {
    parent: formattedParent,
    jobs: jobs,
  };

  // Create a job whose results you can either wait for now, or get later
  const [operation] = await client.batchUpdateJobs(request);

  // Get a Promise representation of the final result of the job
  const [response] = await operation.promise();

  console.log(`Batch response: ${response}`);
}

Python


from google.cloud import talent_v4beta1
import six


def sample_batch_update_jobs(project_id, tenant_id, job_name_one,
                             company_name_one, requisition_id_one, title_one,
                             description_one, job_application_url_one,
                             address_one, language_code_one, job_name_two,
                             company_name_two, requisition_id_two, title_two,
                             description_two, job_application_url_two,
                             address_two, language_code_two):
    """
    Batch Update Jobs

    Args:
      project_id Your Google Cloud Project ID
      tenant_id Identifier of the Tenant
    """

    client = talent_v4beta1.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_name_one = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id'
    # company_name_one = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id_one = 'Job requisition ID, aka Posting ID. Unique per job.'
    # title_one = 'Software Engineer'
    # description_one = 'This is a description of this <i>wonderful</i> job!'
    # job_application_url_one = 'https://www.example.org/job-posting/123'
    # address_one = '1600 Amphitheatre Parkway, Mountain View, CA 94043'
    # language_code_one = 'en-US'
    # job_name_two = 'job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id'
    # company_name_two = 'Company name, e.g. projects/your-project/companies/company-id'
    # requisition_id_two = 'Job requisition ID, aka Posting ID. Unique per job.'
    # title_two = 'Quality Assurance'
    # description_two = 'This is a description of this <i>wonderful</i> job!'
    # job_application_url_two = 'https://www.example.org/job-posting/123'
    # address_two = '111 8th Avenue, New York, NY 10011'
    # language_code_two = '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(job_name_one, six.binary_type):
        job_name_one = job_name_one.decode('utf-8')
    if isinstance(company_name_one, six.binary_type):
        company_name_one = company_name_one.decode('utf-8')
    if isinstance(requisition_id_one, six.binary_type):
        requisition_id_one = requisition_id_one.decode('utf-8')
    if isinstance(title_one, six.binary_type):
        title_one = title_one.decode('utf-8')
    if isinstance(description_one, six.binary_type):
        description_one = description_one.decode('utf-8')
    if isinstance(job_application_url_one, six.binary_type):
        job_application_url_one = job_application_url_one.decode('utf-8')
    if isinstance(address_one, six.binary_type):
        address_one = address_one.decode('utf-8')
    if isinstance(language_code_one, six.binary_type):
        language_code_one = language_code_one.decode('utf-8')
    if isinstance(job_name_two, six.binary_type):
        job_name_two = job_name_two.decode('utf-8')
    if isinstance(company_name_two, six.binary_type):
        company_name_two = company_name_two.decode('utf-8')
    if isinstance(requisition_id_two, six.binary_type):
        requisition_id_two = requisition_id_two.decode('utf-8')
    if isinstance(title_two, six.binary_type):
        title_two = title_two.decode('utf-8')
    if isinstance(description_two, six.binary_type):
        description_two = description_two.decode('utf-8')
    if isinstance(job_application_url_two, six.binary_type):
        job_application_url_two = job_application_url_two.decode('utf-8')
    if isinstance(address_two, six.binary_type):
        address_two = address_two.decode('utf-8')
    if isinstance(language_code_two, six.binary_type):
        language_code_two = language_code_two.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)
    uris = [job_application_url_one]
    application_info = {'uris': uris}
    addresses = [address_one]
    jobs_element = {
        'name': job_name_one,
        'company': company_name_one,
        'requisition_id': requisition_id_one,
        'title': title_one,
        'description': description_one,
        'application_info': application_info,
        'addresses': addresses,
        'language_code': language_code_one
    }
    uris_2 = [job_application_url_two]
    application_info_2 = {'uris': uris_2}
    addresses_2 = [address_two]
    jobs_element_2 = {
        'name': job_name_two,
        'company': company_name_two,
        'requisition_id': requisition_id_two,
        'title': title_two,
        'description': description_two,
        'application_info': application_info_2,
        'addresses': addresses_2,
        'language_code': language_code_two
    }
    jobs = [jobs_element, jobs_element_2]

    operation = client.batch_update_jobs(parent, jobs)

    print('Waiting for operation to complete...')
    response = operation.result()

    print('Batch response: {}'.format(response))


Ruby


 # Batch Update Jobs
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenant
def sample_batch_update_jobs(project_id, tenant_id, job_name_one, company_name_one, requisition_id_one, title_one, description_one, job_application_url_one, address_one, language_code_one, job_name_two, company_name_two, requisition_id_two, title_two, description_two, job_application_url_two, address_two, language_code_two)
  # Instantiate a client
  job_client = Google::Cloud::Talent::Job.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # job_name_one = "job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id"
  # company_name_one = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id_one = "Job requisition ID, aka Posting ID. Unique per job."
  # title_one = "Software Engineer"
  # description_one = "This is a description of this <i>wonderful</i> job!"
  # job_application_url_one = "https://www.example.org/job-posting/123"
  # address_one = "1600 Amphitheatre Parkway, Mountain View, CA 94043"
  # language_code_one = "en-US"
  # job_name_two = "job name, e.g. projects/your-project/tenants/tenant-id/jobs/job-id"
  # company_name_two = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id_two = "Job requisition ID, aka Posting ID. Unique per job."
  # title_two = "Quality Assurance"
  # description_two = "This is a description of this <i>wonderful</i> job!"
  # job_application_url_two = "https://www.example.org/job-posting/123"
  # address_two = "111 8th Avenue, New York, NY 10011"
  # language_code_two = "en-US"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  uris = [job_application_url_one]
  application_info = { uris: uris }
  addresses = [address_one]
  jobs_element = {
    name: job_name_one,
    company: company_name_one,
    requisition_id: requisition_id_one,
    title: title_one,
    description: description_one,
    application_info: application_info,
    addresses: addresses,
    language_code: language_code_one
  }
  uris_2 = [job_application_url_two]
  application_info_2 = { uris: uris_2 }
  addresses_2 = [address_two]
  jobs_element_2 = {
    name: job_name_two,
    company: company_name_two,
    requisition_id: requisition_id_two,
    title: title_two,
    description: description_two,
    application_info: application_info_2,
    addresses: addresses_2,
    language_code: language_code_two
  }
  jobs = [jobs_element, jobs_element_2]

  # Make the long-running operation request
  operation = job_client.batch_update_jobs(formatted_parent, jobs)

  # Block until operation complete
  operation.wait_until_done!

  raise operation.results.message if operation.error?

  results = operation.response.results

  puts "Batch response: #{response}"

end

Czy ta strona była pomocna? Podziel się z nami swoją opinią:

Wyślij opinię na temat...

Job Search documentation