Cloud Vision V1 Client - Class ProductSearchClient (1.10.0)

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.

Namespace

Google \ Cloud \ Vision \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
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
Name Description
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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\AddProductToProductSetRequest;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;

/**
 * @param string $formattedName    The resource name for the ProductSet to modify.
 *
 *                                 Format is:
 *                                 `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
 *                                 Please see {@see ProductSearchClient::productSetName()} for help formatting this field.
 * @param string $formattedProduct The resource name for the Product to be added to this ProductSet.
 *
 *                                 Format is:
 *                                 `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
 *                                 Please see {@see ProductSearchClient::productName()} for help formatting this field.
 */
function add_product_to_product_set_sample(string $formattedName, string $formattedProduct): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new AddProductToProductSetRequest())
        ->setName($formattedName)
        ->setProduct($formattedProduct);

    // Call the API and handle any network failures.
    try {
        $productSearchClient->addProductToProductSet($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
    $formattedProduct = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');

    add_product_to_product_set_sample($formattedName, $formattedProduct);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\Product
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\CreateProductRequest;
use Google\Cloud\Vision\V1\Product;

/**
 * @param string $formattedParent The project in which the Product should be created.
 *
 *                                Format is
 *                                `projects/PROJECT_ID/locations/LOC_ID`. Please see
 *                                {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function create_product_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $product = new Product();
    $request = (new CreateProductRequest())
        ->setParent($formattedParent)
        ->setProduct($product);

    // Call the API and handle any network failures.
    try {
        /** @var Product $response */
        $response = $productSearchClient->createProduct($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    create_product_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\ProductSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\CreateProductSetRequest;
use Google\Cloud\Vision\V1\ProductSet;

/**
 * @param string $formattedParent The project in which the ProductSet should be created.
 *
 *                                Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see
 *                                {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function create_product_set_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $productSet = new ProductSet();
    $request = (new CreateProductSetRequest())
        ->setParent($formattedParent)
        ->setProductSet($productSet);

    // Call the API and handle any network failures.
    try {
        /** @var ProductSet $response */
        $response = $productSearchClient->createProductSet($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    create_product_set_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\ReferenceImage
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\CreateReferenceImageRequest;
use Google\Cloud\Vision\V1\ReferenceImage;

/**
 * @param string $formattedParent   Resource name of the product in which to create the reference
 *                                  image.
 *
 *                                  Format is
 *                                  `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. Please see
 *                                  {@see ProductSearchClient::productName()} for help formatting this field.
 * @param string $referenceImageUri The Google Cloud Storage URI of the reference image.
 *
 *                                  The URI must start with `gs://`.
 */
function create_reference_image_sample(string $formattedParent, string $referenceImageUri): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $referenceImage = (new ReferenceImage())
        ->setUri($referenceImageUri);
    $request = (new CreateReferenceImageRequest())
        ->setParent($formattedParent)
        ->setReferenceImage($referenceImage);

    // Call the API and handle any network failures.
    try {
        /** @var ReferenceImage $response */
        $response = $productSearchClient->createReferenceImage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
    $referenceImageUri = '[URI]';

    create_reference_image_sample($formattedParent, $referenceImageUri);
}

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
Name Description
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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\DeleteProductRequest;

/**
 * @param string $formattedName Resource name of product to delete.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
 *                              Please see {@see ProductSearchClient::productName()} for help formatting this field.
 */
function delete_product_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new DeleteProductRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $productSearchClient->deleteProduct($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');

    delete_product_sample($formattedName);
}

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
Name Description
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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\DeleteProductSetRequest;

/**
 * @param string $formattedName Resource name of the ProductSet to delete.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
 *                              Please see {@see ProductSearchClient::productSetName()} for help formatting this field.
 */
function delete_product_set_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new DeleteProductSetRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $productSearchClient->deleteProductSet($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');

    delete_product_set_sample($formattedName);
}

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
Name Description
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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\DeleteReferenceImageRequest;

/**
 * @param string $formattedName The resource name of the reference image to delete.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
 *                              Please see {@see ProductSearchClient::referenceImageName()} for help formatting this field.
 */
function delete_reference_image_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new DeleteReferenceImageRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $productSearchClient->deleteReferenceImage($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::referenceImageName(
        '[PROJECT]',
        '[LOCATION]',
        '[PRODUCT]',
        '[REFERENCE_IMAGE]'
    );

    delete_reference_image_sample($formattedName);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\Product
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\GetProductRequest;
use Google\Cloud\Vision\V1\Product;

/**
 * @param string $formattedName Resource name of the Product to get.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
 *                              Please see {@see ProductSearchClient::productName()} for help formatting this field.
 */
function get_product_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new GetProductRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Product $response */
        $response = $productSearchClient->getProduct($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');

    get_product_sample($formattedName);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\ProductSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\GetProductSetRequest;
use Google\Cloud\Vision\V1\ProductSet;

/**
 * @param string $formattedName Resource name of the ProductSet to get.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
 *                              Please see {@see ProductSearchClient::productSetName()} for help formatting this field.
 */
function get_product_set_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new GetProductSetRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var ProductSet $response */
        $response = $productSearchClient->getProductSet($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');

    get_product_set_sample($formattedName);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\ReferenceImage
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\GetReferenceImageRequest;
use Google\Cloud\Vision\V1\ReferenceImage;

/**
 * @param string $formattedName The resource name of the ReferenceImage to get.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. Please see
 *                              {@see ProductSearchClient::referenceImageName()} for help formatting this field.
 */
function get_reference_image_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new GetReferenceImageRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var ReferenceImage $response */
        $response = $productSearchClient->getReferenceImage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::referenceImageName(
        '[PROJECT]',
        '[LOCATION]',
        '[PRODUCT]',
        '[REFERENCE_IMAGE]'
    );

    get_reference_image_sample($formattedName);
}

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
Name Description
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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ImportProductSetsInputConfig;
use Google\Cloud\Vision\V1\ImportProductSetsRequest;
use Google\Cloud\Vision\V1\ImportProductSetsResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The project in which the ProductSets should be imported.
 *
 *                                Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see
 *                                {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function import_product_sets_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $inputConfig = new ImportProductSetsInputConfig();
    $request = (new ImportProductSetsRequest())
        ->setParent($formattedParent)
        ->setInputConfig($inputConfig);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $productSearchClient->importProductSets($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ImportProductSetsResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    import_product_sets_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ListProductSetsRequest;
use Google\Cloud\Vision\V1\ProductSet;

/**
 * @param string $formattedParent The project from which ProductSets should be listed.
 *
 *                                Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see
 *                                {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function list_product_sets_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new ListProductSetsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $productSearchClient->listProductSets($request);

        /** @var ProductSet $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    list_product_sets_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ListProductsRequest;
use Google\Cloud\Vision\V1\Product;

/**
 * @param string $formattedParent The project OR ProductSet from which Products should be listed.
 *
 *                                Format:
 *                                `projects/PROJECT_ID/locations/LOC_ID`
 *                                Please see {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function list_products_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new ListProductsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $productSearchClient->listProducts($request);

        /** @var Product $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    list_products_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ListProductsInProductSetRequest;
use Google\Cloud\Vision\V1\Product;

/**
 * @param string $formattedName The ProductSet resource for which to retrieve Products.
 *
 *                              Format is:
 *                              `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
 *                              Please see {@see ProductSearchClient::productSetName()} for help formatting this field.
 */
function list_products_in_product_set_sample(string $formattedName): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new ListProductsInProductSetRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $productSearchClient->listProductsInProductSet($request);

        /** @var Product $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');

    list_products_in_product_set_sample($formattedName);
}

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
Name Description
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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ListReferenceImagesRequest;
use Google\Cloud\Vision\V1\ReferenceImage;

/**
 * @param string $formattedParent Resource name of the product containing the reference images.
 *
 *                                Format is
 *                                `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. Please see
 *                                {@see ProductSearchClient::productName()} for help formatting this field.
 */
function list_reference_images_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new ListReferenceImagesRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $productSearchClient->listReferenceImages($request);

        /** @var ReferenceImage $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');

    list_reference_images_sample($formattedParent);
}

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
Name Description
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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\PurgeProductsRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The project and location in which the Products should be deleted.
 *
 *                                Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see
 *                                {@see ProductSearchClient::locationName()} for help formatting this field.
 */
function purge_products_sample(string $formattedParent): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new PurgeProductsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $productSearchClient->purgeProducts($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ProductSearchClient::locationName('[PROJECT]', '[LOCATION]');

    purge_products_sample($formattedParent);
}

removeProductFromProductSet

Removes a Product from the specified ProductSet.

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

Parameters
Name Description
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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest;

/**
 * @param string $formattedName    The resource name for the ProductSet to modify.
 *
 *                                 Format is:
 *                                 `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
 *                                 Please see {@see ProductSearchClient::productSetName()} for help formatting this field.
 * @param string $formattedProduct The resource name for the Product to be removed from this
 *                                 ProductSet.
 *
 *                                 Format is:
 *                                 `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
 *                                 Please see {@see ProductSearchClient::productName()} for help formatting this field.
 */
function remove_product_from_product_set_sample(
    string $formattedName,
    string $formattedProduct
): void {
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $request = (new RemoveProductFromProductSetRequest())
        ->setName($formattedName)
        ->setProduct($formattedProduct);

    // Call the API and handle any network failures.
    try {
        $productSearchClient->removeProductFromProductSet($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ProductSearchClient::productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
    $formattedProduct = ProductSearchClient::productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');

    remove_product_from_product_set_sample($formattedName, $formattedProduct);
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\Product
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\Product;
use Google\Cloud\Vision\V1\UpdateProductRequest;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_product_sample(): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $product = new Product();
    $request = (new UpdateProductRequest())
        ->setProduct($product);

    // Call the API and handle any network failures.
    try {
        /** @var Product $response */
        $response = $productSearchClient->updateProduct($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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
Name Description
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
Type Description
Google\Cloud\Vision\V1\ProductSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Vision\V1\Client\ProductSearchClient;
use Google\Cloud\Vision\V1\ProductSet;
use Google\Cloud\Vision\V1\UpdateProductSetRequest;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_product_set_sample(): void
{
    // Create a client.
    $productSearchClient = new ProductSearchClient();

    // Prepare the request message.
    $productSet = new ProductSet();
    $request = (new UpdateProductSetRequest())
        ->setProductSet($productSet);

    // Call the API and handle any network failures.
    try {
        /** @var ProductSet $response */
        $response = $productSearchClient->updateProductSet($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

addProductToProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\AddProductToProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createProductAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\CreateProductRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\CreateProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createReferenceImageAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\CreateReferenceImageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteProductAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\DeleteProductRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\DeleteProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteReferenceImageAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\DeleteReferenceImageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getProductAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\GetProductRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\GetProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getReferenceImageAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\GetReferenceImageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

importProductSetsAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\ImportProductSetsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listProductSetsAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\ListProductSetsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listProductsAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\ListProductsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listProductsInProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\ListProductsInProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listReferenceImagesAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\ListReferenceImagesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

purgeProductsAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\PurgeProductsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

removeProductFromProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateProductAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\UpdateProductRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateProductSetAsync

Parameters
Name Description
request Google\Cloud\Vision\V1\UpdateProductSetRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

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

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

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::locationName

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

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location resource.

static::productName

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

Parameters
Name Description
project string
location string
product string
Returns
Type Description
string The formatted product resource.

static::productSetName

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

Parameters
Name Description
project string
location string
productSet string
Returns
Type Description
string The formatted product_set resource.

static::referenceImageName

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

Parameters
Name Description
project string
location string
product string
referenceImage string
Returns
Type Description
string The 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
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.