Ejemplo n.º 1
0
def list_jobs(project_id, tenant_id, filter_):
    """List Jobs"""

    client = talent.JobServiceClient()

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

    if isinstance(project_id, 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
    results = []
    for job in client.list_jobs(parent, filter_):
        results.append(job.name)
        print("Job name: {}".format(job.name))
        print("Job requisition ID: {}".format(job.requisition_id))
        print("Job title: {}".format(job.title))
        print("Job description: {}".format(job.description))
    return results
Ejemplo n.º 2
0
def get_job(project_id, tenant_id, job_id):
    """Get Job"""

    client = talent.JobServiceClient()

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

    if isinstance(project_id, 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=name)
    print(f"Job name: {response.name}")
    print(f"Requisition ID: {response.requisition_id}")
    print(f"Title: {response.title}")
    print(f"Description: {response.description}")
    print(f"Posting language: {response.language_code}")
    for address in response.addresses:
        print(f"Address: {address}")
    for email in response.application_info.emails:
        print(f"Email: {email}")
    for website_uri in response.application_info.uris:
        print(f"Website: {website_uri}")
Ejemplo n.º 3
0
def create_job(
    project_id,
    tenant_id,
    company_id,
    requisition_id,
    job_application_url,
):
    """Create Job"""

    client = talent.JobServiceClient()

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

    if isinstance(project_id, 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_id, six.binary_type):
        company_id = company_id.decode("utf-8")
    if isinstance(requisition_id, six.binary_type):
        requisition_id = requisition_id.decode("utf-8")
    if isinstance(job_application_url, six.binary_type):
        job_application_url = job_application_url.decode("utf-8")
    parent = client.tenant_path(project_id, tenant_id)
    uris = [job_application_url]
    application_info = {"uris": uris}
    addresses = [
        "1600 Amphitheatre Parkway, Mountain View, CA 94043",
        "111 8th Avenue, New York, NY 10011",
    ]
    job = {
        "company": company_id,
        "requisition_id": requisition_id,
        "title": "Software Developer",
        "description": "Develop, maintain the software solutions.",
        "application_info": application_info,
        "addresses": addresses,
        "language_code": "en-US",
    }

    response = client.create_job(parent, job)
    print("Created job: {}".format(response.name))
    return response.name
def search_jobs(project_id, tenant_id, query):
    """
    Search Jobs with histogram queries

    Args:
      query Histogram query
      More info on histogram facets, constants, and built-in functions:
      https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest
    """

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # query = 'count(base_compensation, [bucket(12, 20)])'

    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(query, six.binary_type):
        query = query.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = {
        "domain": domain,
        "session_id": session_id,
        "user_id": user_id
    }
    histogram_queries_element = {"histogram_query": query}
    histogram_queries = [histogram_queries_element]

    # Iterate over all results
    results = []
    request = talent.SearchJobsRequest(
        parent=parent,
        request_metadata=request_metadata,
        histogram_queries=histogram_queries,
    )
    for response_item in client.search_jobs(request=request).matching_jobs:
        print("Job summary: {response_item.job_summary}")
        print("Job title snippet: {response_item.job_title_snippet}")
        job = response_item.job
        results.append(job)
        print("Job name: {job.name}")
        print("Job title: {job.title}")
    return results
Ejemplo n.º 5
0
def search_jobs(project_id, tenant_id):
    """Search Jobs using commute distance"""

    client = talent.JobServiceClient()

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

    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")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = talent.RequestMetadata(domain=domain,
                                              session_id=session_id,
                                              user_id=user_id)
    commute_method = talent.CommuteMethod.TRANSIT
    seconds = 1800
    travel_duration = {"seconds": seconds}
    latitude = 37.422408
    longitude = -122.084068
    start_coordinates = {"latitude": latitude, "longitude": longitude}
    commute_filter = talent.CommuteFilter(
        commute_method=commute_method,
        travel_duration=travel_duration,
        start_coordinates=start_coordinates,
    )
    job_query = talent.JobQuery(commute_filter=commute_filter)

    # Iterate over all results
    results = []
    request = talent.SearchJobsRequest(
        parent=parent,
        request_metadata=request_metadata,
        job_query=job_query,
    )
    for response_item in client.search_jobs(request=request).matching_jobs:
        print(f"Job summary: {response_item.job_summary}")
        print(f"Job title snippet: {response_item.job_title_snippet}")
        job = response_item.job
        results.append(job.name)
        print(f"Job name: {job.name}")
        print(f"Job title: {job.title}")
    return results
def search_jobs(project_id, tenant_id):
    """Search Jobs using custom rankings"""

    client = talent.JobServiceClient()

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

    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")
    parent = client.tenant_path(project_id, tenant_id)
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = {
        "domain": domain,
        "session_id": session_id,
        "user_id": user_id
    }
    importance_level = enums.SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME
    ranking_expression = "(someFieldLong + 25) * 0.25"
    custom_ranking_info = {
        "importance_level": importance_level,
        "ranking_expression": ranking_expression,
    }
    order_by = "custom_ranking desc"

    # Iterate over all results
    results = []
    for response_item in client.search_jobs(
            parent,
            request_metadata,
            custom_ranking_info=custom_ranking_info,
            order_by=order_by,
    ):
        print("Job summary: {}".format(response_item.job_summary))
        print("Job title snippet: {}".format(response_item.job_title_snippet))
        job = response_item.job
        results.append(job.name)
        print("Job name: {}".format(job.name))
        print("Job title: {}".format(job.title))
    return results
Ejemplo n.º 7
0
def delete_job(project_id, tenant_id, job_id):
    """Delete Job"""

    client = talent.JobServiceClient()

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

    if isinstance(project_id, 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=name)
    print("Deleted job.")
def search_jobs(project_id, tenant_id):
    """Search Jobs using commute distance"""

    client = talent.JobServiceClient()

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

    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")
    parent = client.tenant_path(project_id, tenant_id)
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = {"domain": domain, "session_id": session_id, "user_id": user_id}
    commute_method = enums.CommuteMethod.TRANSIT
    seconds = 1800
    travel_duration = {"seconds": seconds}
    latitude = 37.422408
    longitude = -122.084068
    start_coordinates = {"latitude": latitude, "longitude": longitude}
    commute_filter = {
        "commute_method": commute_method,
        "travel_duration": travel_duration,
        "start_coordinates": start_coordinates,
    }
    job_query = {"commute_filter": commute_filter}

    # Iterate over all results
    results = []
    for response_item in client.search_jobs(
        parent, request_metadata, job_query=job_query
    ):
        print("Job summary: {}".format(response_item.job_summary))
        print("Job title snippet: {}".format(response_item.job_title_snippet))
        job = response_item.job
        results.append(job.name)
        print("Job name: {}".format(job.name))
        print("Job title: {}".format(job.title))
    return results
def create_job(project_id, tenant_id, company_id, requisition_id):
    """Create Job with Custom Attributes"""

    client = talent.JobServiceClient()

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

    if isinstance(project_id, 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_id, six.binary_type):
        company_id = company_id.decode("utf-8")

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

    parent = client.tenant_path(project_id, tenant_id)

    job = {
        "company": company_id,
        "title": "Software Engineer",
        "requisition_id": requisition_id,
        "description": "This is a description of this job",
        "language_code": "en-US",
        "custom_attributes": {
            "FOR_STUDENTS": custom_attribute
        },
    }

    response = client.create_job(parent, job)
    print("Created job: {}".format(response.name))
    return response.name
Ejemplo n.º 10
0
def search_jobs(project_id, tenant_id):
    """Search Jobs using custom rankings"""

    client = talent.JobServiceClient()

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

    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")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = talent.RequestMetadata(domain=domain,
                                              session_id=session_id,
                                              user_id=user_id)
    importance_level = talent.SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME
    ranking_expression = "(someFieldLong + 25) * 0.25"
    custom_ranking_info = {
        "importance_level": importance_level,
        "ranking_expression": ranking_expression,
    }
    order_by = "custom_ranking desc"

    # Iterate over all results
    results = []
    request = talent.SearchJobsRequest(parent=parent,
                                       request_metadata=request_metadata,
                                       custom_ranking_info=custom_ranking_info,
                                       order_by=order_by)
    for response_item in client.search_jobs(request=request).matching_jobs:
        print(f"Job summary: {response_item.job_summary}")
        print(f"Job title snippet: {response_item.job_title_snippet}")
        job = response_item.job
        results.append(job.name)
        print(f"Job name: {job.name}")
        print(f"Job title: {job.title}")
    return results
Ejemplo n.º 11
0
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))
Ejemplo n.º 12
0

class JobInUpdate(JobInCreate):
    name: Optional[str]


class JobInRetrieve(JobInUpdate):
    # output
    posting_create_time: Optional[str]
    posting_update_time: Optional[str]
    company_display_name: Optional[str]
    derived_info: Optional[DerivedInfo]
    processing_options: Optional[ProcessingOptions]


client_job = talent.JobServiceClient()


class Job(JobInRetrieve):
    _tenant: Optional[Tenant] = PrivateAttr(None)

    def create(self, tenant: Optional[Tenant] = None):
        """
           Create Job
           https://cloud.google.com/talent-solution/job-search/docs/reference/rest/v4/projects.companys.jobs/create
        """
        if tenant:
            self._tenant = tenant

        job = JobInCreate(**self.dict())
        # job = job.dict(exclude_unset=True, exclude_none=True)