google-cloud-vision 0.38.0 → 1.0.0

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