use of com.google.cloud.talent.v4beta1.JobEvent in project java-docs-samples by GoogleCloudPlatform.
the class JobSearchCreateClientEvent method createClientEvent.
// Creates a client event.
public static void createClientEvent(String projectId, String tenantId, String requestId, String eventId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
TenantName 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 = 3L;
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. ");
System.out.println(response.toString());
}
}
Aggregations