Search in sources :

Example 1 with PurgeMetadata

use of com.google.cloud.retail.v2.PurgeMetadata in project java-retail by googleapis.

the class SetupCleanup method purgeUserEvent.

public static void purgeUserEvent(String visitorId) throws IOException, ExecutionException, InterruptedException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
        PurgeUserEventsRequest purgeUserEventsRequest = PurgeUserEventsRequest.newBuilder().setFilter(String.format("visitorId=\"%s\"", visitorId)).setParent(DEFAULT_CATALOG).setForce(true).build();
        OperationFuture<PurgeUserEventsResponse, PurgeMetadata> purgeOperation = userEventServiceClient.purgeUserEventsAsync(purgeUserEventsRequest);
        System.out.printf("The purge operation was started: %s%n", purgeOperation.getName());
    }
}
Also used : PurgeMetadata(com.google.cloud.retail.v2.PurgeMetadata) PurgeUserEventsRequest(com.google.cloud.retail.v2.PurgeUserEventsRequest) UserEventServiceClient(com.google.cloud.retail.v2.UserEventServiceClient) PurgeUserEventsResponse(com.google.cloud.retail.v2.PurgeUserEventsResponse)

Example 2 with PurgeMetadata

use of com.google.cloud.retail.v2.PurgeMetadata in project java-retail by googleapis.

the class PurgeUserEvent method callPurgeUserEvents.

public static void callPurgeUserEvents(String defaultCatalog, String visitorId) throws IOException, ExecutionException, InterruptedException {
    writeUserEvent(visitorId);
    // the "close" method on the client to safely clean up any remaining background resources.
    try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
        PurgeUserEventsRequest purgeUserEventsRequest = PurgeUserEventsRequest.newBuilder().setFilter(String.format("visitorId=\"%s\"", visitorId)).setParent(defaultCatalog).setForce(true).build();
        System.out.printf("Purge user events request: %s%n", purgeUserEventsRequest);
        OperationFuture<PurgeUserEventsResponse, PurgeMetadata> purgeOperation = userEventServiceClient.purgeUserEventsAsync(purgeUserEventsRequest);
        System.out.printf("The purge operation was started: %s%n", purgeOperation.getName());
    }
}
Also used : PurgeMetadata(com.google.cloud.retail.v2.PurgeMetadata) PurgeUserEventsRequest(com.google.cloud.retail.v2.PurgeUserEventsRequest) UserEventServiceClient(com.google.cloud.retail.v2.UserEventServiceClient) PurgeUserEventsResponse(com.google.cloud.retail.v2.PurgeUserEventsResponse)

Aggregations

PurgeMetadata (com.google.cloud.retail.v2.PurgeMetadata)2 PurgeUserEventsRequest (com.google.cloud.retail.v2.PurgeUserEventsRequest)2 PurgeUserEventsResponse (com.google.cloud.retail.v2.PurgeUserEventsResponse)2 UserEventServiceClient (com.google.cloud.retail.v2.UserEventServiceClient)2