google-cloud-vision 0.38.0 → 1.0.0

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