Class: Google::Cloud::Vision::V1::ProductSearch::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/vision/v1/product_search/client.rb

Overview

Client for the ProductSearch service.

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

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#location_path, #product_path, #product_set_path, #reference_image_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new ProductSearch client object.

Examples:


# 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

Yields:

  • (config)

    Configure the ProductSearch client.

Yield Parameters:



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# 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 == Configuration::DEFAULT_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.quota_project = @quota_project_id
    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

Instance Attribute Details

#operations_client::Google::Cloud::Vision::V1::ProductSearch::Operations (readonly)

Get the associated client for long-running operations.



264
265
266
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 264

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the ProductSearch Client class.

See Configuration for a description of the configuration fields.

Examples:


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

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# 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

Instance Method Details

#add_product_to_product_set(request, options = nil) ⇒ ::Google::Protobuf::Empty #add_product_to_product_set(name: nil, product: nil) ⇒ ::Google::Protobuf::Empty

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.

Examples:

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

Overloads:

  • #add_product_to_product_set(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to add_product_to_product_set via a request object, either of type AddProductToProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #add_product_to_product_set(name: nil, product: nil) ⇒ ::Google::Protobuf::Empty

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name for the ProductSet to modify.

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

    • product (::String) (defaults to: nil)

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

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1706

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
   = @config.rpcs.add_product_to_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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| ... } ⇒ Client::Configuration

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

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



196
197
198
199
# 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) ⇒ ::Google::Cloud::Vision::V1::Product #create_product(parent: nil, product: nil, product_id: nil) ⇒ ::Google::Cloud::Vision::V1::Product

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.

Examples:

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

Overloads:

  • #create_product(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::Product

    Pass arguments to create_product via a request object, either of type CreateProductRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_product(parent: nil, product: nil, product_id: nil) ⇒ ::Google::Cloud::Vision::V1::Product

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

      Format is projects/PROJECT_ID/locations/LOC_ID.

    • product (::Google::Cloud::Vision::V1::Product, ::Hash) (defaults to: nil)

      Required. The product to create.

    • product_id (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 809

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
   = @config.rpcs.create_product..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::ProductSet #create_product_set(parent: nil, product_set: nil, product_set_id: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

Creates and returns a new ProductSet resource.

Possible errors:

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

Examples:

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

Overloads:

  • #create_product_set(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

    Pass arguments to create_product_set via a request object, either of type CreateProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_product_set(parent: nil, product_set: nil, product_set_id: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

      Format is projects/PROJECT_ID/locations/LOC_ID.

    • product_set (::Google::Cloud::Vision::V1::ProductSet, ::Hash) (defaults to: nil)

      Required. The ProductSet to create.

    • product_set_id (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 326

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
   = @config.rpcs.create_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage #create_reference_image(parent: nil, reference_image: nil, reference_image_id: nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

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.

Examples:

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

Overloads:

  • #create_reference_image(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

    Pass arguments to create_reference_image via a request object, either of type CreateReferenceImageRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_reference_image(parent: nil, reference_image: nil, reference_image_id: nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

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

    • reference_image (::Google::Cloud::Vision::V1::ReferenceImage, ::Hash) (defaults to: nil)

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

    • reference_image_id (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1314

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
   = @config.rpcs.create_reference_image..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Protobuf::Empty #delete_product(name: nil) ⇒ ::Google::Protobuf::Empty

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.

Examples:

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

Overloads:

  • #delete_product(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_product via a request object, either of type DeleteProductRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_product(name: nil) ⇒ ::Google::Protobuf::Empty

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Resource name of product to delete.

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1200

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
   = @config.rpcs.delete_product..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Protobuf::Empty #delete_product_set(name: nil) ⇒ ::Google::Protobuf::Empty

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

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

Examples:

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

Overloads:

  • #delete_product_set(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_product_set via a request object, either of type DeleteProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_product_set(name: nil) ⇒ ::Google::Protobuf::Empty

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Resource name of the ProductSet to delete.

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 707

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
   = @config.rpcs.delete_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Protobuf::Empty #delete_reference_image(name: nil) ⇒ ::Google::Protobuf::Empty

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.

Examples:

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

Overloads:

  • #delete_reference_image(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_reference_image via a request object, either of type DeleteReferenceImageRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_reference_image(name: nil) ⇒ ::Google::Protobuf::Empty

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

    Parameters:

    • name (::String) (defaults to: nil)

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

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1408

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
   = @config.rpcs.delete_reference_image..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::Product #get_product(name: nil) ⇒ ::Google::Cloud::Vision::V1::Product

Gets information associated with a Product.

Possible errors:

  • Returns NOT_FOUND if the Product does not exist.

Examples:

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

Overloads:

  • #get_product(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::Product

    Pass arguments to get_product via a request object, either of type GetProductRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_product(name: nil) ⇒ ::Google::Cloud::Vision::V1::Product

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Resource name of the Product to get.

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1002

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
   = @config.rpcs.get_product..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::ProductSet #get_product_set(name: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

Gets information associated with a ProductSet.

Possible errors:

  • Returns NOT_FOUND if the ProductSet does not exist.

Examples:

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

Overloads:

  • #get_product_set(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

    Pass arguments to get_product_set via a request object, either of type GetProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_product_set(name: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Resource name of the ProductSet to get.

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 519

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
   = @config.rpcs.get_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage #get_reference_image(name: nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

Gets information associated with a ReferenceImage.

Possible errors:

  • Returns NOT_FOUND if the specified image does not exist.

Examples:

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

Overloads:

  • #get_reference_image(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

    Pass arguments to get_reference_image via a request object, either of type GetReferenceImageRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_reference_image(name: nil) ⇒ ::Google::Cloud::Vision::V1::ReferenceImage

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the ReferenceImage to get.

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1606

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
   = @config.rpcs.get_reference_image..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::Operation #import_product_sets(parent: nil, input_config: nil) ⇒ ::Gapic::Operation

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.

Examples:

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 it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #import_product_sets(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to import_product_sets via a request object, either of type ImportProductSetsRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #import_product_sets(parent: nil, input_config: nil) ⇒ ::Gapic::Operation

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

      Format is projects/PROJECT_ID/locations/LOC_ID.

    • input_config (::Google::Cloud::Vision::V1::ImportProductSetsInputConfig, ::Hash) (defaults to: nil)

      Required. The input content for the list of requests.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 2008

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
   = @config.rpcs.import_product_sets..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet> #list_product_sets(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet>

Lists ProductSets in an unspecified order.

Possible errors:

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

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Vision::V1::ProductSet.
  p item
end

Overloads:

  • #list_product_sets(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet>

    Pass arguments to list_product_sets via a request object, either of type ListProductSetsRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_product_sets(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ProductSet>

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

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The project from which ProductSets should be listed.

      Format is projects/PROJECT_ID/locations/LOC_ID.

    • page_size (::Integer) (defaults to: nil)

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

    • page_token (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 426

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
   = @config.rpcs.list_product_sets..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product> #list_products(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

Lists products in an unspecified order.

Possible errors:

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

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Vision::V1::Product.
  p item
end

Overloads:

  • #list_products(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

    Pass arguments to list_products via a request object, either of type ListProductsRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_products(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

      Format: projects/PROJECT_ID/locations/LOC_ID

    • page_size (::Integer) (defaults to: nil)

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

    • page_token (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 909

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
   = @config.rpcs.list_products..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product> #list_products_in_product_set(name: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

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.

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Vision::V1::Product.
  p item
end

Overloads:

  • #list_products_in_product_set(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

    Pass arguments to list_products_in_product_set via a request object, either of type ListProductsInProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_products_in_product_set(name: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::Product>

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The ProductSet resource for which to retrieve Products.

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

    • page_size (::Integer) (defaults to: nil)

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

    • page_token (::String) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1901

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
   = @config.rpcs.list_products_in_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage> #list_reference_images(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage>

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.

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Vision::V1::ReferenceImage.
  p item
end

Overloads:

  • #list_reference_images(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage>

    Pass arguments to list_reference_images via a request object, either of type ListReferenceImagesRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_reference_images(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Vision::V1::ReferenceImage>

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

    Parameters:

    • parent (::String) (defaults to: nil)

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

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

    • page_size (::Integer) (defaults to: nil)

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

    • page_token (::String) (defaults to: nil)

      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.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1513

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
   = @config.rpcs.list_reference_images..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Gapic::Operation #purge_products(product_set_purge_config: nil, delete_orphan_products: nil, parent: nil, force: nil) ⇒ ::Gapic::Operation

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)

Examples:

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 it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #purge_products(request, options = nil) ⇒ ::Gapic::Operation

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

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #purge_products(product_set_purge_config: nil, delete_orphan_products: nil, parent: nil, force: nil) ⇒ ::Gapic::Operation

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

    Parameters:

    • product_set_purge_config (::Google::Cloud::Vision::V1::ProductSetPurgeConfig, ::Hash) (defaults to: nil)

      Specify which ProductSet contains the Products to be deleted.

    • delete_orphan_products (::Boolean) (defaults to: nil)

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

    • parent (::String) (defaults to: nil)

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

      Format is projects/PROJECT_ID/locations/LOC_ID.

    • force (::Boolean) (defaults to: nil)

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 2134

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
   = @config.rpcs.purge_products..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Protobuf::Empty #remove_product_from_product_set(name: nil, product: nil) ⇒ ::Google::Protobuf::Empty

Removes a Product from the specified ProductSet.

Examples:

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

Overloads:

  • #remove_product_from_product_set(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to remove_product_from_product_set via a request object, either of type RemoveProductFromProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #remove_product_from_product_set(name: nil, product: nil) ⇒ ::Google::Protobuf::Empty

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

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name for the ProductSet to modify.

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

    • product (::String) (defaults to: nil)

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

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

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1799

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
   = @config.rpcs.remove_product_from_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::Product #update_product(product: nil, update_mask: nil) ⇒ ::Google::Cloud::Vision::V1::Product

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.

Examples:

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

Overloads:

  • #update_product(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::Product

    Pass arguments to update_product via a request object, either of type UpdateProductRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_product(product: nil, update_mask: nil) ⇒ ::Google::Cloud::Vision::V1::Product

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

    Parameters:

    • product (::Google::Cloud::Vision::V1::Product, ::Hash) (defaults to: nil)

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

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The FieldMask that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask paths include product_labels, display_name, and description.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 1108

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
   = @config.rpcs.update_product..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product&.name
    header_params["product.name"] = request.product.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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) ⇒ ::Google::Cloud::Vision::V1::ProductSet #update_product_set(product_set: nil, update_mask: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

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.

Examples:

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

Overloads:

  • #update_product_set(request, options = nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

    Pass arguments to update_product_set via a request object, either of type UpdateProductSetRequest or an equivalent Hash.

    Parameters:

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

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_product_set(product_set: nil, update_mask: nil) ⇒ ::Google::Cloud::Vision::V1::ProductSet

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

    Parameters:

    • product_set (::Google::Cloud::Vision::V1::ProductSet, ::Hash) (defaults to: nil)

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

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The FieldMask that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask path is display_name.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/google/cloud/vision/v1/product_search/client.rb', line 616

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
   = @config.rpcs.update_product_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product_set&.name
    header_params["product_set.name"] = request.product_set.name
  end

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

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

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         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