일괄 작업

Cloud Talent Solution은 비동기 일괄 작업을 지원하므로 여러 개의 API 호출을 단일 HTTP 요청에 넣을 수 있습니다. 반환되는 응답 유형은 google.longrunning.operation입니다. google.longrunning.operationname 필드를 사용하여 GetOperation 메서드를 호출하여 일괄 작업의 상세한 상태를 검색할 수 있습니다.

일괄 처리를 사용하면 API 응답 시간의 지연 시간이 단축되고 처리량이 향상됩니다. 배치 API 응답을 성공적으로 수신하면 배치 요청이 생성되었음을 나타냅니다. 실제 데이터 처리는 비동기적으로 수행됩니다. 30일이 넘는 기간 전에 생성된 일괄 작업은 더 이상 GetOperation 메서드로 액세스할 수 없습니다.

각 배치는 요청 200개로 제한됩니다.

일괄 작업 진행률 표시기

batch create 또는 update 메서드를 호출하여 생성된 google.longrunning.operation은 다음 상태 중 하나에 해당합니다.

  • 미지정 상태(기본값)
  • 초기화 중
  • 처리 중
  • 성공
  • 실패

초기화 상태에서 success_count, failure_count, total_count 필드는 0으로 설정됩니다. 작업이 처리 중 상태인 경우 success_countfailure_count가 증가할 수 있습니다. 성공 상태에서 success_count + failure_count는 항상 total_count와 같으며 success_count > 0입니다. 실패 상태에서 success_count는 항상 0입니다.

채용정보 생성 일괄 처리

다음 코드 샘플은 채용정보 생성을 일괄 처리하는 방법을 보여줍니다.

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))

채용정보 업데이트 일괄 처리

다음 코드 샘플은 채용정보 업데이트를 일괄 처리하는 방법을 보여줍니다.

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))

취업정보를 일괄 삭제합니다.

다음 코드 샘플은 작업을 일괄적으로 삭제하는 방법을 보여줍니다.

Node.js


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

/**
 * Batch delete jobs using a filter
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenantd
 * @param filter {string} The filter string specifies the jobs to be deleted.
 * For example:
 * companyName = "projects/api-test-project/companies/123" AND equisitionId = "req-1"
 */
function sampleBatchDeleteJobs(projectId, tenantId, filter) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const filter = '[Query]';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const request = {
    parent: formattedParent,
    filter: filter,
  };
  client.batchDeleteJobs(request).catch(err => {
    console.error(err);
  });
  console.log('Batch deleted jobs from filter');
}