[v4beta1] 求人の一括作成

求人を一括作成します。

このコードサンプルが含まれるドキュメント ページ

コンテキストで使用されているコードサンプルを表示するには、次のドキュメントをご覧ください。

コードサンプル

Python


from google.cloud import talent
import six

def 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.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 = f"projects/{project_id}/tenants/{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=parent, jobs=jobs)

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

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

Ruby

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
formatted_parent = job_service.tenant_path project: project_id, tenant: tenant_id

# job_application_url_one = "https://www.example.org/job-posting/123"
uris = [job_application_url_one]
application_info = { uris: uris }

# address_one = "1600 Amphitheatre Parkway, Mountain View, CA 94043"
addresses = [address_one]

# 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!"
# language_code_one = "en-US"
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
}

# job_application_url_two = "https://www.example.org/job-posting/123"
uris_2 = [job_application_url_two]
application_info_2 = { uris: uris_2 }

# address_two = "111 8th Avenue, New York, NY 10011"
addresses_2 = [address_two]

# 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!"
# language_code_two = "en-US"
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_service.batch_create_jobs parent: formatted_parent, jobs: jobs

# Block until operation complete
operation.wait_until_done!

raise operation.results.message if operation.error?

response = operation.response

puts "Batch response: #{response.inspect}"