Search in sources :

Example 26 with RequestMetadata

use of com.google.cloud.talent.v4.RequestMetadata in project java-talent by googleapis.

the class JobSearchHistogramSearch method sampleSearchJobs.

/**
 * Search Jobs with histogram queries
 *
 * @param 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
 */
public static void sampleSearchJobs(String projectId, String tenantId, String query) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName 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();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        List<HistogramQuery> histogramQueries = Arrays.asList(histogramQueriesElement);
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addAllHistogramQueries(histogramQueries).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
            System.out.printf("Job summary: %s\n", responseItem.getJobSummary());
            System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet());
            Job job = responseItem.getJob();
            System.out.printf("Job name: %s\n", job.getName());
            System.out.printf("Job title: %s\n", job.getTitle());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) HistogramQuery(com.google.cloud.talent.v4beta1.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Aggregations

RequestMetadata (build.bazel.remote.execution.v2.RequestMetadata)17 Digest (build.bazel.remote.execution.v2.Digest)11 ByteString (com.google.protobuf.ByteString)8 ServerCallStreamObserver (io.grpc.stub.ServerCallStreamObserver)7 ActionResult (build.bazel.remote.execution.v2.ActionResult)6 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)6 ExecuteResponse (build.bazel.remote.execution.v2.ExecuteResponse)6 ActionKey (build.buildfarm.common.DigestUtil.ActionKey)6 Operation (com.google.longrunning.Operation)6 DigestUtil (build.buildfarm.common.DigestUtil)5 Watcher (build.buildfarm.common.Watcher)5 Write (build.buildfarm.common.Write)5 Instance (build.buildfarm.instance.Instance)5 QueuedOperation (build.buildfarm.v1test.QueuedOperation)4 Job (com.google.cloud.talent.v4beta1.Job)4 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)4 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)4 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)4 Duration (com.google.protobuf.Duration)4 Test (org.junit.Test)4