google-cloud-vision 0.37.2 → 1.0.2

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