Constructor
new ProductSearchClient(optionsopt)
Construct an instance of ProductSearchClient.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The configuration object. The options accepted by the constructor are described in detail in this document. The common options are: Properties
|
Members
apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
addProductToProductSet(request, optionsopt) → {Promise}
Adds a Product to the specified ProductSet. If the Product is already present, no change is made.
One Product can be added to at most 100 ProductSets.
Possible errors:
- Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
(async) checkImportProductSetsProgress(name) → {Promise}
Check the status of the long running operation returned by importProductSets().
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
The operation name that will be passed. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
Example
const decodedOperation = await checkImportProductSetsProgress(name);
console.log(decodedOperation.result);
console.log(decodedOperation.done);
console.log(decodedOperation.metadata);
close() → {Promise}
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns:
| Type | Description |
|---|---|
| Promise |
A promise that resolves when the client is closed. |
createProduct(request, optionsopt) → {Promise}
Creates and returns a new product resource.
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.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
createProductSet(request, optionsopt) → {Promise}
Creates and returns a new ProductSet resource.
Possible errors:
- Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
createReferenceImage(request, optionsopt) → {Promise}
Creates and returns a new ReferenceImage resource.
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.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
deleteProduct(request, optionsopt) → {Promise}
Permanently deletes a product and its reference images.
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.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
deleteProductSet(request, optionsopt) → {Promise}
Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted.
The actual image files are not deleted from Google Cloud Storage.
Possible errors:
- Returns NOT_FOUND if the ProductSet does not exist.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
deleteReferenceImage(request, optionsopt) → {Promise}
Permanently deletes a reference image.
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.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
getProduct(request, optionsopt) → {Promise}
Gets information associated with a Product.
Possible errors:
- Returns NOT_FOUND if the Product does not exist.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
getProductSet(request, optionsopt) → {Promise}
Gets information associated with a ProductSet.
Possible errors:
- Returns NOT_FOUND if the ProductSet does not exist.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
getProjectId() → {Promise}
Return the project ID used by this class.
Returns:
| Type | Description |
|---|---|
| Promise |
A promise that resolves to string containing the project ID. |
getReferenceImage(request, optionsopt) → {Promise}
Gets information associated with a ReferenceImage.
Possible errors:
- Returns NOT_FOUND if the specified image does not exist.
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
importProductSets(request, optionsopt) → {Promise}
Asynchronous API that imports a list of reference images to specified product sets based on a list of image information.
The 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.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
Example
const [operation] = await client.importProductSets(request);
const [response] = await operation.promise();
initialize() → {Promise}
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns:
| Type | Description |
|---|---|
| Promise |
A promise that resolves to an authenticated service stub. |
listProducts(request, optionsopt) → {Promise}
Lists products in an unspecified order.
Possible errors:
- Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
listProductsAsync(request, optionsopt) → {Object}
Equivalent to listProducts, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements on-demand.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Object |
An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Product. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
Example
const iterable = client.listProductsAsync(request);
for await (const response of iterable) {
// process response
}
listProductSets(request, optionsopt) → {Promise}
Lists ProductSets in an unspecified order.
Possible errors:
- Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
listProductSetsAsync(request, optionsopt) → {Object}
Equivalent to listProductSets, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements on-demand.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Object |
An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ProductSet. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
Example
const iterable = client.listProductSetsAsync(request);
for await (const response of iterable) {
// process response
}
listProductSetsStream(request, optionsopt) → {Stream}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Stream |
An object stream which emits an object representing ProductSet on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using |
listProductsInProductSet(request, optionsopt) → {Promise}
Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty.
Possible errors:
- Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
listProductsInProductSetAsync(request, optionsopt) → {Object}
Equivalent to listProductsInProductSet, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements on-demand.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Object |
An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Product. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
Example
const iterable = client.listProductsInProductSetAsync(request);
for await (const response of iterable) {
// process response
}
listProductsInProductSetStream(request, optionsopt) → {Stream}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Stream |
An object stream which emits an object representing Product on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using |
listProductsStream(request, optionsopt) → {Stream}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Stream |
An object stream which emits an object representing Product on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using |
listReferenceImages(request, optionsopt) → {Promise}
Lists reference images.
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.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
listReferenceImagesAsync(request, optionsopt) → {Object}
Equivalent to listReferenceImages, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements on-demand.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Object |
An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ReferenceImage. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
Example
const iterable = client.listReferenceImagesAsync(request);
for await (const response of iterable) {
// process response
}
listReferenceImagesStream(request, optionsopt) → {Stream}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Stream |
An object stream which emits an object representing ReferenceImage on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using |
locationPath(project, location) → {string}
Return a fully-qualified location resource name string.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
string | |
location |
string |
Returns:
| Type | Description |
|---|---|
| string |
Resource name string. |
matchLocationFromLocationName(locationName) → {string}
Parse the location from Location resource.
Parameters:
| Name | Type | Description |
|---|---|---|
locationName |
string |
A fully-qualified path representing Location resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the location. |
matchLocationFromProductName(productName) → {string}
Parse the location from Product resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productName |
string |
A fully-qualified path representing Product resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the location. |
matchLocationFromProductSetName(productSetName) → {string}
Parse the location from ProductSet resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productSetName |
string |
A fully-qualified path representing ProductSet resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the location. |
matchLocationFromReferenceImageName(referenceImageName) → {string}
Parse the location from ReferenceImage resource.
Parameters:
| Name | Type | Description |
|---|---|---|
referenceImageName |
string |
A fully-qualified path representing ReferenceImage resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the location. |
matchProductFromProductName(productName) → {string}
Parse the product from Product resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productName |
string |
A fully-qualified path representing Product resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the product. |
matchProductFromReferenceImageName(referenceImageName) → {string}
Parse the product from ReferenceImage resource.
Parameters:
| Name | Type | Description |
|---|---|---|
referenceImageName |
string |
A fully-qualified path representing ReferenceImage resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the product. |
matchProductSetFromProductSetName(productSetName) → {string}
Parse the product_set from ProductSet resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productSetName |
string |
A fully-qualified path representing ProductSet resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the product_set. |
matchProjectFromLocationName(locationName) → {string}
Parse the project from Location resource.
Parameters:
| Name | Type | Description |
|---|---|---|
locationName |
string |
A fully-qualified path representing Location resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the project. |
matchProjectFromProductName(productName) → {string}
Parse the project from Product resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productName |
string |
A fully-qualified path representing Product resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the project. |
matchProjectFromProductSetName(productSetName) → {string}
Parse the project from ProductSet resource.
Parameters:
| Name | Type | Description |
|---|---|---|
productSetName |
string |
A fully-qualified path representing ProductSet resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the project. |
matchProjectFromReferenceImageName(referenceImageName) → {string}
Parse the project from ReferenceImage resource.
Parameters:
| Name | Type | Description |
|---|---|---|
referenceImageName |
string |
A fully-qualified path representing ReferenceImage resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the project. |
matchReferenceImageFromReferenceImageName(referenceImageName) → {string}
Parse the reference_image from ReferenceImage resource.
Parameters:
| Name | Type | Description |
|---|---|---|
referenceImageName |
string |
A fully-qualified path representing ReferenceImage resource. |
Returns:
| Type | Description |
|---|---|
| string |
A string representing the reference_image. |
productPath(project, location, product) → {string}
Return a fully-qualified product resource name string.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
string | |
location |
string | |
product |
string |
Returns:
| Type | Description |
|---|---|
| string |
Resource name string. |
productSetPath(project, location, product_set) → {string}
Return a fully-qualified productSet resource name string.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
string | |
location |
string | |
product_set |
string |
Returns:
| Type | Description |
|---|---|
| string |
Resource name string. |
referenceImagePath(project, location, product, reference_image) → {string}
Return a fully-qualified referenceImage resource name string.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
string | |
location |
string | |
product |
string | |
reference_image |
string |
Returns:
| Type | Description |
|---|---|
| string |
Resource name string. |
removeProductFromProductSet(request, optionsopt) → {Promise}
Removes a Product from the specified ProductSet.
Possible errors:
- Returns NOT_FOUND If the Product is not found under the ProductSet.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
updateProduct(request, optionsopt) → {Promise}
Makes changes to a Product resource. Only display_name, description and labels can be updated right now.
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.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|
updateProductSet(request, optionsopt) → {Promise}
Makes changes to a ProductSet resource. Only display_name can be updated currently.
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.
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
| Type | Description |
|---|---|
| Promise |
|