Search in sources :

Example 1 with CreateProductRequest

use of com.google.cloud.retail.v2.CreateProductRequest in project java-retail by googleapis.

the class SetupCleanup method createProduct.

public static Product createProduct(String productId) throws IOException {
    CreateProductRequest createProductRequest = CreateProductRequest.newBuilder().setProduct(generateProduct()).setProductId(productId).setParent(DEFAULT_BRANCH_NAME).build();
    System.out.printf("Create product request: %s%n", createProductRequest);
    Product createdProduct = ProductServiceClient.create().createProduct(createProductRequest);
    System.out.printf("Created product: %s%n", createdProduct);
    return createdProduct;
}
Also used : CreateProductRequest(com.google.cloud.retail.v2.CreateProductRequest) Product(com.google.cloud.retail.v2.Product)

Example 2 with CreateProductRequest

use of com.google.cloud.retail.v2.CreateProductRequest in project java-retail by googleapis.

the class CreateProduct method createProduct.

// call the Retail API to create product
public static Product createProduct(String productId, String defaultBranchName) throws IOException {
    CreateProductRequest createProductRequest = CreateProductRequest.newBuilder().setProduct(generateProduct()).setProductId(productId).setParent(defaultBranchName).build();
    System.out.printf("Create product request: %s%n", createProductRequest);
    Product createdProduct = ProductServiceClient.create().createProduct(createProductRequest);
    System.out.printf("Created product: %s%n", createdProduct);
    return createdProduct;
}
Also used : CreateProductRequest(com.google.cloud.retail.v2.CreateProductRequest) SetupCleanup.deleteProduct(setup.SetupCleanup.deleteProduct) Product(com.google.cloud.retail.v2.Product)

Example 3 with CreateProductRequest

use of com.google.cloud.retail.v2.CreateProductRequest in project java-retail by googleapis.

the class CrudProduct method createProduct.

// call the Retail API to create product
public static Product createProduct(String productId, String defaultBranchName) throws IOException {
    CreateProductRequest createProductRequest = CreateProductRequest.newBuilder().setProduct(generateProduct()).setProductId(productId).setParent(defaultBranchName).build();
    System.out.printf("Create product request: %s%n", createProductRequest);
    Product createdProduct = ProductServiceClient.create().createProduct(createProductRequest);
    System.out.printf("Created product: %s%n", createdProduct);
    return createdProduct;
}
Also used : CreateProductRequest(com.google.cloud.retail.v2.CreateProductRequest) Product(com.google.cloud.retail.v2.Product)

Example 4 with CreateProductRequest

use of com.google.cloud.retail.v2.CreateProductRequest in project java-vision by googleapis.

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws IOException {
    imageAnnotatorClient = ImageAnnotatorClient.create();
    /* create product */
    productSearchClient = ProductSearchClient.create();
    Product createProduct = Product.newBuilder().setName(PRODUCT_ID).setDisplayName(PRODUCT_DISPLAY_NAME).setProductCategory(PRODUCT_CATEGORY).build();
    CreateProductRequest productRequest = CreateProductRequest.newBuilder().setParent(LOCATION_NAME).setProduct(createProduct).build();
    product = productSearchClient.createProduct(productRequest);
    productName = getName(product.getName());
    formatProductName = ProductName.of(PROJECT_ID, COMPUTE_REGION, productName).toString();
    /* create product set */
    ProductSet createProductSet = ProductSet.newBuilder().setDisplayName(PRODUCT_SET_DISPLAY_NAME).build();
    CreateProductSetRequest productSetRequest = CreateProductSetRequest.newBuilder().setParent(LOCATION_NAME).setProductSet(createProductSet).setProductSetId(PRODUCT_SET_ID).build();
    productSet = productSearchClient.createProductSet(productSetRequest);
    productSetName = getName(productSet.getName());
    formatProductSetName = ProductSetName.of(PROJECT_ID, COMPUTE_REGION, productSetName).toString();
    /* add product to product set */
    AddProductToProductSetRequest productToProductSetRequest = AddProductToProductSetRequest.newBuilder().setName(formatProductSetName).setProduct(formatProductName).build();
    productSearchClient.addProductToProductSet(productToProductSetRequest);
    /* create reference image */
    ReferenceImage createReferenceImage = ReferenceImage.newBuilder().setUri(SAMPLE_BUCKET + "product_search/shoes_1.jpg").build();
    CreateReferenceImageRequest imageRequest = CreateReferenceImageRequest.newBuilder().setParent(formatProductName).setReferenceImage(createReferenceImage).build();
    referenceImage = productSearchClient.createReferenceImage(imageRequest);
    referenceImageName = getName(referenceImage.getName());
    formatReferenceImageName = ReferenceImageName.of(PROJECT_ID, COMPUTE_REGION, productName, referenceImageName).toString();
}
Also used : CreateProductRequest(com.google.cloud.vision.v1.CreateProductRequest) CreateReferenceImageRequest(com.google.cloud.vision.v1.CreateReferenceImageRequest) Product(com.google.cloud.vision.v1.Product) CreateProductSetRequest(com.google.cloud.vision.v1.CreateProductSetRequest) ProductSet(com.google.cloud.vision.v1.ProductSet) ReferenceImage(com.google.cloud.vision.v1.ReferenceImage) AddProductToProductSetRequest(com.google.cloud.vision.v1.AddProductToProductSetRequest) BeforeClass(org.junit.BeforeClass)

Aggregations

CreateProductRequest (com.google.cloud.retail.v2.CreateProductRequest)3 Product (com.google.cloud.retail.v2.Product)3 AddProductToProductSetRequest (com.google.cloud.vision.v1.AddProductToProductSetRequest)1 CreateProductRequest (com.google.cloud.vision.v1.CreateProductRequest)1 CreateProductSetRequest (com.google.cloud.vision.v1.CreateProductSetRequest)1 CreateReferenceImageRequest (com.google.cloud.vision.v1.CreateReferenceImageRequest)1 Product (com.google.cloud.vision.v1.Product)1 ProductSet (com.google.cloud.vision.v1.ProductSet)1 ReferenceImage (com.google.cloud.vision.v1.ReferenceImage)1 BeforeClass (org.junit.BeforeClass)1 SetupCleanup.deleteProduct (setup.SetupCleanup.deleteProduct)1