use of com.google.cloud.retail.v2.DeleteProductRequest in project java-vision by googleapis.
the class ITSystemTest method tearDown.
@AfterClass
public static void tearDown() {
/* delete reference image */
DeleteReferenceImageRequest imageRequest = DeleteReferenceImageRequest.newBuilder().setName(formatReferenceImageName).build();
productSearchClient.deleteReferenceImage(imageRequest);
/* remove product from product set */
RemoveProductFromProductSetRequest removeProductRequest = RemoveProductFromProductSetRequest.newBuilder().setName(formatProductSetName).setProduct(formatProductName).build();
productSearchClient.removeProductFromProductSet(removeProductRequest);
/* delete product set */
DeleteProductSetRequest deleteProductSetRequest = DeleteProductSetRequest.newBuilder().setName(formatProductSetName).build();
productSearchClient.deleteProductSet(deleteProductSetRequest);
/* delete product */
DeleteProductRequest deleteProductRequest = DeleteProductRequest.newBuilder().setName(formatProductName).build();
productSearchClient.deleteProduct(deleteProductRequest);
productSearchClient.close();
imageAnnotatorClient.close();
}
use of com.google.cloud.retail.v2.DeleteProductRequest in project java-retail by googleapis.
the class RemoveTestResources method deleteAllProducts.
public static void deleteAllProducts() throws IOException {
System.out.println("Deleting products in process, please wait...");
try (ProductServiceClient productServiceClient = ProductServiceClient.create()) {
ListProductsRequest listRequest = ListProductsRequest.newBuilder().setParent(DEFAULT_CATALOG).build();
ListProductsPagedResponse products = productServiceClient.listProducts(listRequest);
int deleteCount = 0;
for (Product product : products.iterateAll()) {
DeleteProductRequest deleteRequest = DeleteProductRequest.newBuilder().setName(product.getName()).build();
try {
productServiceClient.deleteProduct(deleteRequest);
deleteCount++;
} catch (PermissionDeniedException e) {
System.out.println("Ignore PermissionDenied in case the product does not exist " + "at time of deletion.");
}
}
System.out.printf("%s products were deleted from %s%n", deleteCount, DEFAULT_CATALOG);
}
}
use of com.google.cloud.retail.v2.DeleteProductRequest in project java-retail by googleapis.
the class SetupCleanup method deleteProduct.
public static void deleteProduct(String productName) throws IOException {
DeleteProductRequest deleteProductRequest = DeleteProductRequest.newBuilder().setName(productName).build();
System.out.printf("Delete product request %s%n", deleteProductRequest);
ProductServiceClient.create().deleteProduct(deleteProductRequest);
System.out.printf("Product %s was deleted.%n", productName);
}
use of com.google.cloud.retail.v2.DeleteProductRequest in project java-retail by googleapis.
the class CrudProduct method deleteProduct.
// delete product
public static void deleteProduct(String productName) throws IOException {
DeleteProductRequest deleteProductRequest = DeleteProductRequest.newBuilder().setName(productName).build();
System.out.printf("Delete product request %s%n", deleteProductRequest);
ProductServiceClient.create().deleteProduct(deleteProductRequest);
System.out.printf("Product %s was deleted.%n", productName);
}
use of com.google.cloud.retail.v2.DeleteProductRequest in project java-retail by googleapis.
the class DeleteProduct method deleteProduct.
// call the Retail API to delete product
public static void deleteProduct(String productName) throws IOException {
DeleteProductRequest deleteProductRequest = DeleteProductRequest.newBuilder().setName(productName).build();
System.out.printf("Delete product request %s%n", deleteProductRequest);
ProductServiceClient.create().deleteProduct(deleteProductRequest);
System.out.printf("Product %s was deleted.%n", productName);
}
Aggregations