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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations