google-cloud-vision 0.32.2 → 1.1.3

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