class Google::Cloud::Vision::V1::ProductSearch::Client

Client for the ProductSearch service.

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

`projects//locations//productSets/*`, which acts as a way to put different products into groups to limit identification.

In parallel,

Attributes

operations_client[R]

Get the associated client for long-running operations.

@return [::Google::Cloud::Vision::V1::ProductSearch::Operations]

product_search_stub[R]

@private

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the ProductSearch Client class.

See {::Google::Cloud::Vision::V1::ProductSearch::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all ProductSearch clients
::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/vision/v1/product_search/client.rb, line 69
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Vision", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.create_product_set.timeout = 600.0
    default_config.rpcs.create_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
    }

    default_config.rpcs.list_product_sets.timeout = 600.0
    default_config.rpcs.list_product_sets.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_product_set.timeout = 600.0
    default_config.rpcs.get_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.update_product_set.timeout = 600.0
    default_config.rpcs.update_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.delete_product_set.timeout = 600.0
    default_config.rpcs.delete_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.create_product.timeout = 600.0
    default_config.rpcs.create_product.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
    }

    default_config.rpcs.list_products.timeout = 600.0
    default_config.rpcs.list_products.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_product.timeout = 600.0
    default_config.rpcs.get_product.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.update_product.timeout = 600.0
    default_config.rpcs.update_product.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.delete_product.timeout = 600.0
    default_config.rpcs.delete_product.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.create_reference_image.timeout = 600.0
    default_config.rpcs.create_reference_image.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
    }

    default_config.rpcs.delete_reference_image.timeout = 600.0
    default_config.rpcs.delete_reference_image.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.list_reference_images.timeout = 600.0
    default_config.rpcs.list_reference_images.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_reference_image.timeout = 600.0
    default_config.rpcs.get_reference_image.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.add_product_to_product_set.timeout = 600.0
    default_config.rpcs.add_product_to_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.remove_product_from_product_set.timeout = 600.0
    default_config.rpcs.remove_product_from_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.list_products_in_product_set.timeout = 600.0
    default_config.rpcs.list_products_in_product_set.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.import_product_sets.timeout = 600.0
    default_config.rpcs.import_product_sets.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
    }

    default_config.rpcs.purge_products.timeout = 600.0
    default_config.rpcs.purge_products.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: []
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new ProductSearch client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
  config.timeout = 10.0
end

@yield [config] Configure the ProductSearch client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/vision/v1/product_search/client.rb, line 217
def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/vision/v1/product_search_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.endpoint = @config.endpoint
  end

  @product_search_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Vision::V1::ProductSearch::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

add_product_to_product_set(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload add_product_to_product_set(request, options = nil)

Pass arguments to `add_product_to_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::AddProductToProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::AddProductToProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload add_product_to_product_set(name: nil, product: nil)

Pass arguments to `add_product_to_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. The resource name for the ProductSet to modify.

  Format is:
  `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
@param product [::String]
  Required. The resource name for the Product to be added to this ProductSet.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::AddProductToProductSetRequest.new

# Call the add_product_to_product_set method.
result = client.add_product_to_product_set request

# The returned object is of type Google::Protobuf::Empty.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1683
def add_product_to_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::AddProductToProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.add_product_to_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.add_product_to_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.add_product_to_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :add_product_to_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
configure() { |config| ... } click to toggle source

Configure the ProductSearch Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on {Client.configure}.

See {::Google::Cloud::Vision::V1::ProductSearch::Client::Configuration} for a description of the configuration fields.

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/vision/v1/product_search/client.rb, line 196
def configure
  yield @config if block_given?
  @config
end
create_product(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload create_product(request, options = nil)

Pass arguments to `create_product` via a request object, either of type
{::Google::Cloud::Vision::V1::CreateProductRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::CreateProductRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload create_product(parent: nil, product: nil, product_id: nil)

Pass arguments to `create_product` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project in which the Product should be created.

  Format is
  `projects/PROJECT_ID/locations/LOC_ID`.
@param product [::Google::Cloud::Vision::V1::Product, ::Hash]
  Required. The product to create.
@param product_id [::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 `/`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::Product] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::Product]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::CreateProductRequest.new

# Call the create_product method.
result = client.create_product request

# The returned object is of type Google::Cloud::Vision::V1::Product.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 800
def create_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::CreateProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.create_product.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_product.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :create_product, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
create_product_set(request, options = nil) { |response, operation| ... } click to toggle source

Creates and returns a new ProductSet resource.

Possible errors:

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

@overload create_product_set(request, options = nil)

Pass arguments to `create_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::CreateProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::CreateProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload create_product_set(parent: nil, product_set: nil, product_set_id: nil)

Pass arguments to `create_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project in which the ProductSet should be created.

  Format is `projects/PROJECT_ID/locations/LOC_ID`.
@param product_set [::Google::Cloud::Vision::V1::ProductSet, ::Hash]
  Required. The ProductSet to create.
@param product_set_id [::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 `/`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::ProductSet] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::ProductSet]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::CreateProductSetRequest.new

# Call the create_product_set method.
result = client.create_product_set request

# The returned object is of type Google::Cloud::Vision::V1::ProductSet.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 325
def create_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::CreateProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.create_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :create_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
create_reference_image(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload create_reference_image(request, options = nil)

Pass arguments to `create_reference_image` via a request object, either of type
{::Google::Cloud::Vision::V1::CreateReferenceImageRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::CreateReferenceImageRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload create_reference_image(parent: nil, reference_image: nil, reference_image_id: nil)

Pass arguments to `create_reference_image` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. Resource name of the product in which to create the reference image.

  Format is
  `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
@param reference_image [::Google::Cloud::Vision::V1::ReferenceImage, ::Hash]
  Required. The reference image to create.
  If an image ID is specified, it is ignored.
@param reference_image_id [::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 `/`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::ReferenceImage] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::ReferenceImage]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::CreateReferenceImageRequest.new

# Call the create_reference_image method.
result = client.create_reference_image request

# The returned object is of type Google::Cloud::Vision::V1::ReferenceImage.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1297
def create_reference_image request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::CreateReferenceImageRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.create_reference_image.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_reference_image.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_reference_image.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :create_reference_image, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
delete_product(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload delete_product(request, options = nil)

Pass arguments to `delete_product` via a request object, either of type
{::Google::Cloud::Vision::V1::DeleteProductRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::DeleteProductRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload delete_product(name: nil)

Pass arguments to `delete_product` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. Resource name of product to delete.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::DeleteProductRequest.new

# Call the delete_product method.
result = client.delete_product request

# The returned object is of type Google::Protobuf::Empty.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1185
def delete_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::DeleteProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.delete_product.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_product.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :delete_product, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
delete_product_set(request, options = nil) { |response, operation| ... } click to toggle source

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

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

@overload delete_product_set(request, options = nil)

Pass arguments to `delete_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::DeleteProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::DeleteProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload delete_product_set(name: nil)

Pass arguments to `delete_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. Resource name of the ProductSet to delete.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::DeleteProductSetRequest.new

# Call the delete_product_set method.
result = client.delete_product_set request

# The returned object is of type Google::Protobuf::Empty.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 700
def delete_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::DeleteProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.delete_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :delete_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
delete_reference_image(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload delete_reference_image(request, options = nil)

Pass arguments to `delete_reference_image` via a request object, either of type
{::Google::Cloud::Vision::V1::DeleteReferenceImageRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::DeleteReferenceImageRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload delete_reference_image(name: nil)

Pass arguments to `delete_reference_image` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. The resource name of the reference image to delete.

  Format is:
  `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::DeleteReferenceImageRequest.new

# Call the delete_reference_image method.
result = client.delete_reference_image request

# The returned object is of type Google::Protobuf::Empty.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1389
def delete_reference_image request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::DeleteReferenceImageRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.delete_reference_image.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_reference_image.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_reference_image.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :delete_reference_image, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_product(request, options = nil) { |response, operation| ... } click to toggle source

Gets information associated with a Product.

Possible errors:

  • Returns NOT_FOUND if the Product does not exist.

@overload get_product(request, options = nil)

Pass arguments to `get_product` via a request object, either of type
{::Google::Cloud::Vision::V1::GetProductRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::GetProductRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_product(name: nil)

Pass arguments to `get_product` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. Resource name of the Product to get.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::Product] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::Product]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::GetProductRequest.new

# Call the get_product method.
result = client.get_product request

# The returned object is of type Google::Cloud::Vision::V1::Product.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 991
def get_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::GetProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_product.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_product.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :get_product, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_product_set(request, options = nil) { |response, operation| ... } click to toggle source

Gets information associated with a ProductSet.

Possible errors:

  • Returns NOT_FOUND if the ProductSet does not exist.

@overload get_product_set(request, options = nil)

Pass arguments to `get_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::GetProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::GetProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_product_set(name: nil)

Pass arguments to `get_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. Resource name of the ProductSet to get.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::ProductSet] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::ProductSet]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::GetProductSetRequest.new

# Call the get_product_set method.
result = client.get_product_set request

# The returned object is of type Google::Cloud::Vision::V1::ProductSet.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 516
def get_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::GetProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :get_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_reference_image(request, options = nil) { |response, operation| ... } click to toggle source

Gets information associated with a ReferenceImage.

Possible errors:

  • Returns NOT_FOUND if the specified image does not exist.

@overload get_reference_image(request, options = nil)

Pass arguments to `get_reference_image` via a request object, either of type
{::Google::Cloud::Vision::V1::GetReferenceImageRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::GetReferenceImageRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_reference_image(name: nil)

Pass arguments to `get_reference_image` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. The resource name of the ReferenceImage to get.

  Format is:
  `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::ReferenceImage] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::ReferenceImage]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::GetReferenceImageRequest.new

# Call the get_reference_image method.
result = client.get_reference_image request

# The returned object is of type Google::Cloud::Vision::V1::ReferenceImage.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1585
def get_reference_image request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::GetReferenceImageRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_reference_image.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_reference_image.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_reference_image.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :get_reference_image, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
import_product_sets(request, options = nil) { |response, operation| ... } click to toggle source

Asynchronous API that imports a list of reference images to specified product sets based on a list of image information.

The {::Google::Longrunning::Operation 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 {::Google::Cloud::Vision::V1::ImportProductSetsGcsSource#csv_file_uri ImportProductSetsGcsSource.csv_file_uri}.

@overload import_product_sets(request, options = nil)

Pass arguments to `import_product_sets` via a request object, either of type
{::Google::Cloud::Vision::V1::ImportProductSetsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::ImportProductSetsRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload import_product_sets(parent: nil, input_config: nil)

Pass arguments to `import_product_sets` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project in which the ProductSets should be imported.

  Format is `projects/PROJECT_ID/locations/LOC_ID`.
@param input_config [::Google::Cloud::Vision::V1::ImportProductSetsInputConfig, ::Hash]
  Required. The input content for the list of requests.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::ImportProductSetsRequest.new

# Call the import_product_sets method.
result = client.import_product_sets request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1981
def import_product_sets request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::ImportProductSetsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.import_product_sets.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.import_product_sets.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.import_product_sets.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :import_product_sets, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_product_sets(request, options = nil) { |response, operation| ... } click to toggle source

Lists ProductSets in an unspecified order.

Possible errors:

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

@overload list_product_sets(request, options = nil)

Pass arguments to `list_product_sets` via a request object, either of type
{::Google::Cloud::Vision::V1::ListProductSetsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::ListProductSetsRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_product_sets(parent: nil, page_size: nil, page_token: nil)

Pass arguments to `list_product_sets` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project from which ProductSets should be listed.

  Format is `projects/PROJECT_ID/locations/LOC_ID`.
@param page_size [::Integer]
  The maximum number of items to return. Default 10, maximum 100.
@param page_token [::String]
  The next_page_token returned from a previous List request, if any.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::ListProductSetsRequest.new

# Call the list_product_sets method.
result = client.list_product_sets request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Vision::V1::ProductSet.
  p response
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 425
def list_product_sets request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::ListProductSetsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_product_sets.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_product_sets.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_product_sets.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :list_product_sets, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @product_search_stub, :list_product_sets, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_products(request, options = nil) { |response, operation| ... } click to toggle source

Lists products in an unspecified order.

Possible errors:

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

@overload list_products(request, options = nil)

Pass arguments to `list_products` via a request object, either of type
{::Google::Cloud::Vision::V1::ListProductsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::ListProductsRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_products(parent: nil, page_size: nil, page_token: nil)

Pass arguments to `list_products` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project OR ProductSet from which Products should be listed.

  Format:
  `projects/PROJECT_ID/locations/LOC_ID`
@param page_size [::Integer]
  The maximum number of items to return. Default 10, maximum 100.
@param page_token [::String]
  The next_page_token returned from a previous List request, if any.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::ListProductsRequest.new

# Call the list_products method.
result = client.list_products request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Vision::V1::Product.
  p response
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 900
def list_products request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::ListProductsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_products.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_products.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_products.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :list_products, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @product_search_stub, :list_products, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_products_in_product_set(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload list_products_in_product_set(request, options = nil)

Pass arguments to `list_products_in_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::ListProductsInProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::ListProductsInProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_products_in_product_set(name: nil, page_size: nil, page_token: nil)

Pass arguments to `list_products_in_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. The ProductSet resource for which to retrieve Products.

  Format is:
  `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
@param page_size [::Integer]
  The maximum number of items to return. Default 10, maximum 100.
@param page_token [::String]
  The next_page_token returned from a previous List request, if any.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::ListProductsInProductSetRequest.new

# Call the list_products_in_product_set method.
result = client.list_products_in_product_set request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Vision::V1::Product.
  p response
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1876
def list_products_in_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::ListProductsInProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_products_in_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_products_in_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_products_in_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :list_products_in_product_set, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @product_search_stub, :list_products_in_product_set, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_reference_images(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload list_reference_images(request, options = nil)

Pass arguments to `list_reference_images` via a request object, either of type
{::Google::Cloud::Vision::V1::ListReferenceImagesRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::ListReferenceImagesRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_reference_images(parent: nil, page_size: nil, page_token: nil)

Pass arguments to `list_reference_images` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. Resource name of the product containing the reference images.

  Format is
  `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
@param page_size [::Integer]
  The maximum number of items to return. Default 10, maximum 100.
@param page_token [::String]
  A token identifying a page of results to be returned. This is the value
  of `nextPageToken` returned in a previous reference image list request.

  Defaults to the first page if not specified.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::ListReferenceImagesRequest.new

# Call the list_reference_images method.
result = client.list_reference_images request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Vision::V1::ReferenceImage.
  p response
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1494
def list_reference_images request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::ListReferenceImagesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_reference_images.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_reference_images.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_reference_images.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :list_reference_images, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @product_search_stub, :list_reference_images, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
purge_products(request, options = nil) { |response, operation| ... } click to toggle source

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 google.longrunning.Operation} API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)

@overload purge_products(request, options = nil)

Pass arguments to `purge_products` via a request object, either of type
{::Google::Cloud::Vision::V1::PurgeProductsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::PurgeProductsRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload purge_products(product_set_purge_config: nil, delete_orphan_products: nil, parent: nil, force: nil)

Pass arguments to `purge_products` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param product_set_purge_config [::Google::Cloud::Vision::V1::ProductSetPurgeConfig, ::Hash]
  Specify which ProductSet contains the Products to be deleted.
@param delete_orphan_products [::Boolean]
  If delete_orphan_products is true, all Products that are not in any
  ProductSet will be deleted.
@param parent [::String]
  Required. The project and location in which the Products should be deleted.

  Format is `projects/PROJECT_ID/locations/LOC_ID`.
@param force [::Boolean]
  The default value is false. Override this value to true to actually perform
  the purge.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::PurgeProductsRequest.new

# Call the purge_products method.
result = client.purge_products request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end
# File lib/google/cloud/vision/v1/product_search/client.rb, line 2105
def purge_products request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::PurgeProductsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.purge_products.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.purge_products.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.purge_products.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :purge_products, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
remove_product_from_product_set(request, options = nil) { |response, operation| ... } click to toggle source

Removes a Product from the specified ProductSet.

@overload remove_product_from_product_set(request, options = nil)

Pass arguments to `remove_product_from_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload remove_product_from_product_set(name: nil, product: nil)

Pass arguments to `remove_product_from_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param name [::String]
  Required. The resource name for the ProductSet to modify.

  Format is:
  `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
@param product [::String]
  Required. The resource name for the Product to be removed from this ProductSet.

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

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest.new

# Call the remove_product_from_product_set method.
result = client.remove_product_from_product_set request

# The returned object is of type Google::Protobuf::Empty.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1774
def remove_product_from_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.remove_product_from_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.remove_product_from_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.remove_product_from_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :remove_product_from_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
update_product(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload update_product(request, options = nil)

Pass arguments to `update_product` via a request object, either of type
{::Google::Cloud::Vision::V1::UpdateProductRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::UpdateProductRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload update_product(product: nil, update_mask: nil)

Pass arguments to `update_product` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param product [::Google::Cloud::Vision::V1::Product, ::Hash]
  Required. The Product resource which replaces the one on the server.
  product.name is immutable.
@param update_mask [::Google::Protobuf::FieldMask, ::Hash]
  The {::Google::Protobuf::FieldMask 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`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::Product] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::Product]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::UpdateProductRequest.new

# Call the update_product method.
result = client.update_product request

# The returned object is of type Google::Cloud::Vision::V1::Product.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 1095
def update_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::UpdateProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.update_product.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "product.name" => request.product.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_product.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.update_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :update_product, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
update_product_set(request, options = nil) { |response, operation| ... } click to toggle source

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.

@overload update_product_set(request, options = nil)

Pass arguments to `update_product_set` via a request object, either of type
{::Google::Cloud::Vision::V1::UpdateProductSetRequest} or an equivalent Hash.

@param request [::Google::Cloud::Vision::V1::UpdateProductSetRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload update_product_set(product_set: nil, update_mask: nil)

Pass arguments to `update_product_set` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param product_set [::Google::Cloud::Vision::V1::ProductSet, ::Hash]
  Required. The ProductSet resource which replaces the one on the server.
@param update_mask [::Google::Protobuf::FieldMask, ::Hash]
  The {::Google::Protobuf::FieldMask 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`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Vision::V1::ProductSet] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Vision::V1::ProductSet]

@raise [::Google::Cloud::Error] if the RPC is aborted.

@example Basic example

require "google/cloud/vision/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Vision::V1::ProductSearch::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Vision::V1::UpdateProductSetRequest.new

# Call the update_product_set method.
result = client.update_product_set request

# The returned object is of type Google::Cloud::Vision::V1::ProductSet.
p result
# File lib/google/cloud/vision/v1/product_search/client.rb, line 611
def update_product_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::UpdateProductSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.update_product_set.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Vision::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "product_set.name" => request.product_set.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_product_set.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.update_product_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @product_search_stub.call_rpc :update_product_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end