use of com.google.cloud.vision.v1.PurgeProductsRequest 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.");
}
}
use of com.google.cloud.vision.v1.PurgeProductsRequest in project java-vision by googleapis.
the class PurgeProducts method purgeOrphanProducts.
// Delete the product and all its reference images.
public static void purgeOrphanProducts(String projectId, String computeRegion) throws Exception {
try (ProductSearchClient client = ProductSearchClient.create()) {
String parent = LocationName.format(projectId, computeRegion);
// The purge operation is async.
PurgeProductsRequest request = PurgeProductsRequest.newBuilder().setDeleteOrphanProducts(true).setForce(true).setParent(parent).build();
OperationFuture response = client.purgeProductsAsync(request);
response.getPollingFuture().get(180, TimeUnit.SECONDS);
System.out.println("Orphan products deleted.");
}
}
Aggregations