google-cloud-vision 0.32.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +4 -2
  3. data/AUTHENTICATION.md +151 -0
  4. data/LICENSE.md +201 -0
  5. data/MIGRATING.md +343 -0
  6. data/README.md +97 -52
  7. data/lib/google/cloud/vision/{v1/doc/google/protobuf/empty.rb → version.rb} +10 -13
  8. data/lib/google/cloud/vision.rb +132 -207
  9. data/lib/{google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb → google-cloud-vision.rb} +5 -15
  10. metadata +108 -83
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/vision/v1/credentials.rb +0 -42
  13. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +0 -66
  14. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +0 -763
  15. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +0 -88
  16. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +0 -539
  17. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +0 -254
  18. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +0 -102
  19. data/lib/google/cloud/vision/v1/doc/google/longrunning/operations.rb +0 -93
  20. data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +0 -130
  21. data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +0 -230
  22. data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +0 -109
  23. data/lib/google/cloud/vision/v1/doc/google/protobuf/wrappers.rb +0 -90
  24. data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +0 -84
  25. data/lib/google/cloud/vision/v1/doc/google/type/color.rb +0 -156
  26. data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +0 -65
  27. data/lib/google/cloud/vision/v1/geometry_pb.rb +0 -39
  28. data/lib/google/cloud/vision/v1/helpers.rb +0 -1154
  29. data/lib/google/cloud/vision/v1/image_annotator_client.rb +0 -302
  30. data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -36
  31. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +0 -305
  32. data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +0 -56
  33. data/lib/google/cloud/vision/v1/product_search_client.rb +0 -1337
  34. data/lib/google/cloud/vision/v1/product_search_client_config.json +0 -116
  35. data/lib/google/cloud/vision/v1/product_search_pb.rb +0 -45
  36. data/lib/google/cloud/vision/v1/product_search_service_pb.rb +0 -191
  37. data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +0 -224
  38. data/lib/google/cloud/vision/v1/text_annotation_pb.rb +0 -94
  39. data/lib/google/cloud/vision/v1/web_detection_pb.rb +0 -51
  40. data/lib/google/cloud/vision/v1.rb +0 -233
  41. data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
  42. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
  43. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
  44. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -154
  45. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -533
  46. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -254
  47. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
  48. data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -93
  49. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -130
  50. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -230
  51. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -109
  52. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -90
  53. data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -84
  54. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -156
  55. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -65
  56. data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
  57. data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
  58. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -302
  59. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +0 -36
  60. data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +0 -304
  61. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -55
  62. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1351
  63. data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
  64. data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -64
  65. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -191
  66. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -222
  67. data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
  68. data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
  69. data/lib/google/cloud/vision/v1p3beta1.rb +0 -233
@@ -1,1337 +0,0 @@
1
- # Copyright 2018 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/product_search_service.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/cloud/vision/v1/product_search_service_pb"
31
- require "google/cloud/vision/v1/credentials"
32
-
33
- module Google
34
- module Cloud
35
- module Vision
36
- module V1
37
- # Manages Products and ProductSets of reference images for use in product
38
- # search. It uses the following resource model:
39
- #
40
- # * The API has a collection of {Google::Cloud::Vision::V1::ProductSet ProductSet} resources, named
41
- # `projects/*/locations/*/productSets/*`, which acts as a way to put different
42
- # products into groups to limit identification.
43
- #
44
- # In parallel,
45
- #
46
- # * The API has a collection of {Google::Cloud::Vision::V1::Product Product} resources, named
47
- # `projects/*/locations/*/products/*`
48
- #
49
- # * Each {Google::Cloud::Vision::V1::Product Product} has a collection of {Google::Cloud::Vision::V1::ReferenceImage ReferenceImage} resources, named
50
- # `projects/*/locations/*/products/*/referenceImages/*`
51
- #
52
- # @!attribute [r] product_search_stub
53
- # @return [Google::Cloud::Vision::V1::ProductSearch::Stub]
54
- class ProductSearchClient
55
- # @private
56
- attr_reader :product_search_stub
57
-
58
- # The default address of the service.
59
- SERVICE_ADDRESS = "vision.googleapis.com".freeze
60
-
61
- # The default port of the service.
62
- DEFAULT_SERVICE_PORT = 443
63
-
64
- # The default set of gRPC interceptors.
65
- GRPC_INTERCEPTORS = []
66
-
67
- DEFAULT_TIMEOUT = 30
68
-
69
- PAGE_DESCRIPTORS = {
70
- "list_products" => Google::Gax::PageDescriptor.new(
71
- "page_token",
72
- "next_page_token",
73
- "products"),
74
- "list_reference_images" => Google::Gax::PageDescriptor.new(
75
- "page_token",
76
- "next_page_token",
77
- "reference_images"),
78
- "list_product_sets" => Google::Gax::PageDescriptor.new(
79
- "page_token",
80
- "next_page_token",
81
- "product_sets"),
82
- "list_products_in_product_set" => Google::Gax::PageDescriptor.new(
83
- "page_token",
84
- "next_page_token",
85
- "products")
86
- }.freeze
87
-
88
- private_constant :PAGE_DESCRIPTORS
89
-
90
- # The scopes needed to make gRPC calls to all of the methods defined in
91
- # this service.
92
- ALL_SCOPES = [
93
- "https://www.googleapis.com/auth/cloud-platform",
94
- "https://www.googleapis.com/auth/cloud-vision"
95
- ].freeze
96
-
97
- # @private
98
- class OperationsClient < Google::Longrunning::OperationsClient
99
- self::SERVICE_ADDRESS = ProductSearchClient::SERVICE_ADDRESS
100
- self::GRPC_INTERCEPTORS = ProductSearchClient::GRPC_INTERCEPTORS
101
- end
102
-
103
- LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
104
- "projects/{project}/locations/{location}"
105
- )
106
-
107
- private_constant :LOCATION_PATH_TEMPLATE
108
-
109
- PRODUCT_SET_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
110
- "projects/{project}/locations/{location}/productSets/{product_set}"
111
- )
112
-
113
- private_constant :PRODUCT_SET_PATH_TEMPLATE
114
-
115
- PRODUCT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
116
- "projects/{project}/locations/{location}/products/{product}"
117
- )
118
-
119
- private_constant :PRODUCT_PATH_TEMPLATE
120
-
121
- REFERENCE_IMAGE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
122
- "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}"
123
- )
124
-
125
- private_constant :REFERENCE_IMAGE_PATH_TEMPLATE
126
-
127
- # Returns a fully-qualified location resource name string.
128
- # @param project [String]
129
- # @param location [String]
130
- # @return [String]
131
- def self.location_path project, location
132
- LOCATION_PATH_TEMPLATE.render(
133
- :"project" => project,
134
- :"location" => location
135
- )
136
- end
137
-
138
- # Returns a fully-qualified product_set resource name string.
139
- # @param project [String]
140
- # @param location [String]
141
- # @param product_set [String]
142
- # @return [String]
143
- def self.product_set_path project, location, product_set
144
- PRODUCT_SET_PATH_TEMPLATE.render(
145
- :"project" => project,
146
- :"location" => location,
147
- :"product_set" => product_set
148
- )
149
- end
150
-
151
- # Returns a fully-qualified product resource name string.
152
- # @param project [String]
153
- # @param location [String]
154
- # @param product [String]
155
- # @return [String]
156
- def self.product_path project, location, product
157
- PRODUCT_PATH_TEMPLATE.render(
158
- :"project" => project,
159
- :"location" => location,
160
- :"product" => product
161
- )
162
- end
163
-
164
- # Returns a fully-qualified reference_image resource name string.
165
- # @param project [String]
166
- # @param location [String]
167
- # @param product [String]
168
- # @param reference_image [String]
169
- # @return [String]
170
- def self.reference_image_path project, location, product, reference_image
171
- REFERENCE_IMAGE_PATH_TEMPLATE.render(
172
- :"project" => project,
173
- :"location" => location,
174
- :"product" => product,
175
- :"reference_image" => reference_image
176
- )
177
- end
178
-
179
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
180
- # Provides the means for authenticating requests made by the client. This parameter can
181
- # be many types.
182
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
183
- # authenticating requests made by this client.
184
- # A `String` will be treated as the path to the keyfile to be used for the construction of
185
- # credentials for this client.
186
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
187
- # credentials for this client.
188
- # A `GRPC::Core::Channel` will be used to make calls through.
189
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
190
- # should already be composed with a `GRPC::Core::CallCredentials` object.
191
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
192
- # metadata for requests, generally, to give OAuth credentials.
193
- # @param scopes [Array<String>]
194
- # The OAuth scopes for this service. This parameter is ignored if
195
- # an updater_proc is supplied.
196
- # @param client_config [Hash]
197
- # A Hash for call options for each method. See
198
- # Google::Gax#construct_settings for the structure of
199
- # this data. Falls back to the default config if not specified
200
- # or the specified config is missing data points.
201
- # @param timeout [Numeric]
202
- # The default timeout, in seconds, for calls made through this client.
203
- # @param metadata [Hash]
204
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
205
- # @param exception_transformer [Proc]
206
- # An optional proc that intercepts any exceptions raised during an API call to inject
207
- # custom error handling.
208
- def initialize \
209
- credentials: nil,
210
- scopes: ALL_SCOPES,
211
- client_config: {},
212
- timeout: DEFAULT_TIMEOUT,
213
- metadata: nil,
214
- exception_transformer: nil,
215
- lib_name: nil,
216
- lib_version: ""
217
- # These require statements are intentionally placed here to initialize
218
- # the gRPC module only when it's required.
219
- # See https://github.com/googleapis/toolkit/issues/446
220
- require "google/gax/grpc"
221
- require "google/cloud/vision/v1/product_search_service_services_pb"
222
-
223
- credentials ||= Google::Cloud::Vision::V1::Credentials.default
224
-
225
- @operations_client = OperationsClient.new(
226
- credentials: credentials,
227
- scopes: scopes,
228
- client_config: client_config,
229
- timeout: timeout,
230
- lib_name: lib_name,
231
- lib_version: lib_version,
232
- )
233
-
234
- if credentials.is_a?(String) || credentials.is_a?(Hash)
235
- updater_proc = Google::Cloud::Vision::V1::Credentials.new(credentials).updater_proc
236
- end
237
- if credentials.is_a?(GRPC::Core::Channel)
238
- channel = credentials
239
- end
240
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
241
- chan_creds = credentials
242
- end
243
- if credentials.is_a?(Proc)
244
- updater_proc = credentials
245
- end
246
- if credentials.is_a?(Google::Auth::Credentials)
247
- updater_proc = credentials.updater_proc
248
- end
249
-
250
- package_version = Gem.loaded_specs['google-cloud-vision'].version.version
251
-
252
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
253
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
254
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
255
- google_api_client << " grpc/#{GRPC::VERSION}"
256
- google_api_client.freeze
257
-
258
- headers = { :"x-goog-api-client" => google_api_client }
259
- headers.merge!(metadata) unless metadata.nil?
260
- client_config_file = Pathname.new(__dir__).join(
261
- "product_search_client_config.json"
262
- )
263
- defaults = client_config_file.open do |f|
264
- Google::Gax.construct_settings(
265
- "google.cloud.vision.v1.ProductSearch",
266
- JSON.parse(f.read),
267
- client_config,
268
- Google::Gax::Grpc::STATUS_CODE_NAMES,
269
- timeout,
270
- page_descriptors: PAGE_DESCRIPTORS,
271
- errors: Google::Gax::Grpc::API_ERRORS,
272
- metadata: headers
273
- )
274
- end
275
-
276
- # Allow overriding the service path/port in subclasses.
277
- service_path = self.class::SERVICE_ADDRESS
278
- port = self.class::DEFAULT_SERVICE_PORT
279
- interceptors = self.class::GRPC_INTERCEPTORS
280
- @product_search_stub = Google::Gax::Grpc.create_stub(
281
- service_path,
282
- port,
283
- chan_creds: chan_creds,
284
- channel: channel,
285
- updater_proc: updater_proc,
286
- scopes: scopes,
287
- interceptors: interceptors,
288
- &Google::Cloud::Vision::V1::ProductSearch::Stub.method(:new)
289
- )
290
-
291
- @create_product = Google::Gax.create_api_call(
292
- @product_search_stub.method(:create_product),
293
- defaults["create_product"],
294
- exception_transformer: exception_transformer
295
- )
296
- @list_products = Google::Gax.create_api_call(
297
- @product_search_stub.method(:list_products),
298
- defaults["list_products"],
299
- exception_transformer: exception_transformer
300
- )
301
- @get_product = Google::Gax.create_api_call(
302
- @product_search_stub.method(:get_product),
303
- defaults["get_product"],
304
- exception_transformer: exception_transformer
305
- )
306
- @update_product = Google::Gax.create_api_call(
307
- @product_search_stub.method(:update_product),
308
- defaults["update_product"],
309
- exception_transformer: exception_transformer
310
- )
311
- @delete_product = Google::Gax.create_api_call(
312
- @product_search_stub.method(:delete_product),
313
- defaults["delete_product"],
314
- exception_transformer: exception_transformer
315
- )
316
- @list_reference_images = Google::Gax.create_api_call(
317
- @product_search_stub.method(:list_reference_images),
318
- defaults["list_reference_images"],
319
- exception_transformer: exception_transformer
320
- )
321
- @get_reference_image = Google::Gax.create_api_call(
322
- @product_search_stub.method(:get_reference_image),
323
- defaults["get_reference_image"],
324
- exception_transformer: exception_transformer
325
- )
326
- @delete_reference_image = Google::Gax.create_api_call(
327
- @product_search_stub.method(:delete_reference_image),
328
- defaults["delete_reference_image"],
329
- exception_transformer: exception_transformer
330
- )
331
- @create_reference_image = Google::Gax.create_api_call(
332
- @product_search_stub.method(:create_reference_image),
333
- defaults["create_reference_image"],
334
- exception_transformer: exception_transformer
335
- )
336
- @create_product_set = Google::Gax.create_api_call(
337
- @product_search_stub.method(:create_product_set),
338
- defaults["create_product_set"],
339
- exception_transformer: exception_transformer
340
- )
341
- @list_product_sets = Google::Gax.create_api_call(
342
- @product_search_stub.method(:list_product_sets),
343
- defaults["list_product_sets"],
344
- exception_transformer: exception_transformer
345
- )
346
- @get_product_set = Google::Gax.create_api_call(
347
- @product_search_stub.method(:get_product_set),
348
- defaults["get_product_set"],
349
- exception_transformer: exception_transformer
350
- )
351
- @update_product_set = Google::Gax.create_api_call(
352
- @product_search_stub.method(:update_product_set),
353
- defaults["update_product_set"],
354
- exception_transformer: exception_transformer
355
- )
356
- @delete_product_set = Google::Gax.create_api_call(
357
- @product_search_stub.method(:delete_product_set),
358
- defaults["delete_product_set"],
359
- exception_transformer: exception_transformer
360
- )
361
- @add_product_to_product_set = Google::Gax.create_api_call(
362
- @product_search_stub.method(:add_product_to_product_set),
363
- defaults["add_product_to_product_set"],
364
- exception_transformer: exception_transformer
365
- )
366
- @remove_product_from_product_set = Google::Gax.create_api_call(
367
- @product_search_stub.method(:remove_product_from_product_set),
368
- defaults["remove_product_from_product_set"],
369
- exception_transformer: exception_transformer
370
- )
371
- @list_products_in_product_set = Google::Gax.create_api_call(
372
- @product_search_stub.method(:list_products_in_product_set),
373
- defaults["list_products_in_product_set"],
374
- exception_transformer: exception_transformer
375
- )
376
- @import_product_sets = Google::Gax.create_api_call(
377
- @product_search_stub.method(:import_product_sets),
378
- defaults["import_product_sets"],
379
- exception_transformer: exception_transformer
380
- )
381
- end
382
-
383
- # Service calls
384
-
385
- # Creates and returns a new product resource.
386
- #
387
- # Possible errors:
388
- #
389
- # * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096
390
- # characters.
391
- # * Returns INVALID_ARGUMENT if description is longer than 4096 characters.
392
- # * Returns INVALID_ARGUMENT if product_category is missing or invalid.
393
- #
394
- # @param parent [String]
395
- # The project in which the Product should be created.
396
- #
397
- # Format is
398
- # `projects/PROJECT_ID/locations/LOC_ID`.
399
- # @param product [Google::Cloud::Vision::V1::Product | Hash]
400
- # The product to create.
401
- # A hash of the same form as `Google::Cloud::Vision::V1::Product`
402
- # can also be provided.
403
- # @param product_id [String]
404
- # A user-supplied resource id for this Product. If set, the server will
405
- # attempt to use this value as the resource id. If it is already in use, an
406
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
407
- # long. It cannot contain the character `/`.
408
- # @param options [Google::Gax::CallOptions]
409
- # Overrides the default settings for this call, e.g, timeout,
410
- # retries, etc.
411
- # @yield [result, operation] Access the result along with the RPC operation
412
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
413
- # @yieldparam operation [GRPC::ActiveCall::Operation]
414
- # @return [Google::Cloud::Vision::V1::Product]
415
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
416
- # @example
417
- # require "google/cloud/vision"
418
- #
419
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
420
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
421
- #
422
- # # TODO: Initialize `product`:
423
- # product = {}
424
- # response = product_search_client.create_product(formatted_parent, product)
425
-
426
- def create_product \
427
- parent,
428
- product,
429
- product_id: nil,
430
- options: nil,
431
- &block
432
- req = {
433
- parent: parent,
434
- product: product,
435
- product_id: product_id
436
- }.delete_if { |_, v| v.nil? }
437
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateProductRequest)
438
- @create_product.call(req, options, &block)
439
- end
440
-
441
- # Lists products in an unspecified order.
442
- #
443
- # Possible errors:
444
- #
445
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
446
- #
447
- # @param parent [String]
448
- # The project OR ProductSet from which Products should be listed.
449
- #
450
- # Format:
451
- # `projects/PROJECT_ID/locations/LOC_ID`
452
- # @param page_size [Integer]
453
- # The maximum number of resources contained in the underlying API
454
- # response. If page streaming is performed per-resource, this
455
- # parameter does not affect the return value. If page streaming is
456
- # performed per-page, this determines the maximum number of
457
- # resources in a page.
458
- # @param options [Google::Gax::CallOptions]
459
- # Overrides the default settings for this call, e.g, timeout,
460
- # retries, etc.
461
- # @yield [result, operation] Access the result along with the RPC operation
462
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
463
- # @yieldparam operation [GRPC::ActiveCall::Operation]
464
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
465
- # An enumerable of Google::Cloud::Vision::V1::Product instances.
466
- # See Google::Gax::PagedEnumerable documentation for other
467
- # operations such as per-page iteration or access to the response
468
- # object.
469
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
470
- # @example
471
- # require "google/cloud/vision"
472
- #
473
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
474
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
475
- #
476
- # # Iterate over all results.
477
- # product_search_client.list_products(formatted_parent).each do |element|
478
- # # Process element.
479
- # end
480
- #
481
- # # Or iterate over results one page at a time.
482
- # product_search_client.list_products(formatted_parent).each_page do |page|
483
- # # Process each page at a time.
484
- # page.each do |element|
485
- # # Process element.
486
- # end
487
- # end
488
-
489
- def list_products \
490
- parent,
491
- page_size: nil,
492
- options: nil,
493
- &block
494
- req = {
495
- parent: parent,
496
- page_size: page_size
497
- }.delete_if { |_, v| v.nil? }
498
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductsRequest)
499
- @list_products.call(req, options, &block)
500
- end
501
-
502
- # Gets information associated with a Product.
503
- #
504
- # Possible errors:
505
- #
506
- # * Returns NOT_FOUND if the Product does not exist.
507
- #
508
- # @param name [String]
509
- # Resource name of the Product to get.
510
- #
511
- # Format is:
512
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
513
- # @param options [Google::Gax::CallOptions]
514
- # Overrides the default settings for this call, e.g, timeout,
515
- # retries, etc.
516
- # @yield [result, operation] Access the result along with the RPC operation
517
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
518
- # @yieldparam operation [GRPC::ActiveCall::Operation]
519
- # @return [Google::Cloud::Vision::V1::Product]
520
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
521
- # @example
522
- # require "google/cloud/vision"
523
- #
524
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
525
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
526
- # response = product_search_client.get_product(formatted_name)
527
-
528
- def get_product \
529
- name,
530
- options: nil,
531
- &block
532
- req = {
533
- name: name
534
- }.delete_if { |_, v| v.nil? }
535
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetProductRequest)
536
- @get_product.call(req, options, &block)
537
- end
538
-
539
- # Makes changes to a Product resource.
540
- # Only the `display_name`, `description`, and `labels` fields can be updated
541
- # right now.
542
- #
543
- # If labels are updated, the change will not be reflected in queries until
544
- # the next index time.
545
- #
546
- # Possible errors:
547
- #
548
- # * Returns NOT_FOUND if the Product does not exist.
549
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but is
550
- # missing from the request or longer than 4096 characters.
551
- # * Returns INVALID_ARGUMENT if description is present in update_mask but is
552
- # longer than 4096 characters.
553
- # * Returns INVALID_ARGUMENT if product_category is present in update_mask.
554
- #
555
- # @param product [Google::Cloud::Vision::V1::Product | Hash]
556
- # The Product resource which replaces the one on the server.
557
- # product.name is immutable.
558
- # A hash of the same form as `Google::Cloud::Vision::V1::Product`
559
- # can also be provided.
560
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
561
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields
562
- # to update.
563
- # If update_mask isn't specified, all mutable fields are to be updated.
564
- # Valid mask paths include `product_labels`, `display_name`, and
565
- # `description`.
566
- # A hash of the same form as `Google::Protobuf::FieldMask`
567
- # can also be provided.
568
- # @param options [Google::Gax::CallOptions]
569
- # Overrides the default settings for this call, e.g, timeout,
570
- # retries, etc.
571
- # @yield [result, operation] Access the result along with the RPC operation
572
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
573
- # @yieldparam operation [GRPC::ActiveCall::Operation]
574
- # @return [Google::Cloud::Vision::V1::Product]
575
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
576
- # @example
577
- # require "google/cloud/vision"
578
- #
579
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
580
- #
581
- # # TODO: Initialize `product`:
582
- # product = {}
583
- # response = product_search_client.update_product(product)
584
-
585
- def update_product \
586
- product,
587
- update_mask: nil,
588
- options: nil,
589
- &block
590
- req = {
591
- product: product,
592
- update_mask: update_mask
593
- }.delete_if { |_, v| v.nil? }
594
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::UpdateProductRequest)
595
- @update_product.call(req, options, &block)
596
- end
597
-
598
- # Permanently deletes a product and its reference images.
599
- #
600
- # Metadata of the product and all its images will be deleted right away, but
601
- # search queries against ProductSets containing the product may still work
602
- # until all related caches are refreshed.
603
- #
604
- # Possible errors:
605
- #
606
- # * Returns NOT_FOUND if the product does not exist.
607
- #
608
- # @param name [String]
609
- # Resource name of product to delete.
610
- #
611
- # Format is:
612
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
613
- # @param options [Google::Gax::CallOptions]
614
- # Overrides the default settings for this call, e.g, timeout,
615
- # retries, etc.
616
- # @yield [result, operation] Access the result along with the RPC operation
617
- # @yieldparam result []
618
- # @yieldparam operation [GRPC::ActiveCall::Operation]
619
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
620
- # @example
621
- # require "google/cloud/vision"
622
- #
623
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
624
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
625
- # product_search_client.delete_product(formatted_name)
626
-
627
- def delete_product \
628
- name,
629
- options: nil,
630
- &block
631
- req = {
632
- name: name
633
- }.delete_if { |_, v| v.nil? }
634
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteProductRequest)
635
- @delete_product.call(req, options, &block)
636
- nil
637
- end
638
-
639
- # Lists reference images.
640
- #
641
- # Possible errors:
642
- #
643
- # * Returns NOT_FOUND if the parent product does not exist.
644
- # * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less
645
- # than 1.
646
- #
647
- # @param parent [String]
648
- # Resource name of the product containing the reference images.
649
- #
650
- # Format is
651
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
652
- # @param page_size [Integer]
653
- # The maximum number of resources contained in the underlying API
654
- # response. If page streaming is performed per-resource, this
655
- # parameter does not affect the return value. If page streaming is
656
- # performed per-page, this determines the maximum number of
657
- # resources in a page.
658
- # @param options [Google::Gax::CallOptions]
659
- # Overrides the default settings for this call, e.g, timeout,
660
- # retries, etc.
661
- # @yield [result, operation] Access the result along with the RPC operation
662
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ReferenceImage>]
663
- # @yieldparam operation [GRPC::ActiveCall::Operation]
664
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ReferenceImage>]
665
- # An enumerable of Google::Cloud::Vision::V1::ReferenceImage instances.
666
- # See Google::Gax::PagedEnumerable documentation for other
667
- # operations such as per-page iteration or access to the response
668
- # object.
669
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
670
- # @example
671
- # require "google/cloud/vision"
672
- #
673
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
674
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
675
- #
676
- # # Iterate over all results.
677
- # product_search_client.list_reference_images(formatted_parent).each do |element|
678
- # # Process element.
679
- # end
680
- #
681
- # # Or iterate over results one page at a time.
682
- # product_search_client.list_reference_images(formatted_parent).each_page do |page|
683
- # # Process each page at a time.
684
- # page.each do |element|
685
- # # Process element.
686
- # end
687
- # end
688
-
689
- def list_reference_images \
690
- parent,
691
- page_size: nil,
692
- options: nil,
693
- &block
694
- req = {
695
- parent: parent,
696
- page_size: page_size
697
- }.delete_if { |_, v| v.nil? }
698
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListReferenceImagesRequest)
699
- @list_reference_images.call(req, options, &block)
700
- end
701
-
702
- # Gets information associated with a ReferenceImage.
703
- #
704
- # Possible errors:
705
- #
706
- # * Returns NOT_FOUND if the specified image does not exist.
707
- #
708
- # @param name [String]
709
- # The resource name of the ReferenceImage to get.
710
- #
711
- # Format is:
712
- #
713
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
714
- # @param options [Google::Gax::CallOptions]
715
- # Overrides the default settings for this call, e.g, timeout,
716
- # retries, etc.
717
- # @yield [result, operation] Access the result along with the RPC operation
718
- # @yieldparam result [Google::Cloud::Vision::V1::ReferenceImage]
719
- # @yieldparam operation [GRPC::ActiveCall::Operation]
720
- # @return [Google::Cloud::Vision::V1::ReferenceImage]
721
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
722
- # @example
723
- # require "google/cloud/vision"
724
- #
725
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
726
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
727
- # response = product_search_client.get_reference_image(formatted_name)
728
-
729
- def get_reference_image \
730
- name,
731
- options: nil,
732
- &block
733
- req = {
734
- name: name
735
- }.delete_if { |_, v| v.nil? }
736
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetReferenceImageRequest)
737
- @get_reference_image.call(req, options, &block)
738
- end
739
-
740
- # Permanently deletes a reference image.
741
- #
742
- # The image metadata will be deleted right away, but search queries
743
- # against ProductSets containing the image may still work until all related
744
- # caches are refreshed.
745
- #
746
- # The actual image files are not deleted from Google Cloud Storage.
747
- #
748
- # Possible errors:
749
- #
750
- # * Returns NOT_FOUND if the reference image does not exist.
751
- #
752
- # @param name [String]
753
- # The resource name of the reference image to delete.
754
- #
755
- # Format is:
756
- #
757
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
758
- # @param options [Google::Gax::CallOptions]
759
- # Overrides the default settings for this call, e.g, timeout,
760
- # retries, etc.
761
- # @yield [result, operation] Access the result along with the RPC operation
762
- # @yieldparam result []
763
- # @yieldparam operation [GRPC::ActiveCall::Operation]
764
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
765
- # @example
766
- # require "google/cloud/vision"
767
- #
768
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
769
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
770
- # product_search_client.delete_reference_image(formatted_name)
771
-
772
- def delete_reference_image \
773
- name,
774
- options: nil,
775
- &block
776
- req = {
777
- name: name
778
- }.delete_if { |_, v| v.nil? }
779
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteReferenceImageRequest)
780
- @delete_reference_image.call(req, options, &block)
781
- nil
782
- end
783
-
784
- # Creates and returns a new ReferenceImage resource.
785
- #
786
- # The `bounding_poly` field is optional. If `bounding_poly` is not specified,
787
- # the system will try to detect regions of interest in the image that are
788
- # compatible with the product_category on the parent product. If it is
789
- # specified, detection is ALWAYS skipped. The system converts polygons into
790
- # non-rotated rectangles.
791
- #
792
- # Note that the pipeline will resize the image if the image resolution is too
793
- # large to process (above 50MP).
794
- #
795
- # Possible errors:
796
- #
797
- # * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096
798
- # characters.
799
- # * Returns INVALID_ARGUMENT if the product does not exist.
800
- # * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing
801
- # compatible with the parent product's product_category is detected.
802
- # * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
803
- #
804
- # @param parent [String]
805
- # Resource name of the product in which to create the reference image.
806
- #
807
- # Format is
808
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
809
- # @param reference_image [Google::Cloud::Vision::V1::ReferenceImage | Hash]
810
- # The reference image to create.
811
- # If an image ID is specified, it is ignored.
812
- # A hash of the same form as `Google::Cloud::Vision::V1::ReferenceImage`
813
- # can also be provided.
814
- # @param reference_image_id [String]
815
- # A user-supplied resource id for the ReferenceImage to be added. If set,
816
- # the server will attempt to use this value as the resource id. If it is
817
- # already in use, an error is returned with code ALREADY_EXISTS. Must be at
818
- # most 128 characters long. It cannot contain the character `/`.
819
- # @param options [Google::Gax::CallOptions]
820
- # Overrides the default settings for this call, e.g, timeout,
821
- # retries, etc.
822
- # @yield [result, operation] Access the result along with the RPC operation
823
- # @yieldparam result [Google::Cloud::Vision::V1::ReferenceImage]
824
- # @yieldparam operation [GRPC::ActiveCall::Operation]
825
- # @return [Google::Cloud::Vision::V1::ReferenceImage]
826
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
827
- # @example
828
- # require "google/cloud/vision"
829
- #
830
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
831
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
832
- #
833
- # # TODO: Initialize `reference_image`:
834
- # reference_image = {}
835
- # response = product_search_client.create_reference_image(formatted_parent, reference_image)
836
-
837
- def create_reference_image \
838
- parent,
839
- reference_image,
840
- reference_image_id: nil,
841
- options: nil,
842
- &block
843
- req = {
844
- parent: parent,
845
- reference_image: reference_image,
846
- reference_image_id: reference_image_id
847
- }.delete_if { |_, v| v.nil? }
848
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateReferenceImageRequest)
849
- @create_reference_image.call(req, options, &block)
850
- end
851
-
852
- # Creates and returns a new ProductSet resource.
853
- #
854
- # Possible errors:
855
- #
856
- # * Returns INVALID_ARGUMENT if display_name is missing, or is longer than
857
- # 4096 characters.
858
- #
859
- # @param parent [String]
860
- # The project in which the ProductSet should be created.
861
- #
862
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
863
- # @param product_set [Google::Cloud::Vision::V1::ProductSet | Hash]
864
- # The ProductSet to create.
865
- # A hash of the same form as `Google::Cloud::Vision::V1::ProductSet`
866
- # can also be provided.
867
- # @param product_set_id [String]
868
- # A user-supplied resource id for this ProductSet. If set, the server will
869
- # attempt to use this value as the resource id. If it is already in use, an
870
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
871
- # long. It cannot contain the character `/`.
872
- # @param options [Google::Gax::CallOptions]
873
- # Overrides the default settings for this call, e.g, timeout,
874
- # retries, etc.
875
- # @yield [result, operation] Access the result along with the RPC operation
876
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
877
- # @yieldparam operation [GRPC::ActiveCall::Operation]
878
- # @return [Google::Cloud::Vision::V1::ProductSet]
879
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
880
- # @example
881
- # require "google/cloud/vision"
882
- #
883
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
884
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
885
- #
886
- # # TODO: Initialize `product_set`:
887
- # product_set = {}
888
- # response = product_search_client.create_product_set(formatted_parent, product_set)
889
-
890
- def create_product_set \
891
- parent,
892
- product_set,
893
- product_set_id: nil,
894
- options: nil,
895
- &block
896
- req = {
897
- parent: parent,
898
- product_set: product_set,
899
- product_set_id: product_set_id
900
- }.delete_if { |_, v| v.nil? }
901
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateProductSetRequest)
902
- @create_product_set.call(req, options, &block)
903
- end
904
-
905
- # Lists ProductSets in an unspecified order.
906
- #
907
- # Possible errors:
908
- #
909
- # * Returns INVALID_ARGUMENT if page_size is greater than 100, or less
910
- # than 1.
911
- #
912
- # @param parent [String]
913
- # The project from which ProductSets should be listed.
914
- #
915
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
916
- # @param page_size [Integer]
917
- # The maximum number of resources contained in the underlying API
918
- # response. If page streaming is performed per-resource, this
919
- # parameter does not affect the return value. If page streaming is
920
- # performed per-page, this determines the maximum number of
921
- # resources in a page.
922
- # @param options [Google::Gax::CallOptions]
923
- # Overrides the default settings for this call, e.g, timeout,
924
- # retries, etc.
925
- # @yield [result, operation] Access the result along with the RPC operation
926
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ProductSet>]
927
- # @yieldparam operation [GRPC::ActiveCall::Operation]
928
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ProductSet>]
929
- # An enumerable of Google::Cloud::Vision::V1::ProductSet instances.
930
- # See Google::Gax::PagedEnumerable documentation for other
931
- # operations such as per-page iteration or access to the response
932
- # object.
933
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
934
- # @example
935
- # require "google/cloud/vision"
936
- #
937
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
938
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
939
- #
940
- # # Iterate over all results.
941
- # product_search_client.list_product_sets(formatted_parent).each do |element|
942
- # # Process element.
943
- # end
944
- #
945
- # # Or iterate over results one page at a time.
946
- # product_search_client.list_product_sets(formatted_parent).each_page do |page|
947
- # # Process each page at a time.
948
- # page.each do |element|
949
- # # Process element.
950
- # end
951
- # end
952
-
953
- def list_product_sets \
954
- parent,
955
- page_size: nil,
956
- options: nil,
957
- &block
958
- req = {
959
- parent: parent,
960
- page_size: page_size
961
- }.delete_if { |_, v| v.nil? }
962
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductSetsRequest)
963
- @list_product_sets.call(req, options, &block)
964
- end
965
-
966
- # Gets information associated with a ProductSet.
967
- #
968
- # Possible errors:
969
- #
970
- # * Returns NOT_FOUND if the ProductSet does not exist.
971
- #
972
- # @param name [String]
973
- # Resource name of the ProductSet to get.
974
- #
975
- # Format is:
976
- # `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
977
- # @param options [Google::Gax::CallOptions]
978
- # Overrides the default settings for this call, e.g, timeout,
979
- # retries, etc.
980
- # @yield [result, operation] Access the result along with the RPC operation
981
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
982
- # @yieldparam operation [GRPC::ActiveCall::Operation]
983
- # @return [Google::Cloud::Vision::V1::ProductSet]
984
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
985
- # @example
986
- # require "google/cloud/vision"
987
- #
988
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
989
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
990
- # response = product_search_client.get_product_set(formatted_name)
991
-
992
- def get_product_set \
993
- name,
994
- options: nil,
995
- &block
996
- req = {
997
- name: name
998
- }.delete_if { |_, v| v.nil? }
999
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetProductSetRequest)
1000
- @get_product_set.call(req, options, &block)
1001
- end
1002
-
1003
- # Makes changes to a ProductSet resource.
1004
- # Only display_name can be updated currently.
1005
- #
1006
- # Possible errors:
1007
- #
1008
- # * Returns NOT_FOUND if the ProductSet does not exist.
1009
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but
1010
- # missing from the request or longer than 4096 characters.
1011
- #
1012
- # @param product_set [Google::Cloud::Vision::V1::ProductSet | Hash]
1013
- # The ProductSet resource which replaces the one on the server.
1014
- # A hash of the same form as `Google::Cloud::Vision::V1::ProductSet`
1015
- # can also be provided.
1016
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
1017
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields to
1018
- # update.
1019
- # If update_mask isn't specified, all mutable fields are to be updated.
1020
- # Valid mask path is `display_name`.
1021
- # A hash of the same form as `Google::Protobuf::FieldMask`
1022
- # can also be provided.
1023
- # @param options [Google::Gax::CallOptions]
1024
- # Overrides the default settings for this call, e.g, timeout,
1025
- # retries, etc.
1026
- # @yield [result, operation] Access the result along with the RPC operation
1027
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
1028
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1029
- # @return [Google::Cloud::Vision::V1::ProductSet]
1030
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1031
- # @example
1032
- # require "google/cloud/vision"
1033
- #
1034
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1035
- #
1036
- # # TODO: Initialize `product_set`:
1037
- # product_set = {}
1038
- # response = product_search_client.update_product_set(product_set)
1039
-
1040
- def update_product_set \
1041
- product_set,
1042
- update_mask: nil,
1043
- options: nil,
1044
- &block
1045
- req = {
1046
- product_set: product_set,
1047
- update_mask: update_mask
1048
- }.delete_if { |_, v| v.nil? }
1049
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::UpdateProductSetRequest)
1050
- @update_product_set.call(req, options, &block)
1051
- end
1052
-
1053
- # Permanently deletes a ProductSet. Products and ReferenceImages in the
1054
- # ProductSet are not deleted.
1055
- #
1056
- # The actual image files are not deleted from Google Cloud Storage.
1057
- #
1058
- # Possible errors:
1059
- #
1060
- # * Returns NOT_FOUND if the ProductSet does not exist.
1061
- #
1062
- # @param name [String]
1063
- # Resource name of the ProductSet to delete.
1064
- #
1065
- # Format is:
1066
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1067
- # @param options [Google::Gax::CallOptions]
1068
- # Overrides the default settings for this call, e.g, timeout,
1069
- # retries, etc.
1070
- # @yield [result, operation] Access the result along with the RPC operation
1071
- # @yieldparam result []
1072
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1073
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1074
- # @example
1075
- # require "google/cloud/vision"
1076
- #
1077
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1078
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1079
- # product_search_client.delete_product_set(formatted_name)
1080
-
1081
- def delete_product_set \
1082
- name,
1083
- options: nil,
1084
- &block
1085
- req = {
1086
- name: name
1087
- }.delete_if { |_, v| v.nil? }
1088
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteProductSetRequest)
1089
- @delete_product_set.call(req, options, &block)
1090
- nil
1091
- end
1092
-
1093
- # Adds a Product to the specified ProductSet. If the Product is already
1094
- # present, no change is made.
1095
- #
1096
- # One Product can be added to at most 100 ProductSets.
1097
- #
1098
- # Possible errors:
1099
- #
1100
- # * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
1101
- #
1102
- # @param name [String]
1103
- # The resource name for the ProductSet to modify.
1104
- #
1105
- # Format is:
1106
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1107
- # @param product [String]
1108
- # The resource name for the Product to be added to this ProductSet.
1109
- #
1110
- # Format is:
1111
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1112
- # @param options [Google::Gax::CallOptions]
1113
- # Overrides the default settings for this call, e.g, timeout,
1114
- # retries, etc.
1115
- # @yield [result, operation] Access the result along with the RPC operation
1116
- # @yieldparam result []
1117
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1118
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1119
- # @example
1120
- # require "google/cloud/vision"
1121
- #
1122
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1123
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1124
- #
1125
- # # TODO: Initialize `product`:
1126
- # product = ''
1127
- # product_search_client.add_product_to_product_set(formatted_name, product)
1128
-
1129
- def add_product_to_product_set \
1130
- name,
1131
- product,
1132
- options: nil,
1133
- &block
1134
- req = {
1135
- name: name,
1136
- product: product
1137
- }.delete_if { |_, v| v.nil? }
1138
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AddProductToProductSetRequest)
1139
- @add_product_to_product_set.call(req, options, &block)
1140
- nil
1141
- end
1142
-
1143
- # Removes a Product from the specified ProductSet.
1144
- #
1145
- # Possible errors:
1146
- #
1147
- # * Returns NOT_FOUND If the Product is not found under the ProductSet.
1148
- #
1149
- # @param name [String]
1150
- # The resource name for the ProductSet to modify.
1151
- #
1152
- # Format is:
1153
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1154
- # @param product [String]
1155
- # The resource name for the Product to be removed from this ProductSet.
1156
- #
1157
- # Format is:
1158
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1159
- # @param options [Google::Gax::CallOptions]
1160
- # Overrides the default settings for this call, e.g, timeout,
1161
- # retries, etc.
1162
- # @yield [result, operation] Access the result along with the RPC operation
1163
- # @yieldparam result []
1164
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1165
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1166
- # @example
1167
- # require "google/cloud/vision"
1168
- #
1169
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1170
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1171
- #
1172
- # # TODO: Initialize `product`:
1173
- # product = ''
1174
- # product_search_client.remove_product_from_product_set(formatted_name, product)
1175
-
1176
- def remove_product_from_product_set \
1177
- name,
1178
- product,
1179
- options: nil,
1180
- &block
1181
- req = {
1182
- name: name,
1183
- product: product
1184
- }.delete_if { |_, v| v.nil? }
1185
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest)
1186
- @remove_product_from_product_set.call(req, options, &block)
1187
- nil
1188
- end
1189
-
1190
- # Lists the Products in a ProductSet, in an unspecified order. If the
1191
- # ProductSet does not exist, the products field of the response will be
1192
- # empty.
1193
- #
1194
- # Possible errors:
1195
- #
1196
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
1197
- #
1198
- # @param name [String]
1199
- # The ProductSet resource for which to retrieve Products.
1200
- #
1201
- # Format is:
1202
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1203
- # @param page_size [Integer]
1204
- # The maximum number of resources contained in the underlying API
1205
- # response. If page streaming is performed per-resource, this
1206
- # parameter does not affect the return value. If page streaming is
1207
- # performed per-page, this determines the maximum number of
1208
- # resources in a page.
1209
- # @param options [Google::Gax::CallOptions]
1210
- # Overrides the default settings for this call, e.g, timeout,
1211
- # retries, etc.
1212
- # @yield [result, operation] Access the result along with the RPC operation
1213
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
1214
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1215
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
1216
- # An enumerable of Google::Cloud::Vision::V1::Product instances.
1217
- # See Google::Gax::PagedEnumerable documentation for other
1218
- # operations such as per-page iteration or access to the response
1219
- # object.
1220
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1221
- # @example
1222
- # require "google/cloud/vision"
1223
- #
1224
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1225
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1226
- #
1227
- # # Iterate over all results.
1228
- # product_search_client.list_products_in_product_set(formatted_name).each do |element|
1229
- # # Process element.
1230
- # end
1231
- #
1232
- # # Or iterate over results one page at a time.
1233
- # product_search_client.list_products_in_product_set(formatted_name).each_page do |page|
1234
- # # Process each page at a time.
1235
- # page.each do |element|
1236
- # # Process element.
1237
- # end
1238
- # end
1239
-
1240
- def list_products_in_product_set \
1241
- name,
1242
- page_size: nil,
1243
- options: nil,
1244
- &block
1245
- req = {
1246
- name: name,
1247
- page_size: page_size
1248
- }.delete_if { |_, v| v.nil? }
1249
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductsInProductSetRequest)
1250
- @list_products_in_product_set.call(req, options, &block)
1251
- end
1252
-
1253
- # Asynchronous API that imports a list of reference images to specified
1254
- # product sets based on a list of image information.
1255
- #
1256
- # The {Google::Longrunning::Operation} API can be used to keep track of the
1257
- # progress and results of the request.
1258
- # `Operation.metadata` contains `BatchOperationMetadata`. (progress)
1259
- # `Operation.response` contains `ImportProductSetsResponse`. (results)
1260
- #
1261
- # The input source of this method is a csv file on Google Cloud Storage.
1262
- # For the format of the csv file please see
1263
- # {Google::Cloud::Vision::V1::ImportProductSetsGcsSource#csv_file_uri ImportProductSetsGcsSource#csv_file_uri}.
1264
- #
1265
- # @param parent [String]
1266
- # The project in which the ProductSets should be imported.
1267
- #
1268
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
1269
- # @param input_config [Google::Cloud::Vision::V1::ImportProductSetsInputConfig | Hash]
1270
- # The input content for the list of requests.
1271
- # A hash of the same form as `Google::Cloud::Vision::V1::ImportProductSetsInputConfig`
1272
- # can also be provided.
1273
- # @param options [Google::Gax::CallOptions]
1274
- # Overrides the default settings for this call, e.g, timeout,
1275
- # retries, etc.
1276
- # @return [Google::Gax::Operation]
1277
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1278
- # @example
1279
- # require "google/cloud/vision"
1280
- #
1281
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1282
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
1283
- #
1284
- # # TODO: Initialize `input_config`:
1285
- # input_config = {}
1286
- #
1287
- # # Register a callback during the method call.
1288
- # operation = product_search_client.import_product_sets(formatted_parent, input_config) do |op|
1289
- # raise op.results.message if op.error?
1290
- # op_results = op.results
1291
- # # Process the results.
1292
- #
1293
- # metadata = op.metadata
1294
- # # Process the metadata.
1295
- # end
1296
- #
1297
- # # Or use the return value to register a callback.
1298
- # operation.on_done do |op|
1299
- # raise op.results.message if op.error?
1300
- # op_results = op.results
1301
- # # Process the results.
1302
- #
1303
- # metadata = op.metadata
1304
- # # Process the metadata.
1305
- # end
1306
- #
1307
- # # Manually reload the operation.
1308
- # operation.reload!
1309
- #
1310
- # # Or block until the operation completes, triggering callbacks on
1311
- # # completion.
1312
- # operation.wait_until_done!
1313
-
1314
- def import_product_sets \
1315
- parent,
1316
- input_config,
1317
- options: nil
1318
- req = {
1319
- parent: parent,
1320
- input_config: input_config
1321
- }.delete_if { |_, v| v.nil? }
1322
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ImportProductSetsRequest)
1323
- operation = Google::Gax::Operation.new(
1324
- @import_product_sets.call(req, options),
1325
- @operations_client,
1326
- Google::Cloud::Vision::V1::ImportProductSetsResponse,
1327
- Google::Cloud::Vision::V1::BatchOperationMetadata,
1328
- call_options: options
1329
- )
1330
- operation.on_done { |operation| yield(operation) } if block_given?
1331
- operation
1332
- end
1333
- end
1334
- end
1335
- end
1336
- end
1337
- end