google-cloud-vision 0.37.2 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +94 -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 +74 -102
  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 -516
  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 -1490
  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 -253
  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 -538
  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 -312
  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 -304
  63. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -55
  64. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1419
  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 -64
  67. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -191
  68. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -226
  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,1490 +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
- headers.merge!(metadata) unless metadata.nil?
270
- client_config_file = Pathname.new(__dir__).join(
271
- "product_search_client_config.json"
272
- )
273
- defaults = client_config_file.open do |f|
274
- Google::Gax.construct_settings(
275
- "google.cloud.vision.v1.ProductSearch",
276
- JSON.parse(f.read),
277
- client_config,
278
- Google::Gax::Grpc::STATUS_CODE_NAMES,
279
- timeout,
280
- page_descriptors: PAGE_DESCRIPTORS,
281
- errors: Google::Gax::Grpc::API_ERRORS,
282
- metadata: headers
283
- )
284
- end
285
-
286
- # Allow overriding the service path/port in subclasses.
287
- service_path = service_address || self.class::SERVICE_ADDRESS
288
- port = service_port || self.class::DEFAULT_SERVICE_PORT
289
- interceptors = self.class::GRPC_INTERCEPTORS
290
- @product_search_stub = Google::Gax::Grpc.create_stub(
291
- service_path,
292
- port,
293
- chan_creds: chan_creds,
294
- channel: channel,
295
- updater_proc: updater_proc,
296
- scopes: scopes,
297
- interceptors: interceptors,
298
- &Google::Cloud::Vision::V1::ProductSearch::Stub.method(:new)
299
- )
300
-
301
- @create_product_set = Google::Gax.create_api_call(
302
- @product_search_stub.method(:create_product_set),
303
- defaults["create_product_set"],
304
- exception_transformer: exception_transformer,
305
- params_extractor: proc do |request|
306
- {'parent' => request.parent}
307
- end
308
- )
309
- @list_product_sets = Google::Gax.create_api_call(
310
- @product_search_stub.method(:list_product_sets),
311
- defaults["list_product_sets"],
312
- exception_transformer: exception_transformer,
313
- params_extractor: proc do |request|
314
- {'parent' => request.parent}
315
- end
316
- )
317
- @get_product_set = Google::Gax.create_api_call(
318
- @product_search_stub.method(:get_product_set),
319
- defaults["get_product_set"],
320
- exception_transformer: exception_transformer,
321
- params_extractor: proc do |request|
322
- {'name' => request.name}
323
- end
324
- )
325
- @update_product_set = Google::Gax.create_api_call(
326
- @product_search_stub.method(:update_product_set),
327
- defaults["update_product_set"],
328
- exception_transformer: exception_transformer,
329
- params_extractor: proc do |request|
330
- {'product_set.name' => request.product_set.name}
331
- end
332
- )
333
- @delete_product_set = Google::Gax.create_api_call(
334
- @product_search_stub.method(:delete_product_set),
335
- defaults["delete_product_set"],
336
- exception_transformer: exception_transformer,
337
- params_extractor: proc do |request|
338
- {'name' => request.name}
339
- end
340
- )
341
- @create_product = Google::Gax.create_api_call(
342
- @product_search_stub.method(:create_product),
343
- defaults["create_product"],
344
- exception_transformer: exception_transformer,
345
- params_extractor: proc do |request|
346
- {'parent' => request.parent}
347
- end
348
- )
349
- @list_products = Google::Gax.create_api_call(
350
- @product_search_stub.method(:list_products),
351
- defaults["list_products"],
352
- exception_transformer: exception_transformer,
353
- params_extractor: proc do |request|
354
- {'parent' => request.parent}
355
- end
356
- )
357
- @get_product = Google::Gax.create_api_call(
358
- @product_search_stub.method(:get_product),
359
- defaults["get_product"],
360
- exception_transformer: exception_transformer,
361
- params_extractor: proc do |request|
362
- {'name' => request.name}
363
- end
364
- )
365
- @update_product = Google::Gax.create_api_call(
366
- @product_search_stub.method(:update_product),
367
- defaults["update_product"],
368
- exception_transformer: exception_transformer,
369
- params_extractor: proc do |request|
370
- {'product.name' => request.product.name}
371
- end
372
- )
373
- @delete_product = Google::Gax.create_api_call(
374
- @product_search_stub.method(:delete_product),
375
- defaults["delete_product"],
376
- exception_transformer: exception_transformer,
377
- params_extractor: proc do |request|
378
- {'name' => request.name}
379
- end
380
- )
381
- @create_reference_image = Google::Gax.create_api_call(
382
- @product_search_stub.method(:create_reference_image),
383
- defaults["create_reference_image"],
384
- exception_transformer: exception_transformer,
385
- params_extractor: proc do |request|
386
- {'parent' => request.parent}
387
- end
388
- )
389
- @delete_reference_image = Google::Gax.create_api_call(
390
- @product_search_stub.method(:delete_reference_image),
391
- defaults["delete_reference_image"],
392
- exception_transformer: exception_transformer,
393
- params_extractor: proc do |request|
394
- {'name' => request.name}
395
- end
396
- )
397
- @list_reference_images = Google::Gax.create_api_call(
398
- @product_search_stub.method(:list_reference_images),
399
- defaults["list_reference_images"],
400
- exception_transformer: exception_transformer,
401
- params_extractor: proc do |request|
402
- {'parent' => request.parent}
403
- end
404
- )
405
- @get_reference_image = Google::Gax.create_api_call(
406
- @product_search_stub.method(:get_reference_image),
407
- defaults["get_reference_image"],
408
- exception_transformer: exception_transformer,
409
- params_extractor: proc do |request|
410
- {'name' => request.name}
411
- end
412
- )
413
- @add_product_to_product_set = Google::Gax.create_api_call(
414
- @product_search_stub.method(:add_product_to_product_set),
415
- defaults["add_product_to_product_set"],
416
- exception_transformer: exception_transformer,
417
- params_extractor: proc do |request|
418
- {'name' => request.name}
419
- end
420
- )
421
- @remove_product_from_product_set = Google::Gax.create_api_call(
422
- @product_search_stub.method(:remove_product_from_product_set),
423
- defaults["remove_product_from_product_set"],
424
- exception_transformer: exception_transformer,
425
- params_extractor: proc do |request|
426
- {'name' => request.name}
427
- end
428
- )
429
- @list_products_in_product_set = Google::Gax.create_api_call(
430
- @product_search_stub.method(:list_products_in_product_set),
431
- defaults["list_products_in_product_set"],
432
- exception_transformer: exception_transformer,
433
- params_extractor: proc do |request|
434
- {'name' => request.name}
435
- end
436
- )
437
- @import_product_sets = Google::Gax.create_api_call(
438
- @product_search_stub.method(:import_product_sets),
439
- defaults["import_product_sets"],
440
- exception_transformer: exception_transformer,
441
- params_extractor: proc do |request|
442
- {'parent' => request.parent}
443
- end
444
- )
445
- @purge_products = Google::Gax.create_api_call(
446
- @product_search_stub.method(:purge_products),
447
- defaults["purge_products"],
448
- exception_transformer: exception_transformer,
449
- params_extractor: proc do |request|
450
- {'parent' => request.parent}
451
- end
452
- )
453
- end
454
-
455
- # Service calls
456
-
457
- # Creates and returns a new ProductSet resource.
458
- #
459
- # Possible errors:
460
- #
461
- # * Returns INVALID_ARGUMENT if display_name is missing, or is longer than
462
- # 4096 characters.
463
- #
464
- # @param parent [String]
465
- # Required. The project in which the ProductSet should be created.
466
- #
467
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
468
- # @param product_set [Google::Cloud::Vision::V1::ProductSet | Hash]
469
- # Required. The ProductSet to create.
470
- # A hash of the same form as `Google::Cloud::Vision::V1::ProductSet`
471
- # can also be provided.
472
- # @param product_set_id [String]
473
- # A user-supplied resource id for this ProductSet. If set, the server will
474
- # attempt to use this value as the resource id. If it is already in use, an
475
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
476
- # long. It cannot contain the character `/`.
477
- # @param options [Google::Gax::CallOptions]
478
- # Overrides the default settings for this call, e.g, timeout,
479
- # retries, etc.
480
- # @yield [result, operation] Access the result along with the RPC operation
481
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
482
- # @yieldparam operation [GRPC::ActiveCall::Operation]
483
- # @return [Google::Cloud::Vision::V1::ProductSet]
484
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
485
- # @example
486
- # require "google/cloud/vision"
487
- #
488
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
489
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
490
- #
491
- # # TODO: Initialize `product_set`:
492
- # product_set = {}
493
- # response = product_search_client.create_product_set(formatted_parent, product_set)
494
-
495
- def create_product_set \
496
- parent,
497
- product_set,
498
- product_set_id: nil,
499
- options: nil,
500
- &block
501
- req = {
502
- parent: parent,
503
- product_set: product_set,
504
- product_set_id: product_set_id
505
- }.delete_if { |_, v| v.nil? }
506
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateProductSetRequest)
507
- @create_product_set.call(req, options, &block)
508
- end
509
-
510
- # Lists ProductSets in an unspecified order.
511
- #
512
- # Possible errors:
513
- #
514
- # * Returns INVALID_ARGUMENT if page_size is greater than 100, or less
515
- # than 1.
516
- #
517
- # @param parent [String]
518
- # Required. The project from which ProductSets should be listed.
519
- #
520
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
521
- # @param page_size [Integer]
522
- # The maximum number of resources contained in the underlying API
523
- # response. If page streaming is performed per-resource, this
524
- # parameter does not affect the return value. If page streaming is
525
- # performed per-page, this determines the maximum number of
526
- # resources in a page.
527
- # @param options [Google::Gax::CallOptions]
528
- # Overrides the default settings for this call, e.g, timeout,
529
- # retries, etc.
530
- # @yield [result, operation] Access the result along with the RPC operation
531
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ProductSet>]
532
- # @yieldparam operation [GRPC::ActiveCall::Operation]
533
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ProductSet>]
534
- # An enumerable of Google::Cloud::Vision::V1::ProductSet instances.
535
- # See Google::Gax::PagedEnumerable documentation for other
536
- # operations such as per-page iteration or access to the response
537
- # object.
538
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
539
- # @example
540
- # require "google/cloud/vision"
541
- #
542
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
543
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
544
- #
545
- # # Iterate over all results.
546
- # product_search_client.list_product_sets(formatted_parent).each do |element|
547
- # # Process element.
548
- # end
549
- #
550
- # # Or iterate over results one page at a time.
551
- # product_search_client.list_product_sets(formatted_parent).each_page do |page|
552
- # # Process each page at a time.
553
- # page.each do |element|
554
- # # Process element.
555
- # end
556
- # end
557
-
558
- def list_product_sets \
559
- parent,
560
- page_size: nil,
561
- options: nil,
562
- &block
563
- req = {
564
- parent: parent,
565
- page_size: page_size
566
- }.delete_if { |_, v| v.nil? }
567
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductSetsRequest)
568
- @list_product_sets.call(req, options, &block)
569
- end
570
-
571
- # Gets information associated with a ProductSet.
572
- #
573
- # Possible errors:
574
- #
575
- # * Returns NOT_FOUND if the ProductSet does not exist.
576
- #
577
- # @param name [String]
578
- # Required. Resource name of the ProductSet to get.
579
- #
580
- # Format is:
581
- # `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID`
582
- # @param options [Google::Gax::CallOptions]
583
- # Overrides the default settings for this call, e.g, timeout,
584
- # retries, etc.
585
- # @yield [result, operation] Access the result along with the RPC operation
586
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
587
- # @yieldparam operation [GRPC::ActiveCall::Operation]
588
- # @return [Google::Cloud::Vision::V1::ProductSet]
589
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
590
- # @example
591
- # require "google/cloud/vision"
592
- #
593
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
594
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
595
- # response = product_search_client.get_product_set(formatted_name)
596
-
597
- def get_product_set \
598
- name,
599
- options: nil,
600
- &block
601
- req = {
602
- name: name
603
- }.delete_if { |_, v| v.nil? }
604
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetProductSetRequest)
605
- @get_product_set.call(req, options, &block)
606
- end
607
-
608
- # Makes changes to a ProductSet resource.
609
- # Only display_name can be updated currently.
610
- #
611
- # Possible errors:
612
- #
613
- # * Returns NOT_FOUND if the ProductSet does not exist.
614
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but
615
- # missing from the request or longer than 4096 characters.
616
- #
617
- # @param product_set [Google::Cloud::Vision::V1::ProductSet | Hash]
618
- # Required. The ProductSet resource which replaces the one on the server.
619
- # A hash of the same form as `Google::Cloud::Vision::V1::ProductSet`
620
- # can also be provided.
621
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
622
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields to
623
- # update.
624
- # If update_mask isn't specified, all mutable fields are to be updated.
625
- # Valid mask path is `display_name`.
626
- # A hash of the same form as `Google::Protobuf::FieldMask`
627
- # can also be provided.
628
- # @param options [Google::Gax::CallOptions]
629
- # Overrides the default settings for this call, e.g, timeout,
630
- # retries, etc.
631
- # @yield [result, operation] Access the result along with the RPC operation
632
- # @yieldparam result [Google::Cloud::Vision::V1::ProductSet]
633
- # @yieldparam operation [GRPC::ActiveCall::Operation]
634
- # @return [Google::Cloud::Vision::V1::ProductSet]
635
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
636
- # @example
637
- # require "google/cloud/vision"
638
- #
639
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
640
- #
641
- # # TODO: Initialize `product_set`:
642
- # product_set = {}
643
- # response = product_search_client.update_product_set(product_set)
644
-
645
- def update_product_set \
646
- product_set,
647
- update_mask: nil,
648
- options: nil,
649
- &block
650
- req = {
651
- product_set: product_set,
652
- update_mask: update_mask
653
- }.delete_if { |_, v| v.nil? }
654
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::UpdateProductSetRequest)
655
- @update_product_set.call(req, options, &block)
656
- end
657
-
658
- # Permanently deletes a ProductSet. Products and ReferenceImages in the
659
- # ProductSet are not deleted.
660
- #
661
- # The actual image files are not deleted from Google Cloud Storage.
662
- #
663
- # @param name [String]
664
- # Required. Resource name of the ProductSet to delete.
665
- #
666
- # Format is:
667
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
668
- # @param options [Google::Gax::CallOptions]
669
- # Overrides the default settings for this call, e.g, timeout,
670
- # retries, etc.
671
- # @yield [result, operation] Access the result along with the RPC operation
672
- # @yieldparam result []
673
- # @yieldparam operation [GRPC::ActiveCall::Operation]
674
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
675
- # @example
676
- # require "google/cloud/vision"
677
- #
678
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
679
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
680
- # product_search_client.delete_product_set(formatted_name)
681
-
682
- def delete_product_set \
683
- name,
684
- options: nil,
685
- &block
686
- req = {
687
- name: name
688
- }.delete_if { |_, v| v.nil? }
689
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteProductSetRequest)
690
- @delete_product_set.call(req, options, &block)
691
- nil
692
- end
693
-
694
- # Creates and returns a new product resource.
695
- #
696
- # Possible errors:
697
- #
698
- # * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096
699
- # characters.
700
- # * Returns INVALID_ARGUMENT if description is longer than 4096 characters.
701
- # * Returns INVALID_ARGUMENT if product_category is missing or invalid.
702
- #
703
- # @param parent [String]
704
- # Required. The project in which the Product should be created.
705
- #
706
- # Format is
707
- # `projects/PROJECT_ID/locations/LOC_ID`.
708
- # @param product [Google::Cloud::Vision::V1::Product | Hash]
709
- # Required. The product to create.
710
- # A hash of the same form as `Google::Cloud::Vision::V1::Product`
711
- # can also be provided.
712
- # @param product_id [String]
713
- # A user-supplied resource id for this Product. If set, the server will
714
- # attempt to use this value as the resource id. If it is already in use, an
715
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
716
- # long. It cannot contain the character `/`.
717
- # @param options [Google::Gax::CallOptions]
718
- # Overrides the default settings for this call, e.g, timeout,
719
- # retries, etc.
720
- # @yield [result, operation] Access the result along with the RPC operation
721
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
722
- # @yieldparam operation [GRPC::ActiveCall::Operation]
723
- # @return [Google::Cloud::Vision::V1::Product]
724
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
725
- # @example
726
- # require "google/cloud/vision"
727
- #
728
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
729
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
730
- #
731
- # # TODO: Initialize `product`:
732
- # product = {}
733
- # response = product_search_client.create_product(formatted_parent, product)
734
-
735
- def create_product \
736
- parent,
737
- product,
738
- product_id: nil,
739
- options: nil,
740
- &block
741
- req = {
742
- parent: parent,
743
- product: product,
744
- product_id: product_id
745
- }.delete_if { |_, v| v.nil? }
746
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateProductRequest)
747
- @create_product.call(req, options, &block)
748
- end
749
-
750
- # Lists products in an unspecified order.
751
- #
752
- # Possible errors:
753
- #
754
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
755
- #
756
- # @param parent [String]
757
- # Required. The project OR ProductSet from which Products should be listed.
758
- #
759
- # Format:
760
- # `projects/PROJECT_ID/locations/LOC_ID`
761
- # @param page_size [Integer]
762
- # The maximum number of resources contained in the underlying API
763
- # response. If page streaming is performed per-resource, this
764
- # parameter does not affect the return value. If page streaming is
765
- # performed per-page, this determines the maximum number of
766
- # resources in a page.
767
- # @param options [Google::Gax::CallOptions]
768
- # Overrides the default settings for this call, e.g, timeout,
769
- # retries, etc.
770
- # @yield [result, operation] Access the result along with the RPC operation
771
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
772
- # @yieldparam operation [GRPC::ActiveCall::Operation]
773
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
774
- # An enumerable of Google::Cloud::Vision::V1::Product instances.
775
- # See Google::Gax::PagedEnumerable documentation for other
776
- # operations such as per-page iteration or access to the response
777
- # object.
778
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
779
- # @example
780
- # require "google/cloud/vision"
781
- #
782
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
783
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
784
- #
785
- # # Iterate over all results.
786
- # product_search_client.list_products(formatted_parent).each do |element|
787
- # # Process element.
788
- # end
789
- #
790
- # # Or iterate over results one page at a time.
791
- # product_search_client.list_products(formatted_parent).each_page do |page|
792
- # # Process each page at a time.
793
- # page.each do |element|
794
- # # Process element.
795
- # end
796
- # end
797
-
798
- def list_products \
799
- parent,
800
- page_size: nil,
801
- options: nil,
802
- &block
803
- req = {
804
- parent: parent,
805
- page_size: page_size
806
- }.delete_if { |_, v| v.nil? }
807
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductsRequest)
808
- @list_products.call(req, options, &block)
809
- end
810
-
811
- # Gets information associated with a Product.
812
- #
813
- # Possible errors:
814
- #
815
- # * Returns NOT_FOUND if the Product does not exist.
816
- #
817
- # @param name [String]
818
- # Required. Resource name of the Product to get.
819
- #
820
- # Format is:
821
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
822
- # @param options [Google::Gax::CallOptions]
823
- # Overrides the default settings for this call, e.g, timeout,
824
- # retries, etc.
825
- # @yield [result, operation] Access the result along with the RPC operation
826
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
827
- # @yieldparam operation [GRPC::ActiveCall::Operation]
828
- # @return [Google::Cloud::Vision::V1::Product]
829
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
830
- # @example
831
- # require "google/cloud/vision"
832
- #
833
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
834
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
835
- # response = product_search_client.get_product(formatted_name)
836
-
837
- def get_product \
838
- name,
839
- options: nil,
840
- &block
841
- req = {
842
- name: name
843
- }.delete_if { |_, v| v.nil? }
844
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetProductRequest)
845
- @get_product.call(req, options, &block)
846
- end
847
-
848
- # Makes changes to a Product resource.
849
- # Only the `display_name`, `description`, and `labels` fields can be updated
850
- # right now.
851
- #
852
- # If labels are updated, the change will not be reflected in queries until
853
- # the next index time.
854
- #
855
- # Possible errors:
856
- #
857
- # * Returns NOT_FOUND if the Product does not exist.
858
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but is
859
- # missing from the request or longer than 4096 characters.
860
- # * Returns INVALID_ARGUMENT if description is present in update_mask but is
861
- # longer than 4096 characters.
862
- # * Returns INVALID_ARGUMENT if product_category is present in update_mask.
863
- #
864
- # @param product [Google::Cloud::Vision::V1::Product | Hash]
865
- # Required. The Product resource which replaces the one on the server.
866
- # product.name is immutable.
867
- # A hash of the same form as `Google::Cloud::Vision::V1::Product`
868
- # can also be provided.
869
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
870
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields
871
- # to update.
872
- # If update_mask isn't specified, all mutable fields are to be updated.
873
- # Valid mask paths include `product_labels`, `display_name`, and
874
- # `description`.
875
- # A hash of the same form as `Google::Protobuf::FieldMask`
876
- # can also be provided.
877
- # @param options [Google::Gax::CallOptions]
878
- # Overrides the default settings for this call, e.g, timeout,
879
- # retries, etc.
880
- # @yield [result, operation] Access the result along with the RPC operation
881
- # @yieldparam result [Google::Cloud::Vision::V1::Product]
882
- # @yieldparam operation [GRPC::ActiveCall::Operation]
883
- # @return [Google::Cloud::Vision::V1::Product]
884
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
885
- # @example
886
- # require "google/cloud/vision"
887
- #
888
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
889
- #
890
- # # TODO: Initialize `product`:
891
- # product = {}
892
- # response = product_search_client.update_product(product)
893
-
894
- def update_product \
895
- product,
896
- update_mask: nil,
897
- options: nil,
898
- &block
899
- req = {
900
- product: product,
901
- update_mask: update_mask
902
- }.delete_if { |_, v| v.nil? }
903
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::UpdateProductRequest)
904
- @update_product.call(req, options, &block)
905
- end
906
-
907
- # Permanently deletes a product and its reference images.
908
- #
909
- # Metadata of the product and all its images will be deleted right away, but
910
- # search queries against ProductSets containing the product may still work
911
- # until all related caches are refreshed.
912
- #
913
- # @param name [String]
914
- # Required. Resource name of product to delete.
915
- #
916
- # Format is:
917
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
918
- # @param options [Google::Gax::CallOptions]
919
- # Overrides the default settings for this call, e.g, timeout,
920
- # retries, etc.
921
- # @yield [result, operation] Access the result along with the RPC operation
922
- # @yieldparam result []
923
- # @yieldparam operation [GRPC::ActiveCall::Operation]
924
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
925
- # @example
926
- # require "google/cloud/vision"
927
- #
928
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
929
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
930
- # product_search_client.delete_product(formatted_name)
931
-
932
- def delete_product \
933
- name,
934
- options: nil,
935
- &block
936
- req = {
937
- name: name
938
- }.delete_if { |_, v| v.nil? }
939
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteProductRequest)
940
- @delete_product.call(req, options, &block)
941
- nil
942
- end
943
-
944
- # Creates and returns a new ReferenceImage resource.
945
- #
946
- # The `bounding_poly` field is optional. If `bounding_poly` is not specified,
947
- # the system will try to detect regions of interest in the image that are
948
- # compatible with the product_category on the parent product. If it is
949
- # specified, detection is ALWAYS skipped. The system converts polygons into
950
- # non-rotated rectangles.
951
- #
952
- # Note that the pipeline will resize the image if the image resolution is too
953
- # large to process (above 50MP).
954
- #
955
- # Possible errors:
956
- #
957
- # * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096
958
- # characters.
959
- # * Returns INVALID_ARGUMENT if the product does not exist.
960
- # * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing
961
- # compatible with the parent product's product_category is detected.
962
- # * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
963
- #
964
- # @param parent [String]
965
- # Required. Resource name of the product in which to create the reference image.
966
- #
967
- # Format is
968
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
969
- # @param reference_image [Google::Cloud::Vision::V1::ReferenceImage | Hash]
970
- # Required. The reference image to create.
971
- # If an image ID is specified, it is ignored.
972
- # A hash of the same form as `Google::Cloud::Vision::V1::ReferenceImage`
973
- # can also be provided.
974
- # @param reference_image_id [String]
975
- # A user-supplied resource id for the ReferenceImage to be added. If set,
976
- # the server will attempt to use this value as the resource id. If it is
977
- # already in use, an error is returned with code ALREADY_EXISTS. Must be at
978
- # most 128 characters long. It cannot contain the character `/`.
979
- # @param options [Google::Gax::CallOptions]
980
- # Overrides the default settings for this call, e.g, timeout,
981
- # retries, etc.
982
- # @yield [result, operation] Access the result along with the RPC operation
983
- # @yieldparam result [Google::Cloud::Vision::V1::ReferenceImage]
984
- # @yieldparam operation [GRPC::ActiveCall::Operation]
985
- # @return [Google::Cloud::Vision::V1::ReferenceImage]
986
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
987
- # @example
988
- # require "google/cloud/vision"
989
- #
990
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
991
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
992
- #
993
- # # TODO: Initialize `reference_image`:
994
- # reference_image = {}
995
- # response = product_search_client.create_reference_image(formatted_parent, reference_image)
996
-
997
- def create_reference_image \
998
- parent,
999
- reference_image,
1000
- reference_image_id: nil,
1001
- options: nil,
1002
- &block
1003
- req = {
1004
- parent: parent,
1005
- reference_image: reference_image,
1006
- reference_image_id: reference_image_id
1007
- }.delete_if { |_, v| v.nil? }
1008
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::CreateReferenceImageRequest)
1009
- @create_reference_image.call(req, options, &block)
1010
- end
1011
-
1012
- # Permanently deletes a reference image.
1013
- #
1014
- # The image metadata will be deleted right away, but search queries
1015
- # against ProductSets containing the image may still work until all related
1016
- # caches are refreshed.
1017
- #
1018
- # The actual image files are not deleted from Google Cloud Storage.
1019
- #
1020
- # @param name [String]
1021
- # Required. The resource name of the reference image to delete.
1022
- #
1023
- # Format is:
1024
- #
1025
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
1026
- # @param options [Google::Gax::CallOptions]
1027
- # Overrides the default settings for this call, e.g, timeout,
1028
- # retries, etc.
1029
- # @yield [result, operation] Access the result along with the RPC operation
1030
- # @yieldparam result []
1031
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1032
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1033
- # @example
1034
- # require "google/cloud/vision"
1035
- #
1036
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1037
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
1038
- # product_search_client.delete_reference_image(formatted_name)
1039
-
1040
- def delete_reference_image \
1041
- name,
1042
- options: nil,
1043
- &block
1044
- req = {
1045
- name: name
1046
- }.delete_if { |_, v| v.nil? }
1047
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::DeleteReferenceImageRequest)
1048
- @delete_reference_image.call(req, options, &block)
1049
- nil
1050
- end
1051
-
1052
- # Lists reference images.
1053
- #
1054
- # Possible errors:
1055
- #
1056
- # * Returns NOT_FOUND if the parent product does not exist.
1057
- # * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less
1058
- # than 1.
1059
- #
1060
- # @param parent [String]
1061
- # Required. Resource name of the product containing the reference images.
1062
- #
1063
- # Format is
1064
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
1065
- # @param page_size [Integer]
1066
- # The maximum number of resources contained in the underlying API
1067
- # response. If page streaming is performed per-resource, this
1068
- # parameter does not affect the return value. If page streaming is
1069
- # performed per-page, this determines the maximum number of
1070
- # resources in a page.
1071
- # @param options [Google::Gax::CallOptions]
1072
- # Overrides the default settings for this call, e.g, timeout,
1073
- # retries, etc.
1074
- # @yield [result, operation] Access the result along with the RPC operation
1075
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ReferenceImage>]
1076
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1077
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::ReferenceImage>]
1078
- # An enumerable of Google::Cloud::Vision::V1::ReferenceImage instances.
1079
- # See Google::Gax::PagedEnumerable documentation for other
1080
- # operations such as per-page iteration or access to the response
1081
- # object.
1082
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1083
- # @example
1084
- # require "google/cloud/vision"
1085
- #
1086
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1087
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
1088
- #
1089
- # # Iterate over all results.
1090
- # product_search_client.list_reference_images(formatted_parent).each do |element|
1091
- # # Process element.
1092
- # end
1093
- #
1094
- # # Or iterate over results one page at a time.
1095
- # product_search_client.list_reference_images(formatted_parent).each_page do |page|
1096
- # # Process each page at a time.
1097
- # page.each do |element|
1098
- # # Process element.
1099
- # end
1100
- # end
1101
-
1102
- def list_reference_images \
1103
- parent,
1104
- page_size: nil,
1105
- options: nil,
1106
- &block
1107
- req = {
1108
- parent: parent,
1109
- page_size: page_size
1110
- }.delete_if { |_, v| v.nil? }
1111
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListReferenceImagesRequest)
1112
- @list_reference_images.call(req, options, &block)
1113
- end
1114
-
1115
- # Gets information associated with a ReferenceImage.
1116
- #
1117
- # Possible errors:
1118
- #
1119
- # * Returns NOT_FOUND if the specified image does not exist.
1120
- #
1121
- # @param name [String]
1122
- # Required. The resource name of the ReferenceImage to get.
1123
- #
1124
- # Format is:
1125
- #
1126
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
1127
- # @param options [Google::Gax::CallOptions]
1128
- # Overrides the default settings for this call, e.g, timeout,
1129
- # retries, etc.
1130
- # @yield [result, operation] Access the result along with the RPC operation
1131
- # @yieldparam result [Google::Cloud::Vision::V1::ReferenceImage]
1132
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1133
- # @return [Google::Cloud::Vision::V1::ReferenceImage]
1134
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1135
- # @example
1136
- # require "google/cloud/vision"
1137
- #
1138
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1139
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
1140
- # response = product_search_client.get_reference_image(formatted_name)
1141
-
1142
- def get_reference_image \
1143
- name,
1144
- options: nil,
1145
- &block
1146
- req = {
1147
- name: name
1148
- }.delete_if { |_, v| v.nil? }
1149
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::GetReferenceImageRequest)
1150
- @get_reference_image.call(req, options, &block)
1151
- end
1152
-
1153
- # Adds a Product to the specified ProductSet. If the Product is already
1154
- # present, no change is made.
1155
- #
1156
- # One Product can be added to at most 100 ProductSets.
1157
- #
1158
- # Possible errors:
1159
- #
1160
- # * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
1161
- #
1162
- # @param name [String]
1163
- # Required. The resource name for the ProductSet to modify.
1164
- #
1165
- # Format is:
1166
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1167
- # @param product [String]
1168
- # Required. The resource name for the Product to be added to this ProductSet.
1169
- #
1170
- # Format is:
1171
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1172
- # @param options [Google::Gax::CallOptions]
1173
- # Overrides the default settings for this call, e.g, timeout,
1174
- # retries, etc.
1175
- # @yield [result, operation] Access the result along with the RPC operation
1176
- # @yieldparam result []
1177
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1178
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1179
- # @example
1180
- # require "google/cloud/vision"
1181
- #
1182
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1183
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1184
- # formatted_product = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
1185
- # product_search_client.add_product_to_product_set(formatted_name, formatted_product)
1186
-
1187
- def add_product_to_product_set \
1188
- name,
1189
- product,
1190
- options: nil,
1191
- &block
1192
- req = {
1193
- name: name,
1194
- product: product
1195
- }.delete_if { |_, v| v.nil? }
1196
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AddProductToProductSetRequest)
1197
- @add_product_to_product_set.call(req, options, &block)
1198
- nil
1199
- end
1200
-
1201
- # Removes a Product from the specified ProductSet.
1202
- #
1203
- # @param name [String]
1204
- # Required. The resource name for the ProductSet to modify.
1205
- #
1206
- # Format is:
1207
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1208
- # @param product [String]
1209
- # Required. The resource name for the Product to be removed from this ProductSet.
1210
- #
1211
- # Format is:
1212
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1213
- # @param options [Google::Gax::CallOptions]
1214
- # Overrides the default settings for this call, e.g, timeout,
1215
- # retries, etc.
1216
- # @yield [result, operation] Access the result along with the RPC operation
1217
- # @yieldparam result []
1218
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1219
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1220
- # @example
1221
- # require "google/cloud/vision"
1222
- #
1223
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1224
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1225
- # formatted_product = Google::Cloud::Vision::V1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
1226
- # product_search_client.remove_product_from_product_set(formatted_name, formatted_product)
1227
-
1228
- def remove_product_from_product_set \
1229
- name,
1230
- product,
1231
- options: nil,
1232
- &block
1233
- req = {
1234
- name: name,
1235
- product: product
1236
- }.delete_if { |_, v| v.nil? }
1237
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::RemoveProductFromProductSetRequest)
1238
- @remove_product_from_product_set.call(req, options, &block)
1239
- nil
1240
- end
1241
-
1242
- # Lists the Products in a ProductSet, in an unspecified order. If the
1243
- # ProductSet does not exist, the products field of the response will be
1244
- # empty.
1245
- #
1246
- # Possible errors:
1247
- #
1248
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
1249
- #
1250
- # @param name [String]
1251
- # Required. The ProductSet resource for which to retrieve Products.
1252
- #
1253
- # Format is:
1254
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1255
- # @param page_size [Integer]
1256
- # The maximum number of resources contained in the underlying API
1257
- # response. If page streaming is performed per-resource, this
1258
- # parameter does not affect the return value. If page streaming is
1259
- # performed per-page, this determines the maximum number of
1260
- # resources in a page.
1261
- # @param options [Google::Gax::CallOptions]
1262
- # Overrides the default settings for this call, e.g, timeout,
1263
- # retries, etc.
1264
- # @yield [result, operation] Access the result along with the RPC operation
1265
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
1266
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1267
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1::Product>]
1268
- # An enumerable of Google::Cloud::Vision::V1::Product instances.
1269
- # See Google::Gax::PagedEnumerable documentation for other
1270
- # operations such as per-page iteration or access to the response
1271
- # object.
1272
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1273
- # @example
1274
- # require "google/cloud/vision"
1275
- #
1276
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1277
- # formatted_name = Google::Cloud::Vision::V1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1278
- #
1279
- # # Iterate over all results.
1280
- # product_search_client.list_products_in_product_set(formatted_name).each do |element|
1281
- # # Process element.
1282
- # end
1283
- #
1284
- # # Or iterate over results one page at a time.
1285
- # product_search_client.list_products_in_product_set(formatted_name).each_page do |page|
1286
- # # Process each page at a time.
1287
- # page.each do |element|
1288
- # # Process element.
1289
- # end
1290
- # end
1291
-
1292
- def list_products_in_product_set \
1293
- name,
1294
- page_size: nil,
1295
- options: nil,
1296
- &block
1297
- req = {
1298
- name: name,
1299
- page_size: page_size
1300
- }.delete_if { |_, v| v.nil? }
1301
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ListProductsInProductSetRequest)
1302
- @list_products_in_product_set.call(req, options, &block)
1303
- end
1304
-
1305
- # Asynchronous API that imports a list of reference images to specified
1306
- # product sets based on a list of image information.
1307
- #
1308
- # The {Google::Longrunning::Operation} API can be used to keep track of the
1309
- # progress and results of the request.
1310
- # `Operation.metadata` contains `BatchOperationMetadata`. (progress)
1311
- # `Operation.response` contains `ImportProductSetsResponse`. (results)
1312
- #
1313
- # The input source of this method is a csv file on Google Cloud Storage.
1314
- # For the format of the csv file please see
1315
- # {Google::Cloud::Vision::V1::ImportProductSetsGcsSource#csv_file_uri ImportProductSetsGcsSource#csv_file_uri}.
1316
- #
1317
- # @param parent [String]
1318
- # Required. The project in which the ProductSets should be imported.
1319
- #
1320
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
1321
- # @param input_config [Google::Cloud::Vision::V1::ImportProductSetsInputConfig | Hash]
1322
- # Required. The input content for the list of requests.
1323
- # A hash of the same form as `Google::Cloud::Vision::V1::ImportProductSetsInputConfig`
1324
- # can also be provided.
1325
- # @param options [Google::Gax::CallOptions]
1326
- # Overrides the default settings for this call, e.g, timeout,
1327
- # retries, etc.
1328
- # @return [Google::Gax::Operation]
1329
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1330
- # @example
1331
- # require "google/cloud/vision"
1332
- #
1333
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1334
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
1335
- #
1336
- # # TODO: Initialize `input_config`:
1337
- # input_config = {}
1338
- #
1339
- # # Register a callback during the method call.
1340
- # operation = product_search_client.import_product_sets(formatted_parent, input_config) do |op|
1341
- # raise op.results.message if op.error?
1342
- # op_results = op.results
1343
- # # Process the results.
1344
- #
1345
- # metadata = op.metadata
1346
- # # Process the metadata.
1347
- # end
1348
- #
1349
- # # Or use the return value to register a callback.
1350
- # operation.on_done do |op|
1351
- # raise op.results.message if op.error?
1352
- # op_results = op.results
1353
- # # Process the results.
1354
- #
1355
- # metadata = op.metadata
1356
- # # Process the metadata.
1357
- # end
1358
- #
1359
- # # Manually reload the operation.
1360
- # operation.reload!
1361
- #
1362
- # # Or block until the operation completes, triggering callbacks on
1363
- # # completion.
1364
- # operation.wait_until_done!
1365
-
1366
- def import_product_sets \
1367
- parent,
1368
- input_config,
1369
- options: nil
1370
- req = {
1371
- parent: parent,
1372
- input_config: input_config
1373
- }.delete_if { |_, v| v.nil? }
1374
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::ImportProductSetsRequest)
1375
- operation = Google::Gax::Operation.new(
1376
- @import_product_sets.call(req, options),
1377
- @operations_client,
1378
- Google::Cloud::Vision::V1::ImportProductSetsResponse,
1379
- Google::Cloud::Vision::V1::BatchOperationMetadata,
1380
- call_options: options
1381
- )
1382
- operation.on_done { |operation| yield(operation) } if block_given?
1383
- operation
1384
- end
1385
-
1386
- # Asynchronous API to delete all Products in a ProductSet or all Products
1387
- # that are in no ProductSet.
1388
- #
1389
- # If a Product is a member of the specified ProductSet in addition to other
1390
- # ProductSets, the Product will still be deleted.
1391
- #
1392
- # It is recommended to not delete the specified ProductSet until after this
1393
- # operation has completed. It is also recommended to not add any of the
1394
- # Products involved in the batch delete to a new ProductSet while this
1395
- # operation is running because those Products may still end up deleted.
1396
- #
1397
- # It's not possible to undo the PurgeProducts operation. Therefore, it is
1398
- # recommended to keep the csv files used in ImportProductSets (if that was
1399
- # how you originally built the Product Set) before starting PurgeProducts, in
1400
- # case you need to re-import the data after deletion.
1401
- #
1402
- # If the plan is to purge all of the Products from a ProductSet and then
1403
- # re-use the empty ProductSet to re-import new Products into the empty
1404
- # ProductSet, you must wait until the PurgeProducts operation has finished
1405
- # for that ProductSet.
1406
- #
1407
- # The {Google::Longrunning::Operation} API can be used to keep track of the
1408
- # progress and results of the request.
1409
- # `Operation.metadata` contains `BatchOperationMetadata`. (progress)
1410
- #
1411
- # @param parent [String]
1412
- # Required. The project and location in which the Products should be deleted.
1413
- #
1414
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
1415
- # @param product_set_purge_config [Google::Cloud::Vision::V1::ProductSetPurgeConfig | Hash]
1416
- # Specify which ProductSet contains the Products to be deleted.
1417
- # A hash of the same form as `Google::Cloud::Vision::V1::ProductSetPurgeConfig`
1418
- # can also be provided.
1419
- # @param delete_orphan_products [true, false]
1420
- # If delete_orphan_products is true, all Products that are not in any
1421
- # ProductSet will be deleted.
1422
- # @param force [true, false]
1423
- # The default value is false. Override this value to true to actually perform
1424
- # the purge.
1425
- # @param options [Google::Gax::CallOptions]
1426
- # Overrides the default settings for this call, e.g, timeout,
1427
- # retries, etc.
1428
- # @return [Google::Gax::Operation]
1429
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1430
- # @example
1431
- # require "google/cloud/vision"
1432
- #
1433
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1)
1434
- # formatted_parent = Google::Cloud::Vision::V1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
1435
- #
1436
- # # Register a callback during the method call.
1437
- # operation = product_search_client.purge_products(formatted_parent) do |op|
1438
- # raise op.results.message if op.error?
1439
- # op_results = op.results
1440
- # # Process the results.
1441
- #
1442
- # metadata = op.metadata
1443
- # # Process the metadata.
1444
- # end
1445
- #
1446
- # # Or use the return value to register a callback.
1447
- # operation.on_done do |op|
1448
- # raise op.results.message if op.error?
1449
- # op_results = op.results
1450
- # # Process the results.
1451
- #
1452
- # metadata = op.metadata
1453
- # # Process the metadata.
1454
- # end
1455
- #
1456
- # # Manually reload the operation.
1457
- # operation.reload!
1458
- #
1459
- # # Or block until the operation completes, triggering callbacks on
1460
- # # completion.
1461
- # operation.wait_until_done!
1462
-
1463
- def purge_products \
1464
- parent,
1465
- product_set_purge_config: nil,
1466
- delete_orphan_products: nil,
1467
- force: nil,
1468
- options: nil
1469
- req = {
1470
- parent: parent,
1471
- product_set_purge_config: product_set_purge_config,
1472
- delete_orphan_products: delete_orphan_products,
1473
- force: force
1474
- }.delete_if { |_, v| v.nil? }
1475
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::PurgeProductsRequest)
1476
- operation = Google::Gax::Operation.new(
1477
- @purge_products.call(req, options),
1478
- @operations_client,
1479
- Google::Protobuf::Empty,
1480
- Google::Cloud::Vision::V1::BatchOperationMetadata,
1481
- call_options: options
1482
- )
1483
- operation.on_done { |operation| yield(operation) } if block_given?
1484
- operation
1485
- end
1486
- end
1487
- end
1488
- end
1489
- end
1490
- end