Search in sources :

Example 1 with UpdateProductRequest

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

the class CrudProduct method updateProduct.

// update product
public static void updateProduct(Product originalProduct, String productName) throws IOException {
    UpdateProductRequest updateProductRequest = UpdateProductRequest.newBuilder().setProduct(generateProductForUpdate(originalProduct.getId(), productName)).setAllowMissing(true).build();
    System.out.printf("Update product request: %s%n", updateProductRequest);
    try (ProductServiceClient serviceClient = ProductServiceClient.create()) {
        Product updatedProduct = serviceClient.updateProduct(updateProductRequest);
        System.out.printf("Updated product: %s%n", updatedProduct);
    }
}
Also used : ProductServiceClient(com.google.cloud.retail.v2.ProductServiceClient) Product(com.google.cloud.retail.v2.Product) UpdateProductRequest(com.google.cloud.retail.v2.UpdateProductRequest)

Example 2 with UpdateProductRequest

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

the class UpdateProduct method getUpdateProductRequest.

// get update product request
public static UpdateProductRequest getUpdateProductRequest(Product productToUpdate) {
    UpdateProductRequest updateProductRequest = UpdateProductRequest.newBuilder().setProduct(productToUpdate).setAllowMissing(true).build();
    System.out.printf("Update product request: %s%n", updateProductRequest);
    return updateProductRequest;
}
Also used : UpdateProductRequest(com.google.cloud.retail.v2.UpdateProductRequest)

Example 3 with UpdateProductRequest

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

the class ITSystemTest method updateProductTest.

@Test
public void updateProductTest() {
    Product updateProduct = product.toBuilder().addProductLabels(KEY_VALUE).build();
    UpdateProductRequest request = UpdateProductRequest.newBuilder().setProduct(updateProduct).build();
    Product actualProduct = productSearchClient.updateProduct(request);
    assertEquals(product.getName(), actualProduct.getName());
    assertEquals(PRODUCT_DISPLAY_NAME, actualProduct.getDisplayName());
    assertEquals(PRODUCT_CATEGORY, actualProduct.getProductCategory());
    assertEquals(ImmutableList.of(KEY_VALUE), actualProduct.getProductLabelsList());
    assertEquals(1, actualProduct.getProductLabelsCount());
}
Also used : Product(com.google.cloud.vision.v1.Product) UpdateProductRequest(com.google.cloud.vision.v1.UpdateProductRequest) Test(org.junit.Test)

Aggregations

UpdateProductRequest (com.google.cloud.retail.v2.UpdateProductRequest)2 Product (com.google.cloud.retail.v2.Product)1 ProductServiceClient (com.google.cloud.retail.v2.ProductServiceClient)1 Product (com.google.cloud.vision.v1.Product)1 UpdateProductRequest (com.google.cloud.vision.v1.UpdateProductRequest)1 Test (org.junit.Test)1