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