Search in sources :

Example 1 with JobServiceClient

use of com.google.cloud.talent.v4beta1.JobServiceClient in project java-docs-samples by GoogleCloudPlatform.

the class CustomRankingSearchJobs method searchCustomRankingJobs.

// Search Jobs using custom rankings.
public static void searchCustomRankingJobs(String projectId, String tenantId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        String domain = "www.example.com";
        String sessionId = "Hashed session identifier";
        String userId = "Hashed user identifier";
        RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
        SearchJobsRequest.CustomRankingInfo.ImportanceLevel importanceLevel = SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME;
        String rankingExpression = "(someFieldLong + 25) * 0.25";
        SearchJobsRequest.CustomRankingInfo customRankingInfo = SearchJobsRequest.CustomRankingInfo.newBuilder().setImportanceLevel(importanceLevel).setRankingExpression(rankingExpression).build();
        String orderBy = "custom_ranking desc";
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setCustomRankingInfo(customRankingInfo).setOrderBy(orderBy).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
            System.out.format("Job summary: %s%n", responseItem.getJobSummary());
            System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet());
            Job job = responseItem.getJob();
            System.out.format("Job name: %s%n", job.getName());
            System.out.format("Job title: %s%n", job.getTitle());
        }
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4beta1.SearchJobsResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 2 with JobServiceClient

use of com.google.cloud.talent.v4beta1.JobServiceClient in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchCreateJobCustomAttributes method createJob.

// Create Job with Custom Attributes.
public static void createJob(String projectId, String tenantId, String companyId, String requisitionId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        // 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
        CustomAttribute customAttribute = CustomAttribute.newBuilder().addStringValues("Internship").addStringValues("Apprenticeship").setFilterable(true).build();
        Job job = Job.newBuilder().setCompany(companyId).setTitle("Software Developer I").setDescription("This is a description of this <i>wonderful</i> job!").putCustomAttributes("FOR_STUDENTS", customAttribute).setRequisitionId(requisitionId).setLanguageCode("en-US").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());
    }
}
Also used : TenantName(com.google.cloud.talent.v4beta1.TenantName) CustomAttribute(com.google.cloud.talent.v4beta1.CustomAttribute) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 3 with JobServiceClient

use of com.google.cloud.talent.v4beta1.JobServiceClient in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchGetJob method getJob.

// Get Job.
public static void getJob(String projectId, String tenantId, String jobId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId);
        GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
        Job response = jobServiceClient.getJob(request);
        System.out.format("Job name: %s%n", response.getName());
        System.out.format("Requisition ID: %s%n", response.getRequisitionId());
        System.out.format("Title: %s%n", response.getTitle());
        System.out.format("Description: %s%n", response.getDescription());
        System.out.format("Posting language: %s%n", response.getLanguageCode());
        for (String address : response.getAddressesList()) {
            System.out.format("Address: %s%n", address);
        }
        for (String email : response.getApplicationInfo().getEmailsList()) {
            System.out.format("Email: %s%n", email);
        }
        for (String websiteUri : response.getApplicationInfo().getUrisList()) {
            System.out.format("Website: %s%n", websiteUri);
        }
    }
}
Also used : GetJobRequest(com.google.cloud.talent.v4beta1.GetJobRequest) JobName(com.google.cloud.talent.v4beta1.JobName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 4 with JobServiceClient

use of com.google.cloud.talent.v4beta1.JobServiceClient in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchListJobs method listJobs.

// Search Jobs with histogram queries.
public static void listJobs(String projectId, String tenantId, String filter) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            System.out.format("Job name: %s%n", responseItem.getName());
            System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId());
            System.out.format("Job title: %s%n", responseItem.getTitle());
            System.out.format("Job description: %s%n", responseItem.getDescription());
        }
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4beta1.ListJobsRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 5 with JobServiceClient

use of com.google.cloud.talent.v4beta1.JobServiceClient in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchDeleteJob method deleteJob.

// Delete Job.
public static void deleteJob(String projectId, String tenantId, String jobId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId);
        DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name.toString()).build();
        jobServiceClient.deleteJob(request);
        System.out.println("Deleted job.");
    }
}
Also used : DeleteJobRequest(com.google.cloud.talent.v4beta1.DeleteJobRequest) JobName(com.google.cloud.talent.v4beta1.JobName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient)

Aggregations

JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)8 Job (com.google.cloud.talent.v4beta1.Job)7 TenantName (com.google.cloud.talent.v4beta1.TenantName)6 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)3 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)3 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)2 JobName (com.google.cloud.talent.v4beta1.JobName)2 CommuteFilter (com.google.cloud.talent.v4beta1.CommuteFilter)1 CommuteMethod (com.google.cloud.talent.v4beta1.CommuteMethod)1 CustomAttribute (com.google.cloud.talent.v4beta1.CustomAttribute)1 DeleteJobRequest (com.google.cloud.talent.v4beta1.DeleteJobRequest)1 GetJobRequest (com.google.cloud.talent.v4beta1.GetJobRequest)1 HistogramQuery (com.google.cloud.talent.v4beta1.HistogramQuery)1 JobQuery (com.google.cloud.talent.v4beta1.JobQuery)1 ListJobsRequest (com.google.cloud.talent.v4beta1.ListJobsRequest)1 Duration (com.google.protobuf.Duration)1 LatLng (com.google.type.LatLng)1