Search in sources :

Example 1 with ProductSetPurgeConfig

use of com.google.cloud.vision.v1.ProductSetPurgeConfig in project java-vision by googleapis.

the class PurgeProductsInProductSet method purgeProductsInProductSet.

// Delete all products in a product set.
public static void purgeProductsInProductSet(String projectId, String location, String productSetId) throws Exception {
    try (ProductSearchClient client = ProductSearchClient.create()) {
        String parent = LocationName.format(projectId, location);
        ProductSetPurgeConfig productSetPurgeConfig = ProductSetPurgeConfig.newBuilder().setProductSetId(productSetId).build();
        PurgeProductsRequest request = PurgeProductsRequest.newBuilder().setParent(parent).setProductSetPurgeConfig(productSetPurgeConfig).setForce(true).build();
        OperationFuture<Empty, BatchOperationMetadata> response = client.purgeProductsAsync(request);
        response.getPollingFuture().get(180, TimeUnit.SECONDS);
        System.out.println("Products removed from product set.");
    }
}
Also used : Empty(com.google.protobuf.Empty) PurgeProductsRequest(com.google.cloud.vision.v1.PurgeProductsRequest) ProductSearchClient(com.google.cloud.vision.v1.ProductSearchClient) ProductSetPurgeConfig(com.google.cloud.vision.v1.ProductSetPurgeConfig) BatchOperationMetadata(com.google.cloud.vision.v1.BatchOperationMetadata)

Aggregations

BatchOperationMetadata (com.google.cloud.vision.v1.BatchOperationMetadata)1 ProductSearchClient (com.google.cloud.vision.v1.ProductSearchClient)1 ProductSetPurgeConfig (com.google.cloud.vision.v1.ProductSetPurgeConfig)1 PurgeProductsRequest (com.google.cloud.vision.v1.PurgeProductsRequest)1 Empty (com.google.protobuf.Empty)1