@Generated(value="by gapic-generator") public class ProductSearchClient extends Object implements BackgroundResource
- The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named `projects/*/locations/*/productSets/*`, which acts as a way to put different products into groups to limit identification.
In parallel,
- The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named `projects/*/locations/*/products/*`
- Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named `projects/*/locations/*/products/*/referenceImages/*`
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
String productId = "";
Product response = productSearchClient.createProduct(parent, product, productId);
}
Note: close() needs to be called on the productSearchClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ProductSearchSettings to create(). For example:
To customize credentials:
ProductSearchSettings productSearchSettings =
ProductSearchSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ProductSearchClient productSearchClient =
ProductSearchClient.create(productSearchSettings);
To customize the endpoint:
ProductSearchSettings productSearchSettings =
ProductSearchSettings.newBuilder().setEndpoint(myEndpoint).build();
ProductSearchClient productSearchClient =
ProductSearchClient.create(productSearchSettings);
Modifier and Type | Class and Description |
---|---|
static class |
ProductSearchClient.ListProductSetsFixedSizeCollection |
static class |
ProductSearchClient.ListProductSetsPage |
static class |
ProductSearchClient.ListProductSetsPagedResponse |
static class |
ProductSearchClient.ListProductsFixedSizeCollection |
static class |
ProductSearchClient.ListProductsInProductSetFixedSizeCollection |
static class |
ProductSearchClient.ListProductsInProductSetPage |
static class |
ProductSearchClient.ListProductsInProductSetPagedResponse |
static class |
ProductSearchClient.ListProductsPage |
static class |
ProductSearchClient.ListProductsPagedResponse |
static class |
ProductSearchClient.ListReferenceImagesFixedSizeCollection |
static class |
ProductSearchClient.ListReferenceImagesPage |
static class |
ProductSearchClient.ListReferenceImagesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ProductSearchClient(ProductSearchSettings settings)
Constructs an instance of ProductSearchClient, using the given settings.
|
protected |
ProductSearchClient(ProductSearchStub stub) |
Modifier and Type | Method and Description |
---|---|
void |
addProductToProductSet(com.google.cloud.vision.v1.AddProductToProductSetRequest request)
Adds a Product to the specified ProductSet.
|
void |
addProductToProductSet(com.google.cloud.vision.v1.ProductSetName name,
com.google.cloud.vision.v1.ProductName product)
Adds a Product to the specified ProductSet.
|
void |
addProductToProductSet(String name,
String product)
Adds a Product to the specified ProductSet.
|
UnaryCallable<com.google.cloud.vision.v1.AddProductToProductSetRequest,Empty> |
addProductToProductSetCallable()
Adds a Product to the specified ProductSet.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ProductSearchClient |
create()
Constructs an instance of ProductSearchClient with default settings.
|
static ProductSearchClient |
create(ProductSearchSettings settings)
Constructs an instance of ProductSearchClient, using the given settings.
|
static ProductSearchClient |
create(ProductSearchStub stub)
Constructs an instance of ProductSearchClient, using the given stub for making calls.
|
com.google.cloud.vision.v1.Product |
createProduct(com.google.cloud.vision.v1.CreateProductRequest request)
Creates and returns a new product resource.
|
com.google.cloud.vision.v1.Product |
createProduct(com.google.cloud.vision.v1.LocationName parent,
com.google.cloud.vision.v1.Product product,
String productId)
Creates and returns a new product resource.
|
com.google.cloud.vision.v1.Product |
createProduct(String parent,
com.google.cloud.vision.v1.Product product,
String productId)
Creates and returns a new product resource.
|
UnaryCallable<com.google.cloud.vision.v1.CreateProductRequest,com.google.cloud.vision.v1.Product> |
createProductCallable()
Creates and returns a new product resource.
|
com.google.cloud.vision.v1.ProductSet |
createProductSet(com.google.cloud.vision.v1.CreateProductSetRequest request)
Creates and returns a new ProductSet resource.
|
com.google.cloud.vision.v1.ProductSet |
createProductSet(com.google.cloud.vision.v1.LocationName parent,
com.google.cloud.vision.v1.ProductSet productSet,
String productSetId)
Creates and returns a new ProductSet resource.
|
com.google.cloud.vision.v1.ProductSet |
createProductSet(String parent,
com.google.cloud.vision.v1.ProductSet productSet,
String productSetId)
Creates and returns a new ProductSet resource.
|
UnaryCallable<com.google.cloud.vision.v1.CreateProductSetRequest,com.google.cloud.vision.v1.ProductSet> |
createProductSetCallable()
Creates and returns a new ProductSet resource.
|
com.google.cloud.vision.v1.ReferenceImage |
createReferenceImage(com.google.cloud.vision.v1.CreateReferenceImageRequest request)
Creates and returns a new ReferenceImage resource.
|
com.google.cloud.vision.v1.ReferenceImage |
createReferenceImage(com.google.cloud.vision.v1.ProductName parent,
com.google.cloud.vision.v1.ReferenceImage referenceImage,
String referenceImageId)
Creates and returns a new ReferenceImage resource.
|
com.google.cloud.vision.v1.ReferenceImage |
createReferenceImage(String parent,
com.google.cloud.vision.v1.ReferenceImage referenceImage,
String referenceImageId)
Creates and returns a new ReferenceImage resource.
|
UnaryCallable<com.google.cloud.vision.v1.CreateReferenceImageRequest,com.google.cloud.vision.v1.ReferenceImage> |
createReferenceImageCallable()
Creates and returns a new ReferenceImage resource.
|
void |
deleteProduct(com.google.cloud.vision.v1.DeleteProductRequest request)
Permanently deletes a product and its reference images.
|
void |
deleteProduct(com.google.cloud.vision.v1.ProductName name)
Permanently deletes a product and its reference images.
|
void |
deleteProduct(String name)
Permanently deletes a product and its reference images.
|
UnaryCallable<com.google.cloud.vision.v1.DeleteProductRequest,Empty> |
deleteProductCallable()
Permanently deletes a product and its reference images.
|
void |
deleteProductSet(com.google.cloud.vision.v1.DeleteProductSetRequest request)
Permanently deletes a ProductSet.
|
void |
deleteProductSet(com.google.cloud.vision.v1.ProductSetName name)
Permanently deletes a ProductSet.
|
void |
deleteProductSet(String name)
Permanently deletes a ProductSet.
|
UnaryCallable<com.google.cloud.vision.v1.DeleteProductSetRequest,Empty> |
deleteProductSetCallable()
Permanently deletes a ProductSet.
|
void |
deleteReferenceImage(com.google.cloud.vision.v1.DeleteReferenceImageRequest request)
Permanently deletes a reference image.
|
void |
deleteReferenceImage(com.google.cloud.vision.v1.ReferenceImageName name)
Permanently deletes a reference image.
|
void |
deleteReferenceImage(String name)
Permanently deletes a reference image.
|
UnaryCallable<com.google.cloud.vision.v1.DeleteReferenceImageRequest,Empty> |
deleteReferenceImageCallable()
Permanently deletes a reference image.
|
static String |
formatLocationName(String project,
String location)
Deprecated.
Use the
LocationName class instead. |
static String |
formatProductName(String project,
String location,
String product)
Deprecated.
Use the
ProductName class instead. |
static String |
formatProductSetName(String project,
String location,
String productSet)
Deprecated.
Use the
ProductSetName class instead. |
static String |
formatReferenceImageName(String project,
String location,
String product,
String referenceImage)
Deprecated.
Use the
ReferenceImageName class instead. |
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.cloud.vision.v1.Product |
getProduct(com.google.cloud.vision.v1.GetProductRequest request)
Gets information associated with a Product.
|
com.google.cloud.vision.v1.Product |
getProduct(com.google.cloud.vision.v1.ProductName name)
Gets information associated with a Product.
|
com.google.cloud.vision.v1.Product |
getProduct(String name)
Gets information associated with a Product.
|
UnaryCallable<com.google.cloud.vision.v1.GetProductRequest,com.google.cloud.vision.v1.Product> |
getProductCallable()
Gets information associated with a Product.
|
com.google.cloud.vision.v1.ProductSet |
getProductSet(com.google.cloud.vision.v1.GetProductSetRequest request)
Gets information associated with a ProductSet.
|
com.google.cloud.vision.v1.ProductSet |
getProductSet(com.google.cloud.vision.v1.ProductSetName name)
Gets information associated with a ProductSet.
|
com.google.cloud.vision.v1.ProductSet |
getProductSet(String name)
Gets information associated with a ProductSet.
|
UnaryCallable<com.google.cloud.vision.v1.GetProductSetRequest,com.google.cloud.vision.v1.ProductSet> |
getProductSetCallable()
Gets information associated with a ProductSet.
|
com.google.cloud.vision.v1.ReferenceImage |
getReferenceImage(com.google.cloud.vision.v1.GetReferenceImageRequest request)
Gets information associated with a ReferenceImage.
|
com.google.cloud.vision.v1.ReferenceImage |
getReferenceImage(com.google.cloud.vision.v1.ReferenceImageName name)
Gets information associated with a ReferenceImage.
|
com.google.cloud.vision.v1.ReferenceImage |
getReferenceImage(String name)
Gets information associated with a ReferenceImage.
|
UnaryCallable<com.google.cloud.vision.v1.GetReferenceImageRequest,com.google.cloud.vision.v1.ReferenceImage> |
getReferenceImageCallable()
Gets information associated with a ReferenceImage.
|
ProductSearchSettings |
getSettings() |
ProductSearchStub |
getStub() |
OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> |
importProductSetsAsync(com.google.cloud.vision.v1.ImportProductSetsRequest request)
Asynchronous API that imports a list of reference images to specified product sets based on a
list of image information.
|
OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> |
importProductSetsAsync(com.google.cloud.vision.v1.LocationName parent,
com.google.cloud.vision.v1.ImportProductSetsInputConfig inputConfig)
Asynchronous API that imports a list of reference images to specified product sets based on a
list of image information.
|
OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> |
importProductSetsAsync(String parent,
com.google.cloud.vision.v1.ImportProductSetsInputConfig inputConfig)
Asynchronous API that imports a list of reference images to specified product sets based on a
list of image information.
|
UnaryCallable<com.google.cloud.vision.v1.ImportProductSetsRequest,Operation> |
importProductSetsCallable()
Asynchronous API that imports a list of reference images to specified product sets based on a
list of image information.
|
OperationCallable<com.google.cloud.vision.v1.ImportProductSetsRequest,com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> |
importProductSetsOperationCallable()
Asynchronous API that imports a list of reference images to specified product sets based on a
list of image information.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
ProductSearchClient.ListProductsPagedResponse |
listProducts(com.google.cloud.vision.v1.ListProductsRequest request)
Lists products in an unspecified order.
|
ProductSearchClient.ListProductsPagedResponse |
listProducts(com.google.cloud.vision.v1.LocationName parent)
Lists products in an unspecified order.
|
ProductSearchClient.ListProductsPagedResponse |
listProducts(String parent)
Lists products in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductsRequest,com.google.cloud.vision.v1.ListProductsResponse> |
listProductsCallable()
Lists products in an unspecified order.
|
ProductSearchClient.ListProductSetsPagedResponse |
listProductSets(com.google.cloud.vision.v1.ListProductSetsRequest request)
Lists ProductSets in an unspecified order.
|
ProductSearchClient.ListProductSetsPagedResponse |
listProductSets(com.google.cloud.vision.v1.LocationName parent)
Lists ProductSets in an unspecified order.
|
ProductSearchClient.ListProductSetsPagedResponse |
listProductSets(String parent)
Lists ProductSets in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductSetsRequest,com.google.cloud.vision.v1.ListProductSetsResponse> |
listProductSetsCallable()
Lists ProductSets in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductSetsRequest,ProductSearchClient.ListProductSetsPagedResponse> |
listProductSetsPagedCallable()
Lists ProductSets in an unspecified order.
|
ProductSearchClient.ListProductsInProductSetPagedResponse |
listProductsInProductSet(com.google.cloud.vision.v1.ListProductsInProductSetRequest request)
Lists the Products in a ProductSet, in an unspecified order.
|
ProductSearchClient.ListProductsInProductSetPagedResponse |
listProductsInProductSet(com.google.cloud.vision.v1.ProductSetName name)
Lists the Products in a ProductSet, in an unspecified order.
|
ProductSearchClient.ListProductsInProductSetPagedResponse |
listProductsInProductSet(String name)
Lists the Products in a ProductSet, in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductsInProductSetRequest,com.google.cloud.vision.v1.ListProductsInProductSetResponse> |
listProductsInProductSetCallable()
Lists the Products in a ProductSet, in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductsInProductSetRequest,ProductSearchClient.ListProductsInProductSetPagedResponse> |
listProductsInProductSetPagedCallable()
Lists the Products in a ProductSet, in an unspecified order.
|
UnaryCallable<com.google.cloud.vision.v1.ListProductsRequest,ProductSearchClient.ListProductsPagedResponse> |
listProductsPagedCallable()
Lists products in an unspecified order.
|
ProductSearchClient.ListReferenceImagesPagedResponse |
listReferenceImages(com.google.cloud.vision.v1.ListReferenceImagesRequest request)
Lists reference images.
|
ProductSearchClient.ListReferenceImagesPagedResponse |
listReferenceImages(com.google.cloud.vision.v1.ProductName parent)
Lists reference images.
|
ProductSearchClient.ListReferenceImagesPagedResponse |
listReferenceImages(String parent)
Lists reference images.
|
UnaryCallable<com.google.cloud.vision.v1.ListReferenceImagesRequest,com.google.cloud.vision.v1.ListReferenceImagesResponse> |
listReferenceImagesCallable()
Lists reference images.
|
UnaryCallable<com.google.cloud.vision.v1.ListReferenceImagesRequest,ProductSearchClient.ListReferenceImagesPagedResponse> |
listReferenceImagesPagedCallable()
Lists reference images.
|
static String |
parseLocationFromLocationName(String locationName)
Deprecated.
Use the
LocationName class instead. |
static String |
parseLocationFromProductName(String productName)
Deprecated.
Use the
ProductName class instead. |
static String |
parseLocationFromProductSetName(String productSetName)
Deprecated.
Use the
ProductSetName class instead. |
static String |
parseLocationFromReferenceImageName(String referenceImageName)
Deprecated.
Use the
ReferenceImageName class instead. |
static String |
parseProductFromProductName(String productName)
Deprecated.
Use the
ProductName class instead. |
static String |
parseProductFromReferenceImageName(String referenceImageName)
Deprecated.
Use the
ReferenceImageName class instead. |
static String |
parseProductSetFromProductSetName(String productSetName)
Deprecated.
Use the
ProductSetName class instead. |
static String |
parseProjectFromLocationName(String locationName)
Deprecated.
Use the
LocationName class instead. |
static String |
parseProjectFromProductName(String productName)
Deprecated.
Use the
ProductName class instead. |
static String |
parseProjectFromProductSetName(String productSetName)
Deprecated.
Use the
ProductSetName class instead. |
static String |
parseProjectFromReferenceImageName(String referenceImageName)
Deprecated.
Use the
ReferenceImageName class instead. |
static String |
parseReferenceImageFromReferenceImageName(String referenceImageName)
Deprecated.
Use the
ReferenceImageName class instead. |
void |
removeProductFromProductSet(com.google.cloud.vision.v1.ProductSetName name,
com.google.cloud.vision.v1.ProductName product)
Removes a Product from the specified ProductSet.
|
void |
removeProductFromProductSet(com.google.cloud.vision.v1.RemoveProductFromProductSetRequest request)
Removes a Product from the specified ProductSet.
|
void |
removeProductFromProductSet(String name,
String product)
Removes a Product from the specified ProductSet.
|
UnaryCallable<com.google.cloud.vision.v1.RemoveProductFromProductSetRequest,Empty> |
removeProductFromProductSetCallable()
Removes a Product from the specified ProductSet.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.cloud.vision.v1.Product |
updateProduct(com.google.cloud.vision.v1.Product product,
FieldMask updateMask)
Makes changes to a Product resource.
|
com.google.cloud.vision.v1.Product |
updateProduct(com.google.cloud.vision.v1.UpdateProductRequest request)
Makes changes to a Product resource.
|
UnaryCallable<com.google.cloud.vision.v1.UpdateProductRequest,com.google.cloud.vision.v1.Product> |
updateProductCallable()
Makes changes to a Product resource.
|
com.google.cloud.vision.v1.ProductSet |
updateProductSet(com.google.cloud.vision.v1.ProductSet productSet,
FieldMask updateMask)
Makes changes to a ProductSet resource.
|
com.google.cloud.vision.v1.ProductSet |
updateProductSet(com.google.cloud.vision.v1.UpdateProductSetRequest request)
Makes changes to a ProductSet resource.
|
UnaryCallable<com.google.cloud.vision.v1.UpdateProductSetRequest,com.google.cloud.vision.v1.ProductSet> |
updateProductSetCallable()
Makes changes to a ProductSet resource.
|
protected ProductSearchClient(ProductSearchSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ProductSearchClient(ProductSearchStub stub)
@Deprecated public static final String formatLocationName(String project, String location)
LocationName
class instead.@Deprecated public static final String formatProductName(String project, String location, String product)
ProductName
class instead.@Deprecated public static final String formatProductSetName(String project, String location, String productSet)
ProductSetName
class instead.@Deprecated public static final String formatReferenceImageName(String project, String location, String product, String referenceImage)
ReferenceImageName
class instead.@Deprecated public static final String parseProjectFromLocationName(String locationName)
LocationName
class instead.@Deprecated public static final String parseLocationFromLocationName(String locationName)
LocationName
class instead.@Deprecated public static final String parseProjectFromProductName(String productName)
ProductName
class instead.@Deprecated public static final String parseLocationFromProductName(String productName)
ProductName
class instead.@Deprecated public static final String parseProductFromProductName(String productName)
ProductName
class instead.@Deprecated public static final String parseProjectFromProductSetName(String productSetName)
ProductSetName
class instead.@Deprecated public static final String parseLocationFromProductSetName(String productSetName)
ProductSetName
class instead.@Deprecated public static final String parseProductSetFromProductSetName(String productSetName)
ProductSetName
class instead.@Deprecated public static final String parseProjectFromReferenceImageName(String referenceImageName)
ReferenceImageName
class instead.@Deprecated public static final String parseLocationFromReferenceImageName(String referenceImageName)
ReferenceImageName
class instead.@Deprecated public static final String parseProductFromReferenceImageName(String referenceImageName)
ReferenceImageName
class instead.@Deprecated public static final String parseReferenceImageFromReferenceImageName(String referenceImageName)
ReferenceImageName
class instead.public static final ProductSearchClient create() throws IOException
IOException
public static final ProductSearchClient create(ProductSearchSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ProductSearchClient create(ProductSearchStub stub)
public final ProductSearchSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ProductSearchStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
public final com.google.cloud.vision.v1.Product createProduct(com.google.cloud.vision.v1.LocationName parent, com.google.cloud.vision.v1.Product product, String productId)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
String productId = "";
Product response = productSearchClient.createProduct(parent, product, productId);
}
parent
- The project in which the Product should be created.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
product
- The product to create.productId
- A user-supplied resource id for this Product. If set, the server will attempt
to use this value as the resource id. If it is already in use, an error is returned with
code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character
`/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.Product createProduct(String parent, com.google.cloud.vision.v1.Product product, String productId)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
String productId = "";
Product response = productSearchClient.createProduct(parent.toString(), product, productId);
}
parent
- The project in which the Product should be created.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
product
- The product to create.productId
- A user-supplied resource id for this Product. If set, the server will attempt
to use this value as the resource id. If it is already in use, an error is returned with
code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character
`/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.Product createProduct(com.google.cloud.vision.v1.CreateProductRequest request)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
CreateProductRequest request = CreateProductRequest.newBuilder()
.setParent(parent.toString())
.setProduct(product)
.build();
Product response = productSearchClient.createProduct(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.CreateProductRequest,com.google.cloud.vision.v1.Product> createProductCallable()
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
CreateProductRequest request = CreateProductRequest.newBuilder()
.setParent(parent.toString())
.setProduct(product)
.build();
ApiFuture<Product> future = productSearchClient.createProductCallable().futureCall(request);
// Do something
Product response = future.get();
}
public final ProductSearchClient.ListProductsPagedResponse listProducts(com.google.cloud.vision.v1.LocationName parent)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Product element : productSearchClient.listProducts(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project OR ProductSet from which Products should be listed.
Format: `projects/PROJECT_ID/locations/LOC_ID`
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductsPagedResponse listProducts(String parent)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Product element : productSearchClient.listProducts(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project OR ProductSet from which Products should be listed.
Format: `projects/PROJECT_ID/locations/LOC_ID`
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductsPagedResponse listProducts(com.google.cloud.vision.v1.ListProductsRequest request)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductsRequest request = ListProductsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Product element : productSearchClient.listProducts(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.ListProductsRequest,ProductSearchClient.ListProductsPagedResponse> listProductsPagedCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductsRequest request = ListProductsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListProductsPagedResponse> future = productSearchClient.listProductsPagedCallable().futureCall(request);
// Do something
for (Product element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.vision.v1.ListProductsRequest,com.google.cloud.vision.v1.ListProductsResponse> listProductsCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductsRequest request = ListProductsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListProductsResponse response = productSearchClient.listProductsCallable().call(request);
for (Product element : response.getProductsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.vision.v1.Product getProduct(com.google.cloud.vision.v1.ProductName name)
Possible errors:
* Returns NOT_FOUND if the Product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
Product response = productSearchClient.getProduct(name);
}
name
- Resource name of the Product to get.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.Product getProduct(String name)
Possible errors:
* Returns NOT_FOUND if the Product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
Product response = productSearchClient.getProduct(name.toString());
}
name
- Resource name of the Product to get.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.Product getProduct(com.google.cloud.vision.v1.GetProductRequest request)
Possible errors:
* Returns NOT_FOUND if the Product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
GetProductRequest request = GetProductRequest.newBuilder()
.setName(name.toString())
.build();
Product response = productSearchClient.getProduct(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.GetProductRequest,com.google.cloud.vision.v1.Product> getProductCallable()
Possible errors:
* Returns NOT_FOUND if the Product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
GetProductRequest request = GetProductRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Product> future = productSearchClient.getProductCallable().futureCall(request);
// Do something
Product response = future.get();
}
public final com.google.cloud.vision.v1.Product updateProduct(com.google.cloud.vision.v1.Product product, FieldMask updateMask)
If labels are updated, the change will not be reflected in queries until the next index time.
Possible errors:
* Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
Product product = Product.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Product response = productSearchClient.updateProduct(product, updateMask);
}
product
- The Product resource which replaces the one on the server. product.name is
immutable.updateMask
- The [FieldMask][google.protobuf.FieldMask] that specifies which fields to
update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask
paths include `product_labels`, `display_name`, and `description`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.Product updateProduct(com.google.cloud.vision.v1.UpdateProductRequest request)
If labels are updated, the change will not be reflected in queries until the next index time.
Possible errors:
* Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
Product product = Product.newBuilder().build();
UpdateProductRequest request = UpdateProductRequest.newBuilder()
.setProduct(product)
.build();
Product response = productSearchClient.updateProduct(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.UpdateProductRequest,com.google.cloud.vision.v1.Product> updateProductCallable()
If labels are updated, the change will not be reflected in queries until the next index time.
Possible errors:
* Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
Product product = Product.newBuilder().build();
UpdateProductRequest request = UpdateProductRequest.newBuilder()
.setProduct(product)
.build();
ApiFuture<Product> future = productSearchClient.updateProductCallable().futureCall(request);
// Do something
Product response = future.get();
}
public final void deleteProduct(com.google.cloud.vision.v1.ProductName name)
Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
Possible errors:
* Returns NOT_FOUND if the product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.deleteProduct(name);
}
name
- Resource name of product to delete.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void deleteProduct(String name)
Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
Possible errors:
* Returns NOT_FOUND if the product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.deleteProduct(name.toString());
}
name
- Resource name of product to delete.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void deleteProduct(com.google.cloud.vision.v1.DeleteProductRequest request)
Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
Possible errors:
* Returns NOT_FOUND if the product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
DeleteProductRequest request = DeleteProductRequest.newBuilder()
.setName(name.toString())
.build();
productSearchClient.deleteProduct(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.DeleteProductRequest,Empty> deleteProductCallable()
Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
Possible errors:
* Returns NOT_FOUND if the product does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
DeleteProductRequest request = DeleteProductRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = productSearchClient.deleteProductCallable().futureCall(request);
// Do something
future.get();
}
public final ProductSearchClient.ListReferenceImagesPagedResponse listReferenceImages(com.google.cloud.vision.v1.ProductName parent)
Possible errors:
* Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Resource name of the product containing the reference images.
Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
ApiException
- if the remote call failspublic final ProductSearchClient.ListReferenceImagesPagedResponse listReferenceImages(String parent)
Possible errors:
* Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
for (ReferenceImage element : productSearchClient.listReferenceImages(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Resource name of the product containing the reference images.
Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
ApiException
- if the remote call failspublic final ProductSearchClient.ListReferenceImagesPagedResponse listReferenceImages(com.google.cloud.vision.v1.ListReferenceImagesRequest request)
Possible errors:
* Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ListReferenceImagesRequest request = ListReferenceImagesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (ReferenceImage element : productSearchClient.listReferenceImages(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.ListReferenceImagesRequest,ProductSearchClient.ListReferenceImagesPagedResponse> listReferenceImagesPagedCallable()
Possible errors:
* Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ListReferenceImagesRequest request = ListReferenceImagesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListReferenceImagesPagedResponse> future = productSearchClient.listReferenceImagesPagedCallable().futureCall(request);
// Do something
for (ReferenceImage element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.vision.v1.ListReferenceImagesRequest,com.google.cloud.vision.v1.ListReferenceImagesResponse> listReferenceImagesCallable()
Possible errors:
* Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ListReferenceImagesRequest request = ListReferenceImagesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListReferenceImagesResponse response = productSearchClient.listReferenceImagesCallable().call(request);
for (ReferenceImage element : response.getReferenceImagesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.vision.v1.ReferenceImage getReferenceImage(com.google.cloud.vision.v1.ReferenceImageName name)
Possible errors:
* Returns NOT_FOUND if the specified image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
ReferenceImage response = productSearchClient.getReferenceImage(name);
}
name
- The resource name of the ReferenceImage to get.
Format is:
`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ReferenceImage getReferenceImage(String name)
Possible errors:
* Returns NOT_FOUND if the specified image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
ReferenceImage response = productSearchClient.getReferenceImage(name.toString());
}
name
- The resource name of the ReferenceImage to get.
Format is:
`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ReferenceImage getReferenceImage(com.google.cloud.vision.v1.GetReferenceImageRequest request)
Possible errors:
* Returns NOT_FOUND if the specified image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
GetReferenceImageRequest request = GetReferenceImageRequest.newBuilder()
.setName(name.toString())
.build();
ReferenceImage response = productSearchClient.getReferenceImage(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.GetReferenceImageRequest,com.google.cloud.vision.v1.ReferenceImage> getReferenceImageCallable()
Possible errors:
* Returns NOT_FOUND if the specified image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
GetReferenceImageRequest request = GetReferenceImageRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ReferenceImage> future = productSearchClient.getReferenceImageCallable().futureCall(request);
// Do something
ReferenceImage response = future.get();
}
public final void deleteReferenceImage(com.google.cloud.vision.v1.ReferenceImageName name)
The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed.
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the reference image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
productSearchClient.deleteReferenceImage(name);
}
name
- The resource name of the reference image to delete.
Format is:
`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
ApiException
- if the remote call failspublic final void deleteReferenceImage(String name)
The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed.
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the reference image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
productSearchClient.deleteReferenceImage(name.toString());
}
name
- The resource name of the reference image to delete.
Format is:
`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
ApiException
- if the remote call failspublic final void deleteReferenceImage(com.google.cloud.vision.v1.DeleteReferenceImageRequest request)
The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed.
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the reference image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
DeleteReferenceImageRequest request = DeleteReferenceImageRequest.newBuilder()
.setName(name.toString())
.build();
productSearchClient.deleteReferenceImage(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.DeleteReferenceImageRequest,Empty> deleteReferenceImageCallable()
The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed.
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the reference image does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ReferenceImageName name = ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]");
DeleteReferenceImageRequest request = DeleteReferenceImageRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = productSearchClient.deleteReferenceImageCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.cloud.vision.v1.ReferenceImage createReferenceImage(com.google.cloud.vision.v1.ProductName parent, com.google.cloud.vision.v1.ReferenceImage referenceImage, String referenceImageId)
The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles.
Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP).
Possible errors:
* Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ReferenceImage referenceImage = ReferenceImage.newBuilder().build();
String referenceImageId = "";
ReferenceImage response = productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId);
}
parent
- Resource name of the product in which to create the reference image.
Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
referenceImage
- The reference image to create. If an image ID is specified, it is
ignored.referenceImageId
- A user-supplied resource id for the ReferenceImage to be added. If set,
the server will attempt to use this value as the resource id. If it is already in use, an
error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot
contain the character `/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ReferenceImage createReferenceImage(String parent, com.google.cloud.vision.v1.ReferenceImage referenceImage, String referenceImageId)
The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles.
Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP).
Possible errors:
* Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ReferenceImage referenceImage = ReferenceImage.newBuilder().build();
String referenceImageId = "";
ReferenceImage response = productSearchClient.createReferenceImage(parent.toString(), referenceImage, referenceImageId);
}
parent
- Resource name of the product in which to create the reference image.
Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
referenceImage
- The reference image to create. If an image ID is specified, it is
ignored.referenceImageId
- A user-supplied resource id for the ReferenceImage to be added. If set,
the server will attempt to use this value as the resource id. If it is already in use, an
error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot
contain the character `/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ReferenceImage createReferenceImage(com.google.cloud.vision.v1.CreateReferenceImageRequest request)
The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles.
Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP).
Possible errors:
* Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ReferenceImage referenceImage = ReferenceImage.newBuilder().build();
CreateReferenceImageRequest request = CreateReferenceImageRequest.newBuilder()
.setParent(parent.toString())
.setReferenceImage(referenceImage)
.build();
ReferenceImage response = productSearchClient.createReferenceImage(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.CreateReferenceImageRequest,com.google.cloud.vision.v1.ReferenceImage> createReferenceImageCallable()
The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles.
Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP).
Possible errors:
* Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
ReferenceImage referenceImage = ReferenceImage.newBuilder().build();
CreateReferenceImageRequest request = CreateReferenceImageRequest.newBuilder()
.setParent(parent.toString())
.setReferenceImage(referenceImage)
.build();
ApiFuture<ReferenceImage> future = productSearchClient.createReferenceImageCallable().futureCall(request);
// Do something
ReferenceImage response = future.get();
}
public final com.google.cloud.vision.v1.ProductSet createProductSet(com.google.cloud.vision.v1.LocationName parent, com.google.cloud.vision.v1.ProductSet productSet, String productSetId)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ProductSet productSet = ProductSet.newBuilder().build();
String productSetId = "";
ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId);
}
parent
- The project in which the ProductSet should be created.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
productSet
- The ProductSet to create.productSetId
- A user-supplied resource id for this ProductSet. If set, the server will
attempt to use this value as the resource id. If it is already in use, an error is returned
with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the
character `/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ProductSet createProductSet(String parent, com.google.cloud.vision.v1.ProductSet productSet, String productSetId)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ProductSet productSet = ProductSet.newBuilder().build();
String productSetId = "";
ProductSet response = productSearchClient.createProductSet(parent.toString(), productSet, productSetId);
}
parent
- The project in which the ProductSet should be created.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
productSet
- The ProductSet to create.productSetId
- A user-supplied resource id for this ProductSet. If set, the server will
attempt to use this value as the resource id. If it is already in use, an error is returned
with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the
character `/`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ProductSet createProductSet(com.google.cloud.vision.v1.CreateProductSetRequest request)
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ProductSet productSet = ProductSet.newBuilder().build();
CreateProductSetRequest request = CreateProductSetRequest.newBuilder()
.setParent(parent.toString())
.setProductSet(productSet)
.build();
ProductSet response = productSearchClient.createProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.CreateProductSetRequest,com.google.cloud.vision.v1.ProductSet> createProductSetCallable()
Possible errors:
* Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ProductSet productSet = ProductSet.newBuilder().build();
CreateProductSetRequest request = CreateProductSetRequest.newBuilder()
.setParent(parent.toString())
.setProductSet(productSet)
.build();
ApiFuture<ProductSet> future = productSearchClient.createProductSetCallable().futureCall(request);
// Do something
ProductSet response = future.get();
}
public final ProductSearchClient.ListProductSetsPagedResponse listProductSets(com.google.cloud.vision.v1.LocationName parent)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project from which ProductSets should be listed.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductSetsPagedResponse listProductSets(String parent)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (ProductSet element : productSearchClient.listProductSets(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project from which ProductSets should be listed.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductSetsPagedResponse listProductSets(com.google.cloud.vision.v1.ListProductSetsRequest request)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductSetsRequest request = ListProductSetsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (ProductSet element : productSearchClient.listProductSets(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.ListProductSetsRequest,ProductSearchClient.ListProductSetsPagedResponse> listProductSetsPagedCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductSetsRequest request = ListProductSetsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListProductSetsPagedResponse> future = productSearchClient.listProductSetsPagedCallable().futureCall(request);
// Do something
for (ProductSet element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.vision.v1.ListProductSetsRequest,com.google.cloud.vision.v1.ListProductSetsResponse> listProductSetsCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListProductSetsRequest request = ListProductSetsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListProductSetsResponse response = productSearchClient.listProductSetsCallable().call(request);
for (ProductSet element : response.getProductSetsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.vision.v1.ProductSet getProductSet(com.google.cloud.vision.v1.ProductSetName name)
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductSet response = productSearchClient.getProductSet(name);
}
name
- Resource name of the ProductSet to get.
Format is: `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ProductSet getProductSet(String name)
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductSet response = productSearchClient.getProductSet(name.toString());
}
name
- Resource name of the ProductSet to get.
Format is: `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ProductSet getProductSet(com.google.cloud.vision.v1.GetProductSetRequest request)
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
GetProductSetRequest request = GetProductSetRequest.newBuilder()
.setName(name.toString())
.build();
ProductSet response = productSearchClient.getProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.GetProductSetRequest,com.google.cloud.vision.v1.ProductSet> getProductSetCallable()
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
GetProductSetRequest request = GetProductSetRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ProductSet> future = productSearchClient.getProductSetCallable().futureCall(request);
// Do something
ProductSet response = future.get();
}
public final com.google.cloud.vision.v1.ProductSet updateProductSet(com.google.cloud.vision.v1.ProductSet productSet, FieldMask updateMask)
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSet productSet = ProductSet.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
ProductSet response = productSearchClient.updateProductSet(productSet, updateMask);
}
productSet
- The ProductSet resource which replaces the one on the server.updateMask
- The [FieldMask][google.protobuf.FieldMask] that specifies which fields to
update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask
path is `display_name`.ApiException
- if the remote call failspublic final com.google.cloud.vision.v1.ProductSet updateProductSet(com.google.cloud.vision.v1.UpdateProductSetRequest request)
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSet productSet = ProductSet.newBuilder().build();
UpdateProductSetRequest request = UpdateProductSetRequest.newBuilder()
.setProductSet(productSet)
.build();
ProductSet response = productSearchClient.updateProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.UpdateProductSetRequest,com.google.cloud.vision.v1.ProductSet> updateProductSetCallable()
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSet productSet = ProductSet.newBuilder().build();
UpdateProductSetRequest request = UpdateProductSetRequest.newBuilder()
.setProductSet(productSet)
.build();
ApiFuture<ProductSet> future = productSearchClient.updateProductSetCallable().futureCall(request);
// Do something
ProductSet response = future.get();
}
public final void deleteProductSet(com.google.cloud.vision.v1.ProductSetName name)
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
productSearchClient.deleteProductSet(name);
}
name
- Resource name of the ProductSet to delete.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final void deleteProductSet(String name)
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
productSearchClient.deleteProductSet(name.toString());
}
name
- Resource name of the ProductSet to delete.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final void deleteProductSet(com.google.cloud.vision.v1.DeleteProductSetRequest request)
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
DeleteProductSetRequest request = DeleteProductSetRequest.newBuilder()
.setName(name.toString())
.build();
productSearchClient.deleteProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.DeleteProductSetRequest,Empty> deleteProductSetCallable()
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
* Returns NOT_FOUND if the ProductSet does not exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
DeleteProductSetRequest request = DeleteProductSetRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = productSearchClient.deleteProductSetCallable().futureCall(request);
// Do something
future.get();
}
public final void addProductToProductSet(com.google.cloud.vision.v1.ProductSetName name, com.google.cloud.vision.v1.ProductName product)
One Product can be added to at most 100 ProductSets.
Possible errors:
* Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.addProductToProductSet(name, product);
}
name
- The resource name for the ProductSet to modify.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
product
- The resource name for the Product to be added to this ProductSet.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void addProductToProductSet(String name, String product)
One Product can be added to at most 100 ProductSets.
Possible errors:
* Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.addProductToProductSet(name.toString(), product.toString());
}
name
- The resource name for the ProductSet to modify.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
product
- The resource name for the Product to be added to this ProductSet.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void addProductToProductSet(com.google.cloud.vision.v1.AddProductToProductSetRequest request)
One Product can be added to at most 100 ProductSets.
Possible errors:
* Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
AddProductToProductSetRequest request = AddProductToProductSetRequest.newBuilder()
.setName(name.toString())
.setProduct(product.toString())
.build();
productSearchClient.addProductToProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.AddProductToProductSetRequest,Empty> addProductToProductSetCallable()
One Product can be added to at most 100 ProductSets.
Possible errors:
* Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
AddProductToProductSetRequest request = AddProductToProductSetRequest.newBuilder()
.setName(name.toString())
.setProduct(product.toString())
.build();
ApiFuture<Void> future = productSearchClient.addProductToProductSetCallable().futureCall(request);
// Do something
future.get();
}
public final void removeProductFromProductSet(com.google.cloud.vision.v1.ProductSetName name, com.google.cloud.vision.v1.ProductName product)
Possible errors:
* Returns NOT_FOUND If the Product is not found under the ProductSet.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.removeProductFromProductSet(name, product);
}
name
- The resource name for the ProductSet to modify.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
product
- The resource name for the Product to be removed from this ProductSet.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void removeProductFromProductSet(String name, String product)
Possible errors:
* Returns NOT_FOUND If the Product is not found under the ProductSet.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
productSearchClient.removeProductFromProductSet(name.toString(), product.toString());
}
name
- The resource name for the ProductSet to modify.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
product
- The resource name for the Product to be removed from this ProductSet.
Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
ApiException
- if the remote call failspublic final void removeProductFromProductSet(com.google.cloud.vision.v1.RemoveProductFromProductSetRequest request)
Possible errors:
* Returns NOT_FOUND If the Product is not found under the ProductSet.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
RemoveProductFromProductSetRequest request = RemoveProductFromProductSetRequest.newBuilder()
.setName(name.toString())
.setProduct(product.toString())
.build();
productSearchClient.removeProductFromProductSet(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.RemoveProductFromProductSetRequest,Empty> removeProductFromProductSetCallable()
Possible errors:
* Returns NOT_FOUND If the Product is not found under the ProductSet.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]");
RemoveProductFromProductSetRequest request = RemoveProductFromProductSetRequest.newBuilder()
.setName(name.toString())
.setProduct(product.toString())
.build();
ApiFuture<Void> future = productSearchClient.removeProductFromProductSetCallable().futureCall(request);
// Do something
future.get();
}
public final ProductSearchClient.ListProductsInProductSetPagedResponse listProductsInProductSet(com.google.cloud.vision.v1.ProductSetName name)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) {
// doThingsWith(element);
}
}
name
- The ProductSet resource for which to retrieve Products.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductsInProductSetPagedResponse listProductsInProductSet(String name)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
for (Product element : productSearchClient.listProductsInProductSet(name.toString()).iterateAll()) {
// doThingsWith(element);
}
}
name
- The ProductSet resource for which to retrieve Products.
Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
ApiException
- if the remote call failspublic final ProductSearchClient.ListProductsInProductSetPagedResponse listProductsInProductSet(com.google.cloud.vision.v1.ListProductsInProductSetRequest request)
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ListProductsInProductSetRequest request = ListProductsInProductSetRequest.newBuilder()
.setName(name.toString())
.build();
for (Product element : productSearchClient.listProductsInProductSet(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.vision.v1.ListProductsInProductSetRequest,ProductSearchClient.ListProductsInProductSetPagedResponse> listProductsInProductSetPagedCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ListProductsInProductSetRequest request = ListProductsInProductSetRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ListProductsInProductSetPagedResponse> future = productSearchClient.listProductsInProductSetPagedCallable().futureCall(request);
// Do something
for (Product element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.vision.v1.ListProductsInProductSetRequest,com.google.cloud.vision.v1.ListProductsInProductSetResponse> listProductsInProductSetCallable()
Possible errors:
* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]");
ListProductsInProductSetRequest request = ListProductsInProductSetRequest.newBuilder()
.setName(name.toString())
.build();
while (true) {
ListProductsInProductSetResponse response = productSearchClient.listProductsInProductSetCallable().call(request);
for (Product element : response.getProductsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> importProductSetsAsync(com.google.cloud.vision.v1.LocationName parent, com.google.cloud.vision.v1.ImportProductSetsInputConfig inputConfig)
The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results)
The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build();
ImportProductSetsResponse response = productSearchClient.importProductSetsAsync(parent, inputConfig).get();
}
parent
- The project in which the ProductSets should be imported.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
inputConfig
- The input content for the list of requests.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> importProductSetsAsync(String parent, com.google.cloud.vision.v1.ImportProductSetsInputConfig inputConfig)
The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results)
The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build();
ImportProductSetsResponse response = productSearchClient.importProductSetsAsync(parent.toString(), inputConfig).get();
}
parent
- The project in which the ProductSets should be imported.
Format is `projects/PROJECT_ID/locations/LOC_ID`.
inputConfig
- The input content for the list of requests.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> importProductSetsAsync(com.google.cloud.vision.v1.ImportProductSetsRequest request)
The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results)
The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build();
ImportProductSetsRequest request = ImportProductSetsRequest.newBuilder()
.setParent(parent.toString())
.setInputConfig(inputConfig)
.build();
ImportProductSetsResponse response = productSearchClient.importProductSetsAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.vision.v1.ImportProductSetsRequest,com.google.cloud.vision.v1.ImportProductSetsResponse,com.google.cloud.vision.v1.BatchOperationMetadata> importProductSetsOperationCallable()
The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results)
The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build();
ImportProductSetsRequest request = ImportProductSetsRequest.newBuilder()
.setParent(parent.toString())
.setInputConfig(inputConfig)
.build();
OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> future = productSearchClient.importProductSetsOperationCallable().futureCall(request);
// Do something
ImportProductSetsResponse response = future.get();
}
public final UnaryCallable<com.google.cloud.vision.v1.ImportProductSetsRequest,Operation> importProductSetsCallable()
The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results)
The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
Sample code:
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build();
ImportProductSetsRequest request = ImportProductSetsRequest.newBuilder()
.setParent(parent.toString())
.setInputConfig(inputConfig)
.build();
ApiFuture<Operation> future = productSearchClient.importProductSetsCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.