Search in sources :

Example 1 with EventServiceClient

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

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());
    }
}
Also used : JobEvent(com.google.cloud.talent.v4.JobEvent) CreateClientEventRequest(com.google.cloud.talent.v4.CreateClientEventRequest) TenantName(com.google.cloud.talent.v4.TenantName) Timestamp(com.google.protobuf.Timestamp) EventServiceClient(com.google.cloud.talent.v4.EventServiceClient) ClientEvent(com.google.cloud.talent.v4.ClientEvent)

Example 2 with EventServiceClient

use of com.google.cloud.talent.v4.EventServiceClient 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());
    }
}
Also used : JobEvent(com.google.cloud.talent.v4beta1.JobEvent) CreateClientEventRequest(com.google.cloud.talent.v4beta1.CreateClientEventRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName) Timestamp(com.google.protobuf.Timestamp) EventServiceClient(com.google.cloud.talent.v4beta1.EventServiceClient) ClientEvent(com.google.cloud.talent.v4beta1.ClientEvent)

Example 3 with EventServiceClient

use of com.google.cloud.talent.v4.EventServiceClient 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

Timestamp (com.google.protobuf.Timestamp)3 ClientEvent (com.google.cloud.talent.v4beta1.ClientEvent)2 CreateClientEventRequest (com.google.cloud.talent.v4beta1.CreateClientEventRequest)2 EventServiceClient (com.google.cloud.talent.v4beta1.EventServiceClient)2 JobEvent (com.google.cloud.talent.v4beta1.JobEvent)2 ClientEvent (com.google.cloud.talent.v4.ClientEvent)1 CreateClientEventRequest (com.google.cloud.talent.v4.CreateClientEventRequest)1 EventServiceClient (com.google.cloud.talent.v4.EventServiceClient)1 JobEvent (com.google.cloud.talent.v4.JobEvent)1 TenantName (com.google.cloud.talent.v4.TenantName)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1