google-cloud-vision-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-vision-v1.rb +1 -0
  7. data/lib/google/cloud/common_resources_pb.rb +15 -0
  8. data/lib/google/cloud/vision/v1.rb +20 -0
  9. data/lib/google/cloud/vision/v1/geometry_pb.rb +40 -0
  10. data/lib/google/cloud/vision/v1/image_annotator.rb +21 -0
  11. data/lib/google/cloud/vision/v1/image_annotator/client.rb +682 -0
  12. data/lib/google/cloud/vision/v1/image_annotator/credentials.rb +52 -0
  13. data/lib/google/cloud/vision/v1/image_annotator/helpers.rb +1228 -0
  14. data/lib/google/cloud/vision/v1/image_annotator/operations.rb +558 -0
  15. data/lib/google/cloud/vision/v1/image_annotator/paths.rb +52 -0
  16. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +345 -0
  17. data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +73 -0
  18. data/lib/google/cloud/vision/v1/product_search.rb +21 -0
  19. data/lib/google/cloud/vision/v1/product_search/client.rb +2134 -0
  20. data/lib/google/cloud/vision/v1/product_search/credentials.rb +52 -0
  21. data/lib/google/cloud/vision/v1/product_search/operations.rb +558 -0
  22. data/lib/google/cloud/vision/v1/product_search/paths.rb +109 -0
  23. data/lib/google/cloud/vision/v1/product_search_pb.rb +55 -0
  24. data/lib/google/cloud/vision/v1/product_search_service_pb.rb +208 -0
  25. data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +232 -0
  26. data/lib/google/cloud/vision/v1/text_annotation_pb.rb +95 -0
  27. data/lib/google/cloud/vision/v1/version.rb +28 -0
  28. data/lib/google/cloud/vision/v1/web_detection_pb.rb +52 -0
  29. data/proto_docs/README.md +4 -0
  30. data/proto_docs/google/api/field_behavior.rb +59 -0
  31. data/proto_docs/google/api/resource.rb +247 -0
  32. data/proto_docs/google/cloud/vision/v1/geometry.rb +82 -0
  33. data/proto_docs/google/cloud/vision/v1/image_annotator.rb +1044 -0
  34. data/proto_docs/google/cloud/vision/v1/product_search.rb +134 -0
  35. data/proto_docs/google/cloud/vision/v1/product_search_service.rb +669 -0
  36. data/proto_docs/google/cloud/vision/v1/text_annotation.rb +285 -0
  37. data/proto_docs/google/cloud/vision/v1/web_detection.rb +121 -0
  38. data/proto_docs/google/longrunning/operations.rb +150 -0
  39. data/proto_docs/google/protobuf/any.rb +137 -0
  40. data/proto_docs/google/protobuf/empty.rb +36 -0
  41. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  42. data/proto_docs/google/protobuf/timestamp.rb +116 -0
  43. data/proto_docs/google/protobuf/wrappers.rb +121 -0
  44. data/proto_docs/google/rpc/status.rb +46 -0
  45. data/proto_docs/google/type/color.rb +168 -0
  46. data/proto_docs/google/type/latlng.rb +38 -0
  47. metadata +201 -0
@@ -0,0 +1,558 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/operation"
21
+
22
+ require "google/cloud/vision/v1/version"
23
+ require "google/cloud/vision/v1/image_annotator/client"
24
+ require "google/longrunning/operations_pb"
25
+
26
+ module Google
27
+ module Cloud
28
+ module Vision
29
+ module V1
30
+ module ImageAnnotator
31
+ # Service that implements Longrunning Operations API.
32
+ class Operations
33
+ # @private
34
+ attr_reader :operations_stub
35
+
36
+ ##
37
+ # Configuration for the ImageAnnotator Operations API.
38
+ #
39
+ # @yield [config] Configure the Operations client.
40
+ # @yieldparam config [Operations::Configuration]
41
+ #
42
+ # @return [Operations::Configuration]
43
+ #
44
+ def self.configure
45
+ @configure ||= Operations::Configuration.new
46
+ yield @configure if block_given?
47
+ @configure
48
+ end
49
+
50
+ ##
51
+ # Configure the ImageAnnotator Operations instance.
52
+ #
53
+ # The configuration is set to the derived mode, meaning that values can be changed,
54
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
55
+ # should be made on {Operations.configure}.
56
+ #
57
+ # @yield [config] Configure the Operations client.
58
+ # @yieldparam config [Operations::Configuration]
59
+ #
60
+ # @return [Operations::Configuration]
61
+ #
62
+ def configure
63
+ yield @config if block_given?
64
+ @config
65
+ end
66
+
67
+ ##
68
+ # Create a new Operations client object.
69
+ #
70
+ # @yield [config] Configure the Client client.
71
+ # @yieldparam config [Operations::Configuration]
72
+ #
73
+ def initialize
74
+ # These require statements are intentionally placed here to initialize
75
+ # the gRPC module only when it's required.
76
+ # See https://github.com/googleapis/toolkit/issues/446
77
+ require "gapic/grpc"
78
+ require "google/longrunning/operations_services_pb"
79
+
80
+ # Create the configuration object
81
+ @config = Configuration.new Operations.configure
82
+
83
+ # Yield the configuration if needed
84
+ yield @config if block_given?
85
+
86
+ # Create credentials
87
+ credentials = @config.credentials
88
+ credentials ||= Credentials.default scope: @config.scope
89
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
90
+ credentials = Credentials.new credentials, scope: @config.scope
91
+ end
92
+
93
+ @operations_stub = Gapic::ServiceStub.new(
94
+ Google::Longrunning::Operations::Stub,
95
+ credentials: credentials,
96
+ endpoint: @config.endpoint,
97
+ channel_args: @config.channel_args,
98
+ interceptors: @config.interceptors
99
+ )
100
+ end
101
+
102
+ # Service calls
103
+
104
+ ##
105
+ # Lists operations that match the specified filter in the request. If the
106
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
107
+ #
108
+ # NOTE: the `name` binding below allows API services to override the binding
109
+ # to use different resource name schemes, such as `users/*/operations`.
110
+ #
111
+ # @overload list_operations(request, options = nil)
112
+ # @param request [Google::Longrunning::ListOperationsRequest | Hash]
113
+ # Lists operations that match the specified filter in the request. If the
114
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
115
+ #
116
+ # NOTE: the `name` binding below allows API services to override the binding
117
+ # to use different resource name schemes, such as `users/*/operations`.
118
+ # @param options [Gapic::CallOptions, Hash]
119
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
120
+ #
121
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
122
+ # @param name [String]
123
+ # The name of the operation collection.
124
+ # @param filter [String]
125
+ # The standard list filter.
126
+ # @param page_size [Integer]
127
+ # The standard list page size.
128
+ # @param page_token [String]
129
+ # The standard list page token.
130
+ #
131
+ #
132
+ # @yield [response, operation] Access the result along with the RPC operation
133
+ # @yieldparam response [Gapic::PagedEnumerable<Gapic::Operation>]
134
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
135
+ #
136
+ # @return [Gapic::PagedEnumerable<Gapic::Operation>]
137
+ #
138
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
139
+ #
140
+ def list_operations request, options = nil
141
+ raise ArgumentError, "request must be provided" if request.nil?
142
+
143
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::ListOperationsRequest
144
+
145
+ # Converts hash and nil to an options object
146
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
147
+
148
+ # Customize the options with defaults
149
+ metadata = @config.rpcs.list_operations.metadata.to_h
150
+
151
+ # Set x-goog-api-client and x-goog-user-project headers
152
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
153
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
154
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION
155
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
156
+
157
+ header_params = {
158
+ "name" => request.name
159
+ }
160
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
161
+ metadata[:"x-goog-request-params"] ||= request_params_header
162
+
163
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
164
+ metadata: metadata,
165
+ retry_policy: @config.rpcs.list_operations.retry_policy
166
+ options.apply_defaults metadata: @config.metadata,
167
+ retry_policy: @config.retry_policy
168
+
169
+ @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
170
+ wrap_lro_operation = ->(op_response) { Gapic::Operation.new op_response, @operations_client }
171
+ response = Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
172
+ yield response, operation if block_given?
173
+ return response
174
+ end
175
+ rescue GRPC::BadStatus => e
176
+ raise Google::Cloud::Error.from_error(e)
177
+ end
178
+
179
+ ##
180
+ # Gets the latest state of a long-running operation. Clients can use this
181
+ # method to poll the operation result at intervals as recommended by the API
182
+ # service.
183
+ #
184
+ # @overload get_operation(request, options = nil)
185
+ # @param request [Google::Longrunning::GetOperationRequest | Hash]
186
+ # Gets the latest state of a long-running operation. Clients can use this
187
+ # method to poll the operation result at intervals as recommended by the API
188
+ # service.
189
+ # @param options [Gapic::CallOptions, Hash]
190
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
191
+ #
192
+ # @overload get_operation(name: nil)
193
+ # @param name [String]
194
+ # The name of the operation resource.
195
+ #
196
+ #
197
+ # @yield [response, operation] Access the result along with the RPC operation
198
+ # @yieldparam response [Gapic::Operation]
199
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
200
+ #
201
+ # @return [Gapic::Operation]
202
+ #
203
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
204
+ #
205
+ def get_operation request, options = nil
206
+ raise ArgumentError, "request must be provided" if request.nil?
207
+
208
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::GetOperationRequest
209
+
210
+ # Converts hash and nil to an options object
211
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
212
+
213
+ # Customize the options with defaults
214
+ metadata = @config.rpcs.get_operation.metadata.to_h
215
+
216
+ # Set x-goog-api-client and x-goog-user-project headers
217
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
218
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
219
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION
220
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
221
+
222
+ header_params = {
223
+ "name" => request.name
224
+ }
225
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
226
+ metadata[:"x-goog-request-params"] ||= request_params_header
227
+
228
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
229
+ metadata: metadata,
230
+ retry_policy: @config.rpcs.get_operation.retry_policy
231
+ options.apply_defaults metadata: @config.metadata,
232
+ retry_policy: @config.retry_policy
233
+
234
+ @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
235
+ response = Gapic::Operation.new response, @operations_client, options: options
236
+ yield response, operation if block_given?
237
+ return response
238
+ end
239
+ rescue GRPC::BadStatus => e
240
+ raise Google::Cloud::Error.from_error(e)
241
+ end
242
+
243
+ ##
244
+ # Deletes a long-running operation. This method indicates that the client is
245
+ # no longer interested in the operation result. It does not cancel the
246
+ # operation. If the server doesn't support this method, it returns
247
+ # `google.rpc.Code.UNIMPLEMENTED`.
248
+ #
249
+ # @overload delete_operation(request, options = nil)
250
+ # @param request [Google::Longrunning::DeleteOperationRequest | Hash]
251
+ # Deletes a long-running operation. This method indicates that the client is
252
+ # no longer interested in the operation result. It does not cancel the
253
+ # operation. If the server doesn't support this method, it returns
254
+ # `google.rpc.Code.UNIMPLEMENTED`.
255
+ # @param options [Gapic::CallOptions, Hash]
256
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
257
+ #
258
+ # @overload delete_operation(name: nil)
259
+ # @param name [String]
260
+ # The name of the operation resource to be deleted.
261
+ #
262
+ #
263
+ # @yield [response, operation] Access the result along with the RPC operation
264
+ # @yieldparam response [Google::Protobuf::Empty]
265
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
266
+ #
267
+ # @return [Google::Protobuf::Empty]
268
+ #
269
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
270
+ #
271
+ def delete_operation request, options = nil
272
+ raise ArgumentError, "request must be provided" if request.nil?
273
+
274
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::DeleteOperationRequest
275
+
276
+ # Converts hash and nil to an options object
277
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
278
+
279
+ # Customize the options with defaults
280
+ metadata = @config.rpcs.delete_operation.metadata.to_h
281
+
282
+ # Set x-goog-api-client and x-goog-user-project headers
283
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
284
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
285
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION
286
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
287
+
288
+ header_params = {
289
+ "name" => request.name
290
+ }
291
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
292
+ metadata[:"x-goog-request-params"] ||= request_params_header
293
+
294
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
295
+ metadata: metadata,
296
+ retry_policy: @config.rpcs.delete_operation.retry_policy
297
+ options.apply_defaults metadata: @config.metadata,
298
+ retry_policy: @config.retry_policy
299
+
300
+ @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
301
+ yield response, operation if block_given?
302
+ return response
303
+ end
304
+ rescue GRPC::BadStatus => e
305
+ raise Google::Cloud::Error.from_error(e)
306
+ end
307
+
308
+ ##
309
+ # Starts asynchronous cancellation on a long-running operation. The server
310
+ # makes a best effort to cancel the operation, but success is not
311
+ # guaranteed. If the server doesn't support this method, it returns
312
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
313
+ # Operations.GetOperation or
314
+ # other methods to check whether the cancellation succeeded or whether the
315
+ # operation completed despite cancellation. On successful cancellation,
316
+ # the operation is not deleted; instead, it becomes an operation with
317
+ # an {Google::Longrunning::Operation#error Operation.error} value with a {Google::Rpc::Status#code google.rpc.Status.code} of 1,
318
+ # corresponding to `Code.CANCELLED`.
319
+ #
320
+ # @overload cancel_operation(request, options = nil)
321
+ # @param request [Google::Longrunning::CancelOperationRequest | Hash]
322
+ # Starts asynchronous cancellation on a long-running operation. The server
323
+ # makes a best effort to cancel the operation, but success is not
324
+ # guaranteed. If the server doesn't support this method, it returns
325
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
326
+ # Operations.GetOperation or
327
+ # other methods to check whether the cancellation succeeded or whether the
328
+ # operation completed despite cancellation. On successful cancellation,
329
+ # the operation is not deleted; instead, it becomes an operation with
330
+ # an {Google::Longrunning::Operation#error Operation.error} value with a {Google::Rpc::Status#code google.rpc.Status.code} of 1,
331
+ # corresponding to `Code.CANCELLED`.
332
+ # @param options [Gapic::CallOptions, Hash]
333
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
334
+ #
335
+ # @overload cancel_operation(name: nil)
336
+ # @param name [String]
337
+ # The name of the operation resource to be cancelled.
338
+ #
339
+ #
340
+ # @yield [response, operation] Access the result along with the RPC operation
341
+ # @yieldparam response [Google::Protobuf::Empty]
342
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
343
+ #
344
+ # @return [Google::Protobuf::Empty]
345
+ #
346
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
347
+ #
348
+ def cancel_operation request, options = nil
349
+ raise ArgumentError, "request must be provided" if request.nil?
350
+
351
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::CancelOperationRequest
352
+
353
+ # Converts hash and nil to an options object
354
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
355
+
356
+ # Customize the options with defaults
357
+ metadata = @config.rpcs.cancel_operation.metadata.to_h
358
+
359
+ # Set x-goog-api-client and x-goog-user-project headers
360
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
361
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
362
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION
363
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
364
+
365
+ header_params = {
366
+ "name" => request.name
367
+ }
368
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
369
+ metadata[:"x-goog-request-params"] ||= request_params_header
370
+
371
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
372
+ metadata: metadata,
373
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
374
+ options.apply_defaults metadata: @config.metadata,
375
+ retry_policy: @config.retry_policy
376
+
377
+ @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
378
+ yield response, operation if block_given?
379
+ return response
380
+ end
381
+ rescue GRPC::BadStatus => e
382
+ raise Google::Cloud::Error.from_error(e)
383
+ end
384
+
385
+ ##
386
+ # Configuration class for the Operations API.
387
+ #
388
+ # This class represents the configuration for Operations,
389
+ # providing control over timeouts, retry behavior, logging, transport
390
+ # parameters, and other low-level controls. Certain parameters can also be
391
+ # applied individually to specific RPCs. See
392
+ # {Google::Longrunning::Operations::Client::Configuration::Rpcs}
393
+ # for a list of RPCs that can be configured independently.
394
+ #
395
+ # Configuration can be applied globally to all clients, or to a single client
396
+ # on construction.
397
+ #
398
+ # # Examples
399
+ #
400
+ # To modify the global config, setting the timeout for list_operations
401
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
402
+ #
403
+ # Google::Longrunning::Operations::Client.configure do |config|
404
+ # config.timeout = 10_000
405
+ # config.rpcs.list_operations.timeout = 20_000
406
+ # end
407
+ #
408
+ # To apply the above configuration only to a new client:
409
+ #
410
+ # client = Google::Longrunning::Operations::Client.new do |config|
411
+ # config.timeout = 10_000
412
+ # config.rpcs.list_operations.timeout = 20_000
413
+ # end
414
+ #
415
+ # @!attribute [rw] endpoint
416
+ # The hostname or hostname:port of the service endpoint.
417
+ # Defaults to `"vision.googleapis.com"`.
418
+ # @return [String]
419
+ # @!attribute [rw] credentials
420
+ # Credentials to send with calls. You may provide any of the following types:
421
+ # * (`String`) The path to a service account key file in JSON format
422
+ # * (`Hash`) A service account key as a Hash
423
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
424
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
425
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
426
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
427
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
428
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
429
+ # * (`nil`) indicating no credentials
430
+ # @return [Object]
431
+ # @!attribute [rw] scope
432
+ # The OAuth scopes
433
+ # @return [Array<String>]
434
+ # @!attribute [rw] lib_name
435
+ # The library name as recorded in instrumentation and logging
436
+ # @return [String]
437
+ # @!attribute [rw] lib_version
438
+ # The library version as recorded in instrumentation and logging
439
+ # @return [String]
440
+ # @!attribute [rw] channel_args
441
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
442
+ # `GRPC::Core::Channel` object is provided as the credential.
443
+ # @return [Hash]
444
+ # @!attribute [rw] interceptors
445
+ # An array of interceptors that are run before calls are executed.
446
+ # @return [Array<GRPC::ClientInterceptor>]
447
+ # @!attribute [rw] timeout
448
+ # The call timeout in milliseconds.
449
+ # @return [Numeric]
450
+ # @!attribute [rw] metadata
451
+ # Additional gRPC headers to be sent with the call.
452
+ # @return [Hash{Symbol=>String}]
453
+ # @!attribute [rw] retry_policy
454
+ # The retry policy. The value is a hash with the following keys:
455
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
456
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
457
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
458
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
459
+ # trigger a retry.
460
+ # @return [Hash]
461
+ #
462
+ class Configuration
463
+ extend Gapic::Config
464
+
465
+ config_attr :endpoint, "vision.googleapis.com", String
466
+ config_attr :credentials, nil do |value|
467
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
468
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
469
+ allowed.any? { |klass| klass === value }
470
+ end
471
+ config_attr :scope, nil, String, Array, nil
472
+ config_attr :lib_name, nil, String, nil
473
+ config_attr :lib_version, nil, String, nil
474
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
475
+ config_attr :interceptors, nil, Array, nil
476
+ config_attr :timeout, nil, Numeric, nil
477
+ config_attr :metadata, nil, Hash, nil
478
+ config_attr :retry_policy, nil, Hash, Proc, nil
479
+
480
+ # @private
481
+ def initialize parent_config = nil
482
+ @parent_config = parent_config unless parent_config.nil?
483
+
484
+ yield self if block_given?
485
+ end
486
+
487
+ ##
488
+ # Configurations for individual RPCs
489
+ # @return [Rpcs]
490
+ #
491
+ def rpcs
492
+ @rpcs ||= begin
493
+ parent_rpcs = nil
494
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
495
+ Rpcs.new parent_rpcs
496
+ end
497
+ end
498
+
499
+ ##
500
+ # Configuration RPC class for the Operations API.
501
+ #
502
+ # Includes fields providing the configuration for each RPC in this service.
503
+ # Each configuration object is of type `Gapic::Config::Method` and includes
504
+ # the following configuration fields:
505
+ #
506
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
507
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
508
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
509
+ # include the following keys:
510
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
511
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
512
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
513
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
514
+ # trigger a retry.
515
+ #
516
+ class Rpcs
517
+ ##
518
+ # RPC-specific configuration for `list_operations`
519
+ # @return [Gapic::Config::Method]
520
+ #
521
+ attr_reader :list_operations
522
+ ##
523
+ # RPC-specific configuration for `get_operation`
524
+ # @return [Gapic::Config::Method]
525
+ #
526
+ attr_reader :get_operation
527
+ ##
528
+ # RPC-specific configuration for `delete_operation`
529
+ # @return [Gapic::Config::Method]
530
+ #
531
+ attr_reader :delete_operation
532
+ ##
533
+ # RPC-specific configuration for `cancel_operation`
534
+ # @return [Gapic::Config::Method]
535
+ #
536
+ attr_reader :cancel_operation
537
+
538
+ # @private
539
+ def initialize parent_rpcs = nil
540
+ list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
541
+ @list_operations = Gapic::Config::Method.new list_operations_config
542
+ get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
543
+ @get_operation = Gapic::Config::Method.new get_operation_config
544
+ delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
545
+ @delete_operation = Gapic::Config::Method.new delete_operation_config
546
+ cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
547
+ @cancel_operation = Gapic::Config::Method.new cancel_operation_config
548
+
549
+ yield self if block_given?
550
+ end
551
+ end
552
+ end
553
+ end
554
+ end
555
+ end
556
+ end
557
+ end
558
+ end