google-cloud-vision 0.37.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +201 -0
  5. data/MIGRATING.md +343 -0
  6. data/README.md +96 -51
  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 +75 -103
  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 -249
  42. data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
  43. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
  44. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
  45. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -156
  46. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -536
  47. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -255
  48. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
  49. data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -51
  50. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -131
  51. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +0 -29
  52. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -222
  53. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -113
  54. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -26
  55. data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -39
  56. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -161
  57. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -31
  58. data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
  59. data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
  60. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -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 -306
  63. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -56
  64. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1415
  65. data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
  66. data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -65
  67. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -194
  68. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -223
  69. data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
  70. data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
@@ -1,56 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # Source: google/cloud/vision/v1p3beta1/image_annotator.proto for package 'google.cloud.vision.v1p3beta1'
3
- # Original file comments:
4
- # Copyright 2019 Google LLC.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- #
19
-
20
-
21
- require 'grpc'
22
- require 'google/cloud/vision/v1p3beta1/image_annotator_pb'
23
-
24
- module Google
25
- module Cloud
26
- module Vision
27
- module V1p3beta1
28
- module ImageAnnotator
29
- # Service that performs Google Cloud Vision API detection tasks over client
30
- # images, such as face, landmark, logo, label, and text detection. The
31
- # ImageAnnotator service returns detected entities from the images.
32
- class Service
33
-
34
- include GRPC::GenericService
35
-
36
- self.marshal_class_method = :encode
37
- self.unmarshal_class_method = :decode
38
- self.service_name = 'google.cloud.vision.v1p3beta1.ImageAnnotator'
39
-
40
- # Run image detection and annotation for a batch of images.
41
- rpc :BatchAnnotateImages, BatchAnnotateImagesRequest, BatchAnnotateImagesResponse
42
- # Run asynchronous image detection and annotation for a list of generic
43
- # files, such as PDF files, which may contain multiple pages and multiple
44
- # images per page. Progress and results can be retrieved through the
45
- # `google.longrunning.Operations` interface.
46
- # `Operation.metadata` contains `OperationMetadata` (metadata).
47
- # `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
48
- rpc :AsyncBatchAnnotateFiles, AsyncBatchAnnotateFilesRequest, Google::Longrunning::Operation
49
- end
50
-
51
- Stub = Service.rpc_stub_class
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,1415 +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/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
- require "google/cloud/vision/version"
33
-
34
- module Google
35
- module Cloud
36
- module Vision
37
- module V1p3beta1
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::V1p3beta1::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::V1p3beta1::Product Product} resources, named
48
- # `projects/*/locations/*/products/*`
49
- #
50
- # * Each {Google::Cloud::Vision::V1p3beta1::Product Product} has a collection of {Google::Cloud::Vision::V1p3beta1::ReferenceImage ReferenceImage} resources, named
51
- # `projects/*/locations/*/products/*/referenceImages/*`
52
- #
53
- # @!attribute [r] product_search_stub
54
- # @return [Google::Cloud::Vision::V1p3beta1::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/v1p3beta1/product_search_service_services_pb"
229
-
230
- credentials ||= Google::Cloud::Vision::V1p3beta1::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::V1p3beta1::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.v1p3beta1.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::V1p3beta1::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
- end
446
-
447
- # Service calls
448
-
449
- # Creates and returns a new ProductSet resource.
450
- #
451
- # Possible errors:
452
- #
453
- # * Returns INVALID_ARGUMENT if display_name is missing, or is longer than
454
- # 4096 characters.
455
- #
456
- # @param parent [String]
457
- # Required. The project in which the ProductSet should be created.
458
- #
459
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
460
- # @param product_set [Google::Cloud::Vision::V1p3beta1::ProductSet | Hash]
461
- # Required. The ProductSet to create.
462
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::ProductSet`
463
- # can also be provided.
464
- # @param product_set_id [String]
465
- # A user-supplied resource id for this ProductSet. If set, the server will
466
- # attempt to use this value as the resource id. If it is already in use, an
467
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
468
- # long. It cannot contain the character `/`.
469
- # @param options [Google::Gax::CallOptions]
470
- # Overrides the default settings for this call, e.g, timeout,
471
- # retries, etc.
472
- # @yield [result, operation] Access the result along with the RPC operation
473
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::ProductSet]
474
- # @yieldparam operation [GRPC::ActiveCall::Operation]
475
- # @return [Google::Cloud::Vision::V1p3beta1::ProductSet]
476
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
477
- # @example
478
- # require "google/cloud/vision"
479
- #
480
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
481
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
482
- #
483
- # # TODO: Initialize `product_set`:
484
- # product_set = {}
485
- #
486
- # # TODO: Initialize `product_set_id`:
487
- # product_set_id = ''
488
- # response = product_search_client.create_product_set(formatted_parent, product_set, product_set_id)
489
-
490
- def create_product_set \
491
- parent,
492
- product_set,
493
- product_set_id,
494
- options: nil,
495
- &block
496
- req = {
497
- parent: parent,
498
- product_set: product_set,
499
- product_set_id: product_set_id
500
- }.delete_if { |_, v| v.nil? }
501
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::CreateProductSetRequest)
502
- @create_product_set.call(req, options, &block)
503
- end
504
-
505
- # Lists ProductSets in an unspecified order.
506
- #
507
- # Possible errors:
508
- #
509
- # * Returns INVALID_ARGUMENT if page_size is greater than 100, or less
510
- # than 1.
511
- #
512
- # @param parent [String]
513
- # Required. The project from which ProductSets should be listed.
514
- #
515
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
516
- # @param page_size [Integer]
517
- # The maximum number of resources contained in the underlying API
518
- # response. If page streaming is performed per-resource, this
519
- # parameter does not affect the return value. If page streaming is
520
- # performed per-page, this determines the maximum number of
521
- # resources in a page.
522
- # @param options [Google::Gax::CallOptions]
523
- # Overrides the default settings for this call, e.g, timeout,
524
- # retries, etc.
525
- # @yield [result, operation] Access the result along with the RPC operation
526
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::ProductSet>]
527
- # @yieldparam operation [GRPC::ActiveCall::Operation]
528
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::ProductSet>]
529
- # An enumerable of Google::Cloud::Vision::V1p3beta1::ProductSet instances.
530
- # See Google::Gax::PagedEnumerable documentation for other
531
- # operations such as per-page iteration or access to the response
532
- # object.
533
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
534
- # @example
535
- # require "google/cloud/vision"
536
- #
537
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
538
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
539
- #
540
- # # Iterate over all results.
541
- # product_search_client.list_product_sets(formatted_parent).each do |element|
542
- # # Process element.
543
- # end
544
- #
545
- # # Or iterate over results one page at a time.
546
- # product_search_client.list_product_sets(formatted_parent).each_page do |page|
547
- # # Process each page at a time.
548
- # page.each do |element|
549
- # # Process element.
550
- # end
551
- # end
552
-
553
- def list_product_sets \
554
- parent,
555
- page_size: nil,
556
- options: nil,
557
- &block
558
- req = {
559
- parent: parent,
560
- page_size: page_size
561
- }.delete_if { |_, v| v.nil? }
562
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::ListProductSetsRequest)
563
- @list_product_sets.call(req, options, &block)
564
- end
565
-
566
- # Gets information associated with a ProductSet.
567
- #
568
- # Possible errors:
569
- #
570
- # * Returns NOT_FOUND if the ProductSet does not exist.
571
- #
572
- # @param name [String]
573
- # Required. Resource name of the ProductSet to get.
574
- #
575
- # Format is:
576
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
577
- # @param options [Google::Gax::CallOptions]
578
- # Overrides the default settings for this call, e.g, timeout,
579
- # retries, etc.
580
- # @yield [result, operation] Access the result along with the RPC operation
581
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::ProductSet]
582
- # @yieldparam operation [GRPC::ActiveCall::Operation]
583
- # @return [Google::Cloud::Vision::V1p3beta1::ProductSet]
584
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
585
- # @example
586
- # require "google/cloud/vision"
587
- #
588
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
589
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
590
- # response = product_search_client.get_product_set(formatted_name)
591
-
592
- def get_product_set \
593
- name,
594
- options: nil,
595
- &block
596
- req = {
597
- name: name
598
- }.delete_if { |_, v| v.nil? }
599
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::GetProductSetRequest)
600
- @get_product_set.call(req, options, &block)
601
- end
602
-
603
- # Makes changes to a ProductSet resource.
604
- # Only display_name can be updated currently.
605
- #
606
- # Possible errors:
607
- #
608
- # * Returns NOT_FOUND if the ProductSet does not exist.
609
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but
610
- # missing from the request or longer than 4096 characters.
611
- #
612
- # @param product_set [Google::Cloud::Vision::V1p3beta1::ProductSet | Hash]
613
- # Required. The ProductSet resource which replaces the one on the server.
614
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::ProductSet`
615
- # can also be provided.
616
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
617
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields to
618
- # update.
619
- # If update_mask isn't specified, all mutable fields are to be updated.
620
- # Valid mask path is `display_name`.
621
- # A hash of the same form as `Google::Protobuf::FieldMask`
622
- # can also be provided.
623
- # @param options [Google::Gax::CallOptions]
624
- # Overrides the default settings for this call, e.g, timeout,
625
- # retries, etc.
626
- # @yield [result, operation] Access the result along with the RPC operation
627
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::ProductSet]
628
- # @yieldparam operation [GRPC::ActiveCall::Operation]
629
- # @return [Google::Cloud::Vision::V1p3beta1::ProductSet]
630
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
631
- # @example
632
- # require "google/cloud/vision"
633
- #
634
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
635
- #
636
- # # TODO: Initialize `product_set`:
637
- # product_set = {}
638
- #
639
- # # TODO: Initialize `update_mask`:
640
- # update_mask = {}
641
- # response = product_search_client.update_product_set(product_set, update_mask)
642
-
643
- def update_product_set \
644
- product_set,
645
- update_mask,
646
- options: nil,
647
- &block
648
- req = {
649
- product_set: product_set,
650
- update_mask: update_mask
651
- }.delete_if { |_, v| v.nil? }
652
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::UpdateProductSetRequest)
653
- @update_product_set.call(req, options, &block)
654
- end
655
-
656
- # Permanently deletes a ProductSet. All Products and ReferenceImages in the
657
- # ProductSet will be deleted.
658
- #
659
- # The actual image files are not deleted from Google Cloud Storage.
660
- #
661
- # Possible errors:
662
- #
663
- # * Returns NOT_FOUND if the ProductSet does not exist.
664
- #
665
- # @param name [String]
666
- # Required. Resource name of the ProductSet to delete.
667
- #
668
- # Format is:
669
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
670
- # @param options [Google::Gax::CallOptions]
671
- # Overrides the default settings for this call, e.g, timeout,
672
- # retries, etc.
673
- # @yield [result, operation] Access the result along with the RPC operation
674
- # @yieldparam result []
675
- # @yieldparam operation [GRPC::ActiveCall::Operation]
676
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
677
- # @example
678
- # require "google/cloud/vision"
679
- #
680
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
681
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
682
- # product_search_client.delete_product_set(formatted_name)
683
-
684
- def delete_product_set \
685
- name,
686
- options: nil,
687
- &block
688
- req = {
689
- name: name
690
- }.delete_if { |_, v| v.nil? }
691
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::DeleteProductSetRequest)
692
- @delete_product_set.call(req, options, &block)
693
- nil
694
- end
695
-
696
- # Creates and returns a new product resource.
697
- #
698
- # Possible errors:
699
- #
700
- # * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096
701
- # characters.
702
- # * Returns INVALID_ARGUMENT if description is longer than 4096 characters.
703
- # * Returns INVALID_ARGUMENT if product_category is missing or invalid.
704
- #
705
- # @param parent [String]
706
- # Required. The project in which the Product should be created.
707
- #
708
- # Format is
709
- # `projects/PROJECT_ID/locations/LOC_ID`.
710
- # @param product [Google::Cloud::Vision::V1p3beta1::Product | Hash]
711
- # Required. The product to create.
712
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::Product`
713
- # can also be provided.
714
- # @param product_id [String]
715
- # A user-supplied resource id for this Product. If set, the server will
716
- # attempt to use this value as the resource id. If it is already in use, an
717
- # error is returned with code ALREADY_EXISTS. Must be at most 128 characters
718
- # long. It cannot contain the character `/`.
719
- # @param options [Google::Gax::CallOptions]
720
- # Overrides the default settings for this call, e.g, timeout,
721
- # retries, etc.
722
- # @yield [result, operation] Access the result along with the RPC operation
723
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::Product]
724
- # @yieldparam operation [GRPC::ActiveCall::Operation]
725
- # @return [Google::Cloud::Vision::V1p3beta1::Product]
726
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
727
- # @example
728
- # require "google/cloud/vision"
729
- #
730
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
731
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
732
- #
733
- # # TODO: Initialize `product`:
734
- # product = {}
735
- #
736
- # # TODO: Initialize `product_id`:
737
- # product_id = ''
738
- # response = product_search_client.create_product(formatted_parent, product, product_id)
739
-
740
- def create_product \
741
- parent,
742
- product,
743
- product_id,
744
- options: nil,
745
- &block
746
- req = {
747
- parent: parent,
748
- product: product,
749
- product_id: product_id
750
- }.delete_if { |_, v| v.nil? }
751
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::CreateProductRequest)
752
- @create_product.call(req, options, &block)
753
- end
754
-
755
- # Lists products in an unspecified order.
756
- #
757
- # Possible errors:
758
- #
759
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
760
- #
761
- # @param parent [String]
762
- # Required. The project OR ProductSet from which Products should be listed.
763
- #
764
- # Format:
765
- # `projects/PROJECT_ID/locations/LOC_ID`
766
- # @param page_size [Integer]
767
- # The maximum number of resources contained in the underlying API
768
- # response. If page streaming is performed per-resource, this
769
- # parameter does not affect the return value. If page streaming is
770
- # performed per-page, this determines the maximum number of
771
- # resources in a page.
772
- # @param options [Google::Gax::CallOptions]
773
- # Overrides the default settings for this call, e.g, timeout,
774
- # retries, etc.
775
- # @yield [result, operation] Access the result along with the RPC operation
776
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::Product>]
777
- # @yieldparam operation [GRPC::ActiveCall::Operation]
778
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::Product>]
779
- # An enumerable of Google::Cloud::Vision::V1p3beta1::Product instances.
780
- # See Google::Gax::PagedEnumerable documentation for other
781
- # operations such as per-page iteration or access to the response
782
- # object.
783
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
784
- # @example
785
- # require "google/cloud/vision"
786
- #
787
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
788
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
789
- #
790
- # # Iterate over all results.
791
- # product_search_client.list_products(formatted_parent).each do |element|
792
- # # Process element.
793
- # end
794
- #
795
- # # Or iterate over results one page at a time.
796
- # product_search_client.list_products(formatted_parent).each_page do |page|
797
- # # Process each page at a time.
798
- # page.each do |element|
799
- # # Process element.
800
- # end
801
- # end
802
-
803
- def list_products \
804
- parent,
805
- page_size: nil,
806
- options: nil,
807
- &block
808
- req = {
809
- parent: parent,
810
- page_size: page_size
811
- }.delete_if { |_, v| v.nil? }
812
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::ListProductsRequest)
813
- @list_products.call(req, options, &block)
814
- end
815
-
816
- # Gets information associated with a Product.
817
- #
818
- # Possible errors:
819
- #
820
- # * Returns NOT_FOUND if the Product does not exist.
821
- #
822
- # @param name [String]
823
- # Required. Resource name of the Product to get.
824
- #
825
- # Format is:
826
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
827
- # @param options [Google::Gax::CallOptions]
828
- # Overrides the default settings for this call, e.g, timeout,
829
- # retries, etc.
830
- # @yield [result, operation] Access the result along with the RPC operation
831
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::Product]
832
- # @yieldparam operation [GRPC::ActiveCall::Operation]
833
- # @return [Google::Cloud::Vision::V1p3beta1::Product]
834
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
835
- # @example
836
- # require "google/cloud/vision"
837
- #
838
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
839
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
840
- # response = product_search_client.get_product(formatted_name)
841
-
842
- def get_product \
843
- name,
844
- options: nil,
845
- &block
846
- req = {
847
- name: name
848
- }.delete_if { |_, v| v.nil? }
849
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::GetProductRequest)
850
- @get_product.call(req, options, &block)
851
- end
852
-
853
- # Makes changes to a Product resource.
854
- # Only display_name, description and labels can be updated right now.
855
- #
856
- # If labels are updated, the change will not be reflected in queries until
857
- # the next index time.
858
- #
859
- # Possible errors:
860
- #
861
- # * Returns NOT_FOUND if the Product does not exist.
862
- # * Returns INVALID_ARGUMENT if display_name is present in update_mask but is
863
- # missing from the request or longer than 4096 characters.
864
- # * Returns INVALID_ARGUMENT if description is present in update_mask but is
865
- # longer than 4096 characters.
866
- # * Returns INVALID_ARGUMENT if product_category is present in update_mask.
867
- #
868
- # @param product [Google::Cloud::Vision::V1p3beta1::Product | Hash]
869
- # Required. The Product resource which replaces the one on the server.
870
- # product.name is immutable.
871
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::Product`
872
- # can also be provided.
873
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
874
- # The {Google::Protobuf::FieldMask FieldMask} that specifies which fields
875
- # to update.
876
- # If update_mask isn't specified, all mutable fields are to be updated.
877
- # Valid mask paths include `product_labels`, `display_name`, and
878
- # `description`.
879
- # A hash of the same form as `Google::Protobuf::FieldMask`
880
- # can also be provided.
881
- # @param options [Google::Gax::CallOptions]
882
- # Overrides the default settings for this call, e.g, timeout,
883
- # retries, etc.
884
- # @yield [result, operation] Access the result along with the RPC operation
885
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::Product]
886
- # @yieldparam operation [GRPC::ActiveCall::Operation]
887
- # @return [Google::Cloud::Vision::V1p3beta1::Product]
888
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
889
- # @example
890
- # require "google/cloud/vision"
891
- #
892
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
893
- #
894
- # # TODO: Initialize `product`:
895
- # product = {}
896
- #
897
- # # TODO: Initialize `update_mask`:
898
- # update_mask = {}
899
- # response = product_search_client.update_product(product, update_mask)
900
-
901
- def update_product \
902
- product,
903
- update_mask,
904
- options: nil,
905
- &block
906
- req = {
907
- product: product,
908
- update_mask: update_mask
909
- }.delete_if { |_, v| v.nil? }
910
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::UpdateProductRequest)
911
- @update_product.call(req, options, &block)
912
- end
913
-
914
- # Permanently deletes a product and its reference images.
915
- #
916
- # Metadata of the product and all its images will be deleted right away, but
917
- # search queries against ProductSets containing the product may still work
918
- # until all related caches are refreshed.
919
- #
920
- # Possible errors:
921
- #
922
- # * Returns NOT_FOUND if the product does not exist.
923
- #
924
- # @param name [String]
925
- # Required. Resource name of product to delete.
926
- #
927
- # Format is:
928
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
929
- # @param options [Google::Gax::CallOptions]
930
- # Overrides the default settings for this call, e.g, timeout,
931
- # retries, etc.
932
- # @yield [result, operation] Access the result along with the RPC operation
933
- # @yieldparam result []
934
- # @yieldparam operation [GRPC::ActiveCall::Operation]
935
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
936
- # @example
937
- # require "google/cloud/vision"
938
- #
939
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
940
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
941
- # product_search_client.delete_product(formatted_name)
942
-
943
- def delete_product \
944
- name,
945
- options: nil,
946
- &block
947
- req = {
948
- name: name
949
- }.delete_if { |_, v| v.nil? }
950
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::DeleteProductRequest)
951
- @delete_product.call(req, options, &block)
952
- nil
953
- end
954
-
955
- # Creates and returns a new ReferenceImage resource.
956
- #
957
- # The `bounding_poly` field is optional. If `bounding_poly` is not specified,
958
- # the system will try to detect regions of interest in the image that are
959
- # compatible with the product_category on the parent product. If it is
960
- # specified, detection is ALWAYS skipped. The system converts polygons into
961
- # non-rotated rectangles.
962
- #
963
- # Note that the pipeline will resize the image if the image resolution is too
964
- # large to process (above 50MP).
965
- #
966
- # Possible errors:
967
- #
968
- # * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096
969
- # characters.
970
- # * Returns INVALID_ARGUMENT if the product does not exist.
971
- # * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing
972
- # compatible with the parent product's product_category is detected.
973
- # * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
974
- #
975
- # @param parent [String]
976
- # Required. Resource name of the product in which to create the reference image.
977
- #
978
- # Format is
979
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
980
- # @param reference_image [Google::Cloud::Vision::V1p3beta1::ReferenceImage | Hash]
981
- # Required. The reference image to create.
982
- # If an image ID is specified, it is ignored.
983
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::ReferenceImage`
984
- # can also be provided.
985
- # @param reference_image_id [String]
986
- # A user-supplied resource id for the ReferenceImage to be added. If set,
987
- # the server will attempt to use this value as the resource id. If it is
988
- # already in use, an error is returned with code ALREADY_EXISTS. Must be at
989
- # most 128 characters long. It cannot contain the character `/`.
990
- # @param options [Google::Gax::CallOptions]
991
- # Overrides the default settings for this call, e.g, timeout,
992
- # retries, etc.
993
- # @yield [result, operation] Access the result along with the RPC operation
994
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::ReferenceImage]
995
- # @yieldparam operation [GRPC::ActiveCall::Operation]
996
- # @return [Google::Cloud::Vision::V1p3beta1::ReferenceImage]
997
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
998
- # @example
999
- # require "google/cloud/vision"
1000
- #
1001
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1002
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
1003
- #
1004
- # # TODO: Initialize `reference_image`:
1005
- # reference_image = {}
1006
- #
1007
- # # TODO: Initialize `reference_image_id`:
1008
- # reference_image_id = ''
1009
- # response = product_search_client.create_reference_image(formatted_parent, reference_image, reference_image_id)
1010
-
1011
- def create_reference_image \
1012
- parent,
1013
- reference_image,
1014
- reference_image_id,
1015
- options: nil,
1016
- &block
1017
- req = {
1018
- parent: parent,
1019
- reference_image: reference_image,
1020
- reference_image_id: reference_image_id
1021
- }.delete_if { |_, v| v.nil? }
1022
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::CreateReferenceImageRequest)
1023
- @create_reference_image.call(req, options, &block)
1024
- end
1025
-
1026
- # Permanently deletes a reference image.
1027
- #
1028
- # The image metadata will be deleted right away, but search queries
1029
- # against ProductSets containing the image may still work until all related
1030
- # caches are refreshed.
1031
- #
1032
- # The actual image files are not deleted from Google Cloud Storage.
1033
- #
1034
- # Possible errors:
1035
- #
1036
- # * Returns NOT_FOUND if the reference image does not exist.
1037
- #
1038
- # @param name [String]
1039
- # Required. The resource name of the reference image to delete.
1040
- #
1041
- # Format is:
1042
- #
1043
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
1044
- # @param options [Google::Gax::CallOptions]
1045
- # Overrides the default settings for this call, e.g, timeout,
1046
- # retries, etc.
1047
- # @yield [result, operation] Access the result along with the RPC operation
1048
- # @yieldparam result []
1049
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1050
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1051
- # @example
1052
- # require "google/cloud/vision"
1053
- #
1054
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1055
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
1056
- # product_search_client.delete_reference_image(formatted_name)
1057
-
1058
- def delete_reference_image \
1059
- name,
1060
- options: nil,
1061
- &block
1062
- req = {
1063
- name: name
1064
- }.delete_if { |_, v| v.nil? }
1065
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::DeleteReferenceImageRequest)
1066
- @delete_reference_image.call(req, options, &block)
1067
- nil
1068
- end
1069
-
1070
- # Lists reference images.
1071
- #
1072
- # Possible errors:
1073
- #
1074
- # * Returns NOT_FOUND if the parent product does not exist.
1075
- # * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less
1076
- # than 1.
1077
- #
1078
- # @param parent [String]
1079
- # Required. Resource name of the product containing the reference images.
1080
- #
1081
- # Format is
1082
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
1083
- # @param page_size [Integer]
1084
- # The maximum number of resources contained in the underlying API
1085
- # response. If page streaming is performed per-resource, this
1086
- # parameter does not affect the return value. If page streaming is
1087
- # performed per-page, this determines the maximum number of
1088
- # resources in a page.
1089
- # @param options [Google::Gax::CallOptions]
1090
- # Overrides the default settings for this call, e.g, timeout,
1091
- # retries, etc.
1092
- # @yield [result, operation] Access the result along with the RPC operation
1093
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::ReferenceImage>]
1094
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1095
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::ReferenceImage>]
1096
- # An enumerable of Google::Cloud::Vision::V1p3beta1::ReferenceImage instances.
1097
- # See Google::Gax::PagedEnumerable documentation for other
1098
- # operations such as per-page iteration or access to the response
1099
- # object.
1100
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1101
- # @example
1102
- # require "google/cloud/vision"
1103
- #
1104
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1105
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_path("[PROJECT]", "[LOCATION]", "[PRODUCT]")
1106
- #
1107
- # # Iterate over all results.
1108
- # product_search_client.list_reference_images(formatted_parent).each do |element|
1109
- # # Process element.
1110
- # end
1111
- #
1112
- # # Or iterate over results one page at a time.
1113
- # product_search_client.list_reference_images(formatted_parent).each_page do |page|
1114
- # # Process each page at a time.
1115
- # page.each do |element|
1116
- # # Process element.
1117
- # end
1118
- # end
1119
-
1120
- def list_reference_images \
1121
- parent,
1122
- page_size: nil,
1123
- options: nil,
1124
- &block
1125
- req = {
1126
- parent: parent,
1127
- page_size: page_size
1128
- }.delete_if { |_, v| v.nil? }
1129
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::ListReferenceImagesRequest)
1130
- @list_reference_images.call(req, options, &block)
1131
- end
1132
-
1133
- # Gets information associated with a ReferenceImage.
1134
- #
1135
- # Possible errors:
1136
- #
1137
- # * Returns NOT_FOUND if the specified image does not exist.
1138
- #
1139
- # @param name [String]
1140
- # Required. The resource name of the ReferenceImage to get.
1141
- #
1142
- # Format is:
1143
- #
1144
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
1145
- # @param options [Google::Gax::CallOptions]
1146
- # Overrides the default settings for this call, e.g, timeout,
1147
- # retries, etc.
1148
- # @yield [result, operation] Access the result along with the RPC operation
1149
- # @yieldparam result [Google::Cloud::Vision::V1p3beta1::ReferenceImage]
1150
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1151
- # @return [Google::Cloud::Vision::V1p3beta1::ReferenceImage]
1152
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1153
- # @example
1154
- # require "google/cloud/vision"
1155
- #
1156
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1157
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.reference_image_path("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]")
1158
- # response = product_search_client.get_reference_image(formatted_name)
1159
-
1160
- def get_reference_image \
1161
- name,
1162
- options: nil,
1163
- &block
1164
- req = {
1165
- name: name
1166
- }.delete_if { |_, v| v.nil? }
1167
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::GetReferenceImageRequest)
1168
- @get_reference_image.call(req, options, &block)
1169
- end
1170
-
1171
- # Adds a Product to the specified ProductSet. If the Product is already
1172
- # present, no change is made.
1173
- #
1174
- # One Product can be added to at most 100 ProductSets.
1175
- #
1176
- # Possible errors:
1177
- #
1178
- # * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
1179
- #
1180
- # @param name [String]
1181
- # Required. The resource name for the ProductSet to modify.
1182
- #
1183
- # Format is:
1184
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1185
- # @param product [String]
1186
- # Required. The resource name for the Product to be added to this ProductSet.
1187
- #
1188
- # Format is:
1189
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1190
- # @param options [Google::Gax::CallOptions]
1191
- # Overrides the default settings for this call, e.g, timeout,
1192
- # retries, etc.
1193
- # @yield [result, operation] Access the result along with the RPC operation
1194
- # @yieldparam result []
1195
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1196
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1197
- # @example
1198
- # require "google/cloud/vision"
1199
- #
1200
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1201
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1202
- #
1203
- # # TODO: Initialize `product`:
1204
- # product = ''
1205
- # product_search_client.add_product_to_product_set(formatted_name, product)
1206
-
1207
- def add_product_to_product_set \
1208
- name,
1209
- product,
1210
- options: nil,
1211
- &block
1212
- req = {
1213
- name: name,
1214
- product: product
1215
- }.delete_if { |_, v| v.nil? }
1216
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::AddProductToProductSetRequest)
1217
- @add_product_to_product_set.call(req, options, &block)
1218
- nil
1219
- end
1220
-
1221
- # Removes a Product from the specified ProductSet.
1222
- #
1223
- # Possible errors:
1224
- #
1225
- # * Returns NOT_FOUND If the Product is not found under the ProductSet.
1226
- #
1227
- # @param name [String]
1228
- # Required. The resource name for the ProductSet to modify.
1229
- #
1230
- # Format is:
1231
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1232
- # @param product [String]
1233
- # Required. The resource name for the Product to be removed from this ProductSet.
1234
- #
1235
- # Format is:
1236
- # `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1237
- # @param options [Google::Gax::CallOptions]
1238
- # Overrides the default settings for this call, e.g, timeout,
1239
- # retries, etc.
1240
- # @yield [result, operation] Access the result along with the RPC operation
1241
- # @yieldparam result []
1242
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1243
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1244
- # @example
1245
- # require "google/cloud/vision"
1246
- #
1247
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1248
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1249
- #
1250
- # # TODO: Initialize `product`:
1251
- # product = ''
1252
- # product_search_client.remove_product_from_product_set(formatted_name, product)
1253
-
1254
- def remove_product_from_product_set \
1255
- name,
1256
- product,
1257
- options: nil,
1258
- &block
1259
- req = {
1260
- name: name,
1261
- product: product
1262
- }.delete_if { |_, v| v.nil? }
1263
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::RemoveProductFromProductSetRequest)
1264
- @remove_product_from_product_set.call(req, options, &block)
1265
- nil
1266
- end
1267
-
1268
- # Lists the Products in a ProductSet, in an unspecified order. If the
1269
- # ProductSet does not exist, the products field of the response will be
1270
- # empty.
1271
- #
1272
- # Possible errors:
1273
- #
1274
- # * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
1275
- #
1276
- # @param name [String]
1277
- # Required. The ProductSet resource for which to retrieve Products.
1278
- #
1279
- # Format is:
1280
- # `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
1281
- # @param page_size [Integer]
1282
- # The maximum number of resources contained in the underlying API
1283
- # response. If page streaming is performed per-resource, this
1284
- # parameter does not affect the return value. If page streaming is
1285
- # performed per-page, this determines the maximum number of
1286
- # resources in a page.
1287
- # @param options [Google::Gax::CallOptions]
1288
- # Overrides the default settings for this call, e.g, timeout,
1289
- # retries, etc.
1290
- # @yield [result, operation] Access the result along with the RPC operation
1291
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::Product>]
1292
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1293
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Vision::V1p3beta1::Product>]
1294
- # An enumerable of Google::Cloud::Vision::V1p3beta1::Product instances.
1295
- # See Google::Gax::PagedEnumerable documentation for other
1296
- # operations such as per-page iteration or access to the response
1297
- # object.
1298
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1299
- # @example
1300
- # require "google/cloud/vision"
1301
- #
1302
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1303
- # formatted_name = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.product_set_path("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]")
1304
- #
1305
- # # Iterate over all results.
1306
- # product_search_client.list_products_in_product_set(formatted_name).each do |element|
1307
- # # Process element.
1308
- # end
1309
- #
1310
- # # Or iterate over results one page at a time.
1311
- # product_search_client.list_products_in_product_set(formatted_name).each_page do |page|
1312
- # # Process each page at a time.
1313
- # page.each do |element|
1314
- # # Process element.
1315
- # end
1316
- # end
1317
-
1318
- def list_products_in_product_set \
1319
- name,
1320
- page_size: nil,
1321
- options: nil,
1322
- &block
1323
- req = {
1324
- name: name,
1325
- page_size: page_size
1326
- }.delete_if { |_, v| v.nil? }
1327
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::ListProductsInProductSetRequest)
1328
- @list_products_in_product_set.call(req, options, &block)
1329
- end
1330
-
1331
- # Asynchronous API that imports a list of reference images to specified
1332
- # product sets based on a list of image information.
1333
- #
1334
- # The {Google::Longrunning::Operation} API can be
1335
- # used to keep track of the progress and results of the request.
1336
- # `Operation.metadata` contains `BatchOperationMetadata`. (progress)
1337
- # `Operation.response` contains `ImportProductSetsResponse`. (results)
1338
- #
1339
- # The input source of this method is a csv file on Google Cloud Storage.
1340
- # For the format of the csv file please see
1341
- # {Google::Cloud::Vision::V1p3beta1::ImportProductSetsGcsSource#csv_file_uri ImportProductSetsGcsSource#csv_file_uri}.
1342
- #
1343
- # @param parent [String]
1344
- # Required. The project in which the ProductSets should be imported.
1345
- #
1346
- # Format is `projects/PROJECT_ID/locations/LOC_ID`.
1347
- # @param input_config [Google::Cloud::Vision::V1p3beta1::ImportProductSetsInputConfig | Hash]
1348
- # Required. The input content for the list of requests.
1349
- # A hash of the same form as `Google::Cloud::Vision::V1p3beta1::ImportProductSetsInputConfig`
1350
- # can also be provided.
1351
- # @param options [Google::Gax::CallOptions]
1352
- # Overrides the default settings for this call, e.g, timeout,
1353
- # retries, etc.
1354
- # @return [Google::Gax::Operation]
1355
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1356
- # @example
1357
- # require "google/cloud/vision"
1358
- #
1359
- # product_search_client = Google::Cloud::Vision::ProductSearch.new(version: :v1p3beta1)
1360
- # formatted_parent = Google::Cloud::Vision::V1p3beta1::ProductSearchClient.location_path("[PROJECT]", "[LOCATION]")
1361
- #
1362
- # # TODO: Initialize `input_config`:
1363
- # input_config = {}
1364
- #
1365
- # # Register a callback during the method call.
1366
- # operation = product_search_client.import_product_sets(formatted_parent, input_config) do |op|
1367
- # raise op.results.message if op.error?
1368
- # op_results = op.results
1369
- # # Process the results.
1370
- #
1371
- # metadata = op.metadata
1372
- # # Process the metadata.
1373
- # end
1374
- #
1375
- # # Or use the return value to register a callback.
1376
- # operation.on_done do |op|
1377
- # raise op.results.message if op.error?
1378
- # op_results = op.results
1379
- # # Process the results.
1380
- #
1381
- # metadata = op.metadata
1382
- # # Process the metadata.
1383
- # end
1384
- #
1385
- # # Manually reload the operation.
1386
- # operation.reload!
1387
- #
1388
- # # Or block until the operation completes, triggering callbacks on
1389
- # # completion.
1390
- # operation.wait_until_done!
1391
-
1392
- def import_product_sets \
1393
- parent,
1394
- input_config,
1395
- options: nil
1396
- req = {
1397
- parent: parent,
1398
- input_config: input_config
1399
- }.delete_if { |_, v| v.nil? }
1400
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1p3beta1::ImportProductSetsRequest)
1401
- operation = Google::Gax::Operation.new(
1402
- @import_product_sets.call(req, options),
1403
- @operations_client,
1404
- Google::Cloud::Vision::V1p3beta1::ImportProductSetsResponse,
1405
- Google::Cloud::Vision::V1p3beta1::BatchOperationMetadata,
1406
- call_options: options
1407
- )
1408
- operation.on_done { |operation| yield(operation) } if block_given?
1409
- operation
1410
- end
1411
- end
1412
- end
1413
- end
1414
- end
1415
- end