Cloud Vision V1 Client - Class ProductSearchClient (1.7.6)

Reference documentation and code samples for the Cloud Vision V1 Client class ProductSearchClient.

Service Description: 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/*

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

This class is currently experimental and may be subject to changes. See Google\Cloud\Vision\V1\ProductSearchClient for the stable implementation

Namespace

Google \ Cloud \ Vision \ V1 \ Client

Methods

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

addProductToProductSet

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\AddProductToProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

createProduct

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateProductRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\Product

createProductSet

Creates and returns a new ProductSet resource.

Possible errors:

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

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\ProductSet

createReferenceImage

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateReferenceImageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\ReferenceImage

deleteProduct

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteProductRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

deleteProductSet

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

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

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

deleteReferenceImage

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteReferenceImageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

getProduct

Gets information associated with a Product.

Possible errors:

  • Returns NOT_FOUND if the Product does not exist.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetProductRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\Product

getProductSet

Gets information associated with a ProductSet.

Possible errors:

  • Returns NOT_FOUND if the ProductSet does not exist.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\ProductSet

getReferenceImage

Gets information associated with a ReferenceImage.

Possible errors:

  • Returns NOT_FOUND if the specified image does not exist.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetReferenceImageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\ReferenceImage

importProductSets

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\ImportProductSetsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse

listProductSets

Lists ProductSets in an unspecified order.

Possible errors:

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

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductSetsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

listProducts

Lists products in an unspecified order.

Possible errors:

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

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

listProductsInProductSet

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductsInProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

listReferenceImages

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListReferenceImagesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

purgeProducts

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)

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\PurgeProductsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse

removeProductFromProductSet

Removes a Product from the specified ProductSet.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

updateProduct

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\UpdateProductRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\Product

updateProductSet

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.

The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync() .

Parameters
NameDescription
request Google\Cloud\Vision\V1\UpdateProductSetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Vision\V1\ProductSet

addProductToProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\AddProductToProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createProductAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateProductRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createReferenceImageAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\CreateReferenceImageRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteProductAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteProductRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteReferenceImageAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\DeleteReferenceImageRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getProductAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetProductRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getReferenceImageAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\GetReferenceImageRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

importProductSetsAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\ImportProductSetsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listProductSetsAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductSetsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listProductsAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listProductsInProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListProductsInProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listReferenceImagesAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\ListReferenceImagesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

purgeProductsAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\PurgeProductsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

removeProductFromProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateProductAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\UpdateProductRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateProductSetAsync

Parameters
NameDescription
request Google\Cloud\Vision\V1\UpdateProductSetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

static::locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

static::productName

Formats a string containing the fully-qualified path to represent a product resource.

Parameters
NameDescription
project string
location string
product string
Returns
TypeDescription
stringThe formatted product resource.

static::productSetName

Formats a string containing the fully-qualified path to represent a product_set resource.

Parameters
NameDescription
project string
location string
productSet string
Returns
TypeDescription
stringThe formatted product_set resource.

static::referenceImageName

Formats a string containing the fully-qualified path to represent a reference_image resource.

Parameters
NameDescription
project string
location string
product string
referenceImage string
Returns
TypeDescription
stringThe formatted reference_image resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • location: projects/{project}/locations/{location}
  • product: projects/{project}/locations/{location}/products/{product}
  • productSet: projects/{project}/locations/{location}/productSets/{product_set}
  • referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.