ProductSearchClient

ProductSearchClient

Manages Products and ProductSets of reference images for use in product search. It uses the following resource model:

  • The API has a collection of 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 resources, named projects/* /locations/* /products/*

  • Each Product has a collection of ReferenceImage resources, named projects/* /locations/* /products/* /referenceImages/*

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
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean <optional>

Use HTTP fallback mode. In fallback mode, a special browser-compatible transport implementation is used instead of gRPC transport. In browser context (if the window object is defined) the fallback mode is enabled automatically; set options.fallback to false if you need to override this behavior.

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
Name Type Description
name string

Required. The resource name for the ProductSet to modify.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

product string

Required. The resource name for the Product to be added to this ProductSet.

Format is: projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.addProductToProductSet(request);

(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
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
const decodedOperation = await checkImportProductSetsProgress(name);
console.log(decodedOperation.result);
console.log(decodedOperation.done);
console.log(decodedOperation.metadata);

(async) checkPurgeProductsProgress(name) → {Promise}

Check the status of the long running operation returned by purgeProducts().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
const decodedOperation = await checkPurgeProductsProgress(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
Name Type Description
parent string

Required. The project in which the Product should be created.

Format is projects/PROJECT_ID/locations/LOC_ID.

product google.cloud.vision.v1p4beta1.Product

Required. The product to create.

productId string

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 /.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Product. Please see the documentation for more details and examples.
Example
const [response] = await client.createProduct(request);

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
Name Type Description
parent string

Required. The project in which the ProductSet should be created.

Format is projects/PROJECT_ID/locations/LOC_ID.

productSet google.cloud.vision.v1p4beta1.ProductSet

Required. The ProductSet to create.

productSetId string

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 /.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. Please see the documentation for more details and examples.
Example
const [response] = await client.createProductSet(request);

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
Name Type Description
parent string

Required. Resource name of the product in which to create the reference image.

Format is projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID.

referenceImage google.cloud.vision.v1p4beta1.ReferenceImage

Required. The reference image to create. If an image ID is specified, it is ignored.

referenceImageId string

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 /.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing ReferenceImage. Please see the documentation for more details and examples.
Example
const [response] = await client.createReferenceImage(request);

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. Resource name of product to delete.

Format is: projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteProduct(request);

deleteProductSet(request, optionsopt) → {Promise}

Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted.

The actual image files are not deleted from Google Cloud Storage.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. Resource name of the ProductSet to delete.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteProductSet(request);

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The resource name of the reference image to delete.

Format is:

projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteReferenceImage(request);

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
Name Type Description
name string

Required. Resource name of the Product to get.

Format is: projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Product. Please see the documentation for more details and examples.
Example
const [response] = await client.getProduct(request);

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
Name Type Description
name string

Required. Resource name of the ProductSet to get.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. Please see the documentation for more details and examples.
Example
const [response] = await client.getProductSet(request);

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
Name Type Description
name string

Required. The resource name of the ReferenceImage to get.

Format is:

projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing ReferenceImage. Please see the documentation for more details and examples.
Example
const [response] = await client.getReferenceImage(request);

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
Name Type Description
parent string

Required. The project in which the ProductSets should be imported.

Format is projects/PROJECT_ID/locations/LOC_ID.

inputConfig google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig

Required. The input content for the list of requests.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.
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
Name Type Description
parent string

Required. The project OR ProductSet from which Products should be listed.

Format: projects/PROJECT_ID/locations/LOC_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Product. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listProductsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
parent string

Required. The project OR ProductSet from which Products should be listed.

Format: projects/PROJECT_ID/locations/LOC_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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
Name Type Description
parent string

Required. The project from which ProductSets should be listed.

Format is projects/PROJECT_ID/locations/LOC_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of ProductSet. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listProductSetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
parent string

Required. The project from which ProductSets should be listed.

Format is projects/PROJECT_ID/locations/LOC_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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
Name Type Description
parent string

Required. The project from which ProductSets should be listed.

Format is projects/PROJECT_ID/locations/LOC_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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 listProductSetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
name string

Required. The ProductSet resource for which to retrieve Products.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Product. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listProductsInProductSetAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
name string

Required. The ProductSet resource for which to retrieve Products.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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
Name Type Description
name string

Required. The ProductSet resource for which to retrieve Products.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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 listProductsInProductSetAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
parent string

Required. The project OR ProductSet from which Products should be listed.

Format: projects/PROJECT_ID/locations/LOC_ID

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

The next_page_token returned from a previous List request, if any.

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 listProductsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
parent string

Required. Resource name of the product containing the reference images.

Format is projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

A token identifying a page of results to be returned. This is the value of nextPageToken returned in a previous reference image list request.

Defaults to the first page if not specified.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of ReferenceImage. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listReferenceImagesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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
Name Type Description
parent string

Required. Resource name of the product containing the reference images.

Format is projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

A token identifying a page of results to be returned. This is the value of nextPageToken returned in a previous reference image list request.

Defaults to the first page if not specified.

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
Name Type Description
parent string

Required. Resource name of the product containing the reference images.

Format is projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID.

pageSize number

The maximum number of items to return. Default 10, maximum 100.

pageToken string

A token identifying a page of results to be returned. This is the value of nextPageToken returned in a previous reference image list request.

Defaults to the first page if not specified.

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 listReferenceImagesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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.

purgeProducts(request, optionsopt) → {Promise}

Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet.

If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted.

It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted.

It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion.

If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet.

The google.longrunning.Operation API can be used to keep track of the progress and results of the request. Operation.metadata contains BatchOperationMetadata. (progress)

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
productSetPurgeConfig google.cloud.vision.v1p4beta1.ProductSetPurgeConfig

Specify which ProductSet contains the Products to be deleted.

deleteOrphanProducts boolean

If delete_orphan_products is true, all Products that are not in any ProductSet will be deleted.

parent string

Required. The project and location in which the Products should be deleted.

Format is projects/PROJECT_ID/locations/LOC_ID.

force boolean

The default value is false. Override this value to true to actually perform the purge.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.
Example
const [operation] = await client.purgeProducts(request);
const [response] = await operation.promise();

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The resource name for the ProductSet to modify.

Format is: projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID

product string

Required. The resource name for the Product to be removed from this ProductSet.

Format is: projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.removeProductFromProductSet(request);

updateProduct(request, optionsopt) → {Promise}

Makes changes to a Product resource. Only the display_name, description, and labels fields 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
Name Type Description
product google.cloud.vision.v1p4beta1.Product

Required. The Product resource which replaces the one on the server. product.name is immutable.

updateMask google.protobuf.FieldMask

The 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.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Product. Please see the documentation for more details and examples.
Example
const [response] = await client.updateProduct(request);

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
Name Type Description
productSet google.cloud.vision.v1p4beta1.ProductSet

Required. The ProductSet resource which replaces the one on the server.

updateMask google.protobuf.FieldMask

The 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.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. Please see the documentation for more details and examples.
Example
const [response] = await client.updateProductSet(request);