Search in sources :

Example 6 with TenantOrProjectName

use of com.google.cloud.talent.v4beta1.TenantOrProjectName 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)

Example 7 with TenantOrProjectName

use of com.google.cloud.talent.v4beta1.TenantOrProjectName in project java-talent by googleapis.

the class JobSearchListCompanies method sampleListCompanies.

/**
 * List Companies
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListCompanies(String projectId, String tenantId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.printf("Company Name: %s\n", responseItem.getName());
            System.out.printf("Display Name: %s\n", responseItem.getDisplayName());
            System.out.printf("External ID: %s\n", responseItem.getExternalId());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 8 with TenantOrProjectName

use of com.google.cloud.talent.v4beta1.TenantOrProjectName in project java-talent by googleapis.

the class JobSearchAutocompleteJobTitle method sampleCompleteQuery.

/**
 * Complete job title given partial text (autocomplete)
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 */
public static void sampleCompleteQuery(String projectId, String tenantId, String query, int numResults, String languageCode) {
    try (CompletionClient completionClient = CompletionClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        List<String> languageCodes = Arrays.asList(languageCode);
        CompleteQueryRequest request = CompleteQueryRequest.newBuilder().setParent(parent.toString()).setQuery(query).setPageSize(numResults).addAllLanguageCodes(languageCodes).build();
        CompleteQueryResponse response = completionClient.completeQuery(request);
        for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
            System.out.printf("Suggested title: %s\n", result.getSuggestion());
            // Suggestion type is JOB_TITLE or COMPANY_TITLE
            System.out.printf("Suggestion type: %s\n", result.getType());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4beta1.CompleteQueryResponse) CompletionClient(com.google.cloud.talent.v4beta1.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4beta1.CompleteQueryRequest) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 9 with TenantOrProjectName

use of com.google.cloud.talent.v4beta1.TenantOrProjectName in project java-talent by googleapis.

the class JobSearchBatchDeleteJob method sampleBatchDeleteJobs.

/**
 * Batch delete jobs using a filter
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 * @param filter The filter string specifies the jobs to be deleted. For example: companyName =
 *     "projects/api-test-project/companies/123" AND equisitionId = "req-1"
 */
public static void sampleBatchDeleteJobs(String projectId, String tenantId, String filter) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        BatchDeleteJobsRequest request = BatchDeleteJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        jobServiceClient.batchDeleteJobs(request);
        System.out.println("Batch deleted jobs from filter");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : BatchDeleteJobsRequest(com.google.cloud.talent.v4beta1.BatchDeleteJobsRequest) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 10 with TenantOrProjectName

use of com.google.cloud.talent.v4beta1.TenantOrProjectName in project java-talent by googleapis.

the class JobSearchCreateClientEvent method sampleCreateClientEvent.

/**
 * Creates a client event
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 * @param requestId A unique ID generated in the API responses. Value should be set to the
 *     request_id from an API response.
 * @param eventId A unique identifier, generated by the client application
 */
public static void sampleCreateClientEvent(String projectId, String tenantId, String requestId, String eventId) {
    try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        // The timestamp of the event as seconds of UTC time since Unix epoch
        // For more information on how to create google.protobuf.Timestamps
        // See:
        // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
        long seconds = 0L;
        Timestamp createTime = Timestamp.newBuilder().setSeconds(seconds).build();
        // The type of event attributed to the behavior of the end user
        JobEvent.JobEventType type = JobEvent.JobEventType.VIEW;
        // List of job names associated with this event
        String jobsElement = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        String jobsElement2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        List<String> jobs = Arrays.asList(jobsElement, jobsElement2);
        JobEvent jobEvent = JobEvent.newBuilder().setType(type).addAllJobs(jobs).build();
        ClientEvent clientEvent = ClientEvent.newBuilder().setRequestId(requestId).setEventId(eventId).setCreateTime(createTime).setJobEvent(jobEvent).build();
        CreateClientEventRequest request = CreateClientEventRequest.newBuilder().setParent(parent.toString()).setClientEvent(clientEvent).build();
        ClientEvent response = eventServiceClient.createClientEvent(request);
        System.out.println("Created client event");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobEvent(com.google.cloud.talent.v4beta1.JobEvent) CreateClientEventRequest(com.google.cloud.talent.v4beta1.CreateClientEventRequest) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Timestamp(com.google.protobuf.Timestamp) EventServiceClient(com.google.cloud.talent.v4beta1.EventServiceClient) ClientEvent(com.google.cloud.talent.v4beta1.ClientEvent)

Aggregations

TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)11 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)7 Job (com.google.cloud.talent.v4beta1.Job)6 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)3 Company (com.google.cloud.talent.v4beta1.Company)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)2 BatchDeleteJobsRequest (com.google.cloud.talent.v4beta1.BatchDeleteJobsRequest)1 ClientEvent (com.google.cloud.talent.v4beta1.ClientEvent)1 CommuteFilter (com.google.cloud.talent.v4beta1.CommuteFilter)1 CommuteMethod (com.google.cloud.talent.v4beta1.CommuteMethod)1 CompleteQueryRequest (com.google.cloud.talent.v4beta1.CompleteQueryRequest)1 CompleteQueryResponse (com.google.cloud.talent.v4beta1.CompleteQueryResponse)1 CompletionClient (com.google.cloud.talent.v4beta1.CompletionClient)1 CreateClientEventRequest (com.google.cloud.talent.v4beta1.CreateClientEventRequest)1 CreateCompanyRequest (com.google.cloud.talent.v4beta1.CreateCompanyRequest)1 EventServiceClient (com.google.cloud.talent.v4beta1.EventServiceClient)1 HistogramQuery (com.google.cloud.talent.v4beta1.HistogramQuery)1 JobEvent (com.google.cloud.talent.v4beta1.JobEvent)1