Search in sources :

Example 1 with RequestMetadata

use of build.bazel.remote.execution.v2.RequestMetadata 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 RequestMetadata

use of build.bazel.remote.execution.v2.RequestMetadata in project java-talent by googleapis.

the class JobSearchCommuteSearch method sampleSearchJobs.

/**
 * Search Jobs using commute distance
 */
public static void sampleSearchJobs(String projectId, String tenantId) {
    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();
        CommuteMethod commuteMethod = CommuteMethod.TRANSIT;
        long seconds = 1800L;
        Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build();
        double latitude = 37.422408;
        double longitude = -122.084068;
        LatLng startCoordinates = LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build();
        CommuteFilter commuteFilter = CommuteFilter.newBuilder().setCommuteMethod(commuteMethod).setTravelDuration(travelDuration).setStartCoordinates(startCoordinates).build();
        JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setJobQuery(jobQuery).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) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Duration(com.google.protobuf.Duration) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata) CommuteFilter(com.google.cloud.talent.v4beta1.CommuteFilter) JobQuery(com.google.cloud.talent.v4beta1.JobQuery) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) LatLng(com.google.type.LatLng) Job(com.google.cloud.talent.v4beta1.Job) CommuteMethod(com.google.cloud.talent.v4beta1.CommuteMethod)

Example 3 with RequestMetadata

use of build.bazel.remote.execution.v2.RequestMetadata in project java-talent by googleapis.

the class CommuteSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(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();
        CommuteMethod commuteMethod = CommuteMethod.DRIVING;
        long seconds = 3600L;
        Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build();
        double latitude = 37.422408;
        double longitude = -122.084068;
        LatLng startCoordinates = LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build();
        CommuteFilter commuteFilter = CommuteFilter.newBuilder().setCommuteMethod(commuteMethod).setTravelDuration(travelDuration).setStartCoordinates(startCoordinates).build();
        JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setJobQuery(jobQuery).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).getMatchingJobsList()) {
            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.v4.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4.SearchJobsResponse) TenantName(com.google.cloud.talent.v4.TenantName) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Duration(com.google.protobuf.Duration) RequestMetadata(com.google.cloud.talent.v4.RequestMetadata) CommuteFilter(com.google.cloud.talent.v4.CommuteFilter) JobQuery(com.google.cloud.talent.v4.JobQuery) LatLng(com.google.type.LatLng) Job(com.google.cloud.talent.v4.Job) CommuteMethod(com.google.cloud.talent.v4.CommuteMethod)

Example 4 with RequestMetadata

use of build.bazel.remote.execution.v2.RequestMetadata in project java-talent by googleapis.

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).getMatchingJobsList()) {
            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.v4.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4.SearchJobsResponse) TenantName(com.google.cloud.talent.v4.TenantName) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Job(com.google.cloud.talent.v4.Job) RequestMetadata(com.google.cloud.talent.v4.RequestMetadata)

Example 5 with RequestMetadata

use of build.bazel.remote.execution.v2.RequestMetadata in project java-talent by googleapis.

the class HistogramSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(String projectId, String tenantId, String query) 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 = "http://www.jobUrl.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();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addHistogramQueries(histogramQueriesElement).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).getMatchingJobsList()) {
            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.v4.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4.SearchJobsResponse) TenantName(com.google.cloud.talent.v4.TenantName) HistogramQuery(com.google.cloud.talent.v4.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Job(com.google.cloud.talent.v4.Job) RequestMetadata(com.google.cloud.talent.v4.RequestMetadata)

Aggregations

Digest (build.bazel.remote.execution.v2.Digest)18 RequestMetadata (build.bazel.remote.execution.v2.RequestMetadata)17 ByteString (com.google.protobuf.ByteString)15 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)12 Operation (com.google.longrunning.Operation)11 IOException (java.io.IOException)10 QueuedOperation (build.buildfarm.v1test.QueuedOperation)9 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)9 Status (io.grpc.Status)9 Actions.asExecutionStatus (build.buildfarm.common.Actions.asExecutionStatus)8 ExecutionException (java.util.concurrent.ExecutionException)8 ActionResult (build.bazel.remote.execution.v2.ActionResult)7 ExecuteResponse (build.bazel.remote.execution.v2.ExecuteResponse)7 ActionKey (build.buildfarm.common.DigestUtil.ActionKey)7 EntryLimitException (build.buildfarm.common.EntryLimitException)7 Tree (build.buildfarm.v1test.Tree)7 StatusException (io.grpc.StatusException)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ServerCallStreamObserver (io.grpc.stub.ServerCallStreamObserver)7 Directory (build.bazel.remote.execution.v2.Directory)6