Constructor

ProductSearchClient

new ProductSearchClient(options)

Construct an instance of ProductSearchClient.

Parameter

options

Optional

object

The configuration object. See the subsequent parameters for more details.

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static

The DNS address for this API service.

Methods

addProductToProductSet

addProductToProductSet(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name for the ProductSet to modify.

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

product

string

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

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
var product = '';
var request = {
  name: formattedName,
  product: product,
};
client.addProductToProductSet(request).catch(err => {
  console.error(err);
});

createProduct

createProduct(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project in which the Product should be created.

Format is projects/PROJECT_ID/locations/LOC_ID.

product

Object

The product to create.

This object should have the same structure as Product

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Product.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Product. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
var product = {};
var productId = '';
var request = {
  parent: formattedParent,
  product: product,
  productId: productId,
};
client.createProduct(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

createProductSet

createProductSet(request, options, callback) returns Promise

Creates and returns a new ProductSet resource.

Possible errors:

  • Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project in which the ProductSet should be created.

Format is projects/PROJECT_ID/locations/LOC_ID.

productSet

Object

The ProductSet to create.

This object should have the same structure as ProductSet

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ProductSet.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
var productSet = {};
var productSetId = '';
var request = {
  parent: formattedParent,
  productSet: productSet,
  productSetId: productSetId,
};
client.createProductSet(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

createReferenceImage

createReferenceImage(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

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

referenceImage

Object

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

This object should have the same structure as ReferenceImage

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ReferenceImage.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ReferenceImage. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');
var referenceImage = {};
var referenceImageId = '';
var request = {
  parent: formattedParent,
  referenceImage: referenceImage,
  referenceImageId: referenceImageId,
};
client.createReferenceImage(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

deleteProduct

deleteProduct(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of product to delete.

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');
client.deleteProduct({name: formattedName}).catch(err => {
  console.error(err);
});

deleteProductSet

deleteProductSet(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the ProductSet to delete.

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
client.deleteProductSet({name: formattedName}).catch(err => {
  console.error(err);
});

deleteReferenceImage

deleteReferenceImage(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name of the reference image to delete.

Format is:

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
client.deleteReferenceImage({name: formattedName}).catch(err => {
  console.error(err);
});

getProduct

getProduct(request, options, callback) returns Promise

Gets information associated with a Product.

Possible errors:

  • Returns NOT_FOUND if the Product does not exist.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the Product to get.

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Product.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Product. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');
client.getProduct({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProductSet

getProductSet(request, options, callback) returns Promise

Gets information associated with a ProductSet.

Possible errors:

  • Returns NOT_FOUND if the ProductSet does not exist.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Resource name of the ProductSet to get.

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ProductSet.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
client.getProductSet({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

getReferenceImage

getReferenceImage(request, options, callback) returns Promise

Gets information associated with a ReferenceImage.

Possible errors:

  • Returns NOT_FOUND if the specified image does not exist.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name of the ReferenceImage to get.

Format is:

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ReferenceImage.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ReferenceImage. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
client.getReferenceImage({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

importProductSets

importProductSets(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project in which the ProductSets should be imported.

Format is projects/PROJECT_ID/locations/LOC_ID.

inputConfig

Object

The input content for the list of requests.

This object should have the same structure as ImportProductSetsInputConfig

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
var inputConfig = {};
var request = {
  parent: formattedParent,
  inputConfig: inputConfig,
};

// Handle the operation using the promise pattern.
client.importProductSets(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    // The final result of the operation.
    var result = responses[0];

    // The metadata value of the completed operation.
    var metadata = responses[1];

    // The response of the api call returning the complete operation.
    var finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
var inputConfig = {};
var request = {
  parent: formattedParent,
  inputConfig: inputConfig,
};

// Handle the operation using the event emitter pattern.
client.importProductSets(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

listProducts

listProducts(request, options, callback) returns Promise

Lists products in an unspecified order.

Possible errors:

  • Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project OR ProductSet from which Products should be listed.

Format: projects/PROJECT_ID/locations/LOC_ID

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of Product.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListProductsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Product.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Product in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListProductsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');

client.listProducts({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listProducts(nextRequest, options).then(callback);
  }
}
client.listProducts({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listProductSets

listProductSets(request, options, callback) returns Promise

Lists ProductSets in an unspecified order.

Possible errors:

  • Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project from which ProductSets should be listed.

Format is projects/PROJECT_ID/locations/LOC_ID.

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of ProductSet.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListProductSetsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of ProductSet.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of ProductSet in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListProductSetsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');

client.listProductSets({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listProductSets(nextRequest, options).then(callback);
  }
}
client.listProductSets({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listProductSetsStream

listProductSetsStream(request, options) returns Stream

Equivalent to listProductSets, but returns a NodeJS Stream object.

This fetches the paged responses for listProductSets continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project from which ProductSets should be listed.

Format is projects/PROJECT_ID/locations/LOC_ID.

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing ProductSet on 'data' event.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
client.listProductSetsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listProductsInProductSet

listProductsInProductSet(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The ProductSet resource for which to retrieve Products.

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of Product.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListProductsInProductSetResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Product.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Product in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListProductsInProductSetResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');

client.listProductsInProductSet({name: formattedName})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listProductsInProductSet(nextRequest, options).then(callback);
  }
}
client.listProductsInProductSet({name: formattedName}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listProductsInProductSetStream

listProductsInProductSetStream(request, options) returns Stream

Equivalent to listProductsInProductSet, but returns a NodeJS Stream object.

This fetches the paged responses for listProductsInProductSet continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The ProductSet resource for which to retrieve Products.

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Product on 'data' event.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
client.listProductsInProductSetStream({name: formattedName})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listProductsStream

listProductsStream(request, options) returns Stream

Equivalent to listProducts, but returns a NodeJS Stream object.

This fetches the paged responses for listProducts continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

The project OR ProductSet from which Products should be listed.

Format: projects/PROJECT_ID/locations/LOC_ID

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Product on 'data' event.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
client.listProductsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listReferenceImages

listReferenceImages(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the product containing the reference images.

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of ReferenceImage.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListReferenceImagesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of ReferenceImage.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of ReferenceImage in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListReferenceImagesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');

client.listReferenceImages({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listReferenceImages(nextRequest, options).then(callback);
  }
}
client.listReferenceImages({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listReferenceImagesStream

listReferenceImagesStream(request, options) returns Stream

Equivalent to listReferenceImages, but returns a NodeJS Stream object.

This fetches the paged responses for listReferenceImages continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Resource name of the product containing the reference images.

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing ReferenceImage on 'data' event.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]');
client.listReferenceImagesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

locationPath

locationPath(project, location) returns String

Return a fully-qualified location resource name string.

Parameter

project

String

location

String

Returns

String 

matchLocationFromLocationName

matchLocationFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the location.

matchLocationFromProductName

matchLocationFromProductName(productName) returns String

Parse the productName from a product resource.

Parameter

productName

String

A fully-qualified path representing a product resources.

Returns

String 

  • A string representing the location.

matchLocationFromProductSetName

matchLocationFromProductSetName(productSetName) returns String

Parse the productSetName from a product_set resource.

Parameter

productSetName

String

A fully-qualified path representing a product_set resources.

Returns

String 

  • A string representing the location.

matchLocationFromReferenceImageName

matchLocationFromReferenceImageName(referenceImageName) returns String

Parse the referenceImageName from a reference_image resource.

Parameter

referenceImageName

String

A fully-qualified path representing a reference_image resources.

Returns

String 

  • A string representing the location.

matchProductFromProductName

matchProductFromProductName(productName) returns String

Parse the productName from a product resource.

Parameter

productName

String

A fully-qualified path representing a product resources.

Returns

String 

  • A string representing the product.

matchProductFromReferenceImageName

matchProductFromReferenceImageName(referenceImageName) returns String

Parse the referenceImageName from a reference_image resource.

Parameter

referenceImageName

String

A fully-qualified path representing a reference_image resources.

Returns

String 

  • A string representing the product.

matchProductSetFromProductSetName

matchProductSetFromProductSetName(productSetName) returns String

Parse the productSetName from a product_set resource.

Parameter

productSetName

String

A fully-qualified path representing a product_set resources.

Returns

String 

  • A string representing the product_set.

matchProjectFromLocationName

matchProjectFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the project.

matchProjectFromProductName

matchProjectFromProductName(productName) returns String

Parse the productName from a product resource.

Parameter

productName

String

A fully-qualified path representing a product resources.

Returns

String 

  • A string representing the project.

matchProjectFromProductSetName

matchProjectFromProductSetName(productSetName) returns String

Parse the productSetName from a product_set resource.

Parameter

productSetName

String

A fully-qualified path representing a product_set resources.

Returns

String 

  • A string representing the project.

matchProjectFromReferenceImageName

matchProjectFromReferenceImageName(referenceImageName) returns String

Parse the referenceImageName from a reference_image resource.

Parameter

referenceImageName

String

A fully-qualified path representing a reference_image resources.

Returns

String 

  • A string representing the project.

matchReferenceImageFromReferenceImageName

matchReferenceImageFromReferenceImageName(referenceImageName) returns String

Parse the referenceImageName from a reference_image resource.

Parameter

referenceImageName

String

A fully-qualified path representing a reference_image resources.

Returns

String 

  • A string representing the reference_image.

productPath

productPath(project, location, product) returns String

Return a fully-qualified product resource name string.

Parameter

project

String

location

String

product

String

Returns

String 

productSetPath

productSetPath(project, location, productSet) returns String

Return a fully-qualified product_set resource name string.

Parameter

project

String

location

String

productSet

String

Returns

String 

referenceImagePath

referenceImagePath(project, location, product, referenceImage) returns String

Return a fully-qualified reference_image resource name string.

Parameter

project

String

location

String

product

String

referenceImage

String

Returns

String 

removeProductFromProductSet

removeProductFromProductSet(request, options, callback) returns Promise

Removes a Product from the specified ProductSet.

Possible errors:

  • Returns NOT_FOUND If the Product is not found under the ProductSet.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

The resource name for the ProductSet to modify.

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

product

string

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

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
var product = '';
var request = {
  name: formattedName,
  product: product,
};
client.removeProductFromProductSet(request).catch(err => {
  console.error(err);
});

updateProduct

updateProduct(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

product

Object

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

This object should have the same structure as Product

updateMask

Object

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.

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Product.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Product. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var product = {};
var updateMask = {};
var request = {
  product: product,
  updateMask: updateMask,
};
client.updateProduct(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

updateProductSet

updateProductSet(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

productSet

Object

The ProductSet resource which replaces the one on the server.

This object should have the same structure as ProductSet

updateMask

Object

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.

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ProductSet.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ProductSet. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const vision = require('@google-cloud/vision');

var client = new vision.v1p3beta1.ProductSearchClient({
  // optional auth parameters.
});

var productSet = {};
var updateMask = {};
var request = {
  productSet: productSet,
  updateMask: updateMask,
};
client.updateProductSet(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });