google-cloud-vision-v1 0.5.0 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,13 +43,12 @@ module Google
43
43
  # See {::Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
44
44
  # for a description of the configuration fields.
45
45
  #
46
- # ## Example
46
+ # @example
47
47
  #
48
- # To modify the configuration for all ImageAnnotator clients:
49
- #
50
- # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
51
- # config.timeout = 10.0
52
- # end
48
+ # # Modify the configuration for all ImageAnnotator clients
49
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
53
52
  #
54
53
  # @yield [config] Configure the Client client.
55
54
  # @yieldparam config [Client::Configuration]
@@ -62,41 +61,29 @@ module Google
62
61
  parent_config = while namespace.any?
63
62
  parent_name = namespace.join "::"
64
63
  parent_const = const_get parent_name
65
- break parent_const.configure if parent_const&.respond_to? :configure
64
+ break parent_const.configure if parent_const.respond_to? :configure
66
65
  namespace.pop
67
66
  end
68
67
  default_config = Client::Configuration.new parent_config
69
68
 
70
69
  default_config.rpcs.batch_annotate_images.timeout = 600.0
71
70
  default_config.rpcs.batch_annotate_images.retry_policy = {
72
- initial_delay: 0.1,
73
- max_delay: 60.0,
74
- multiplier: 1.3,
75
- retry_codes: [4, 14]
71
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
76
72
  }
77
73
 
78
74
  default_config.rpcs.batch_annotate_files.timeout = 600.0
79
75
  default_config.rpcs.batch_annotate_files.retry_policy = {
80
- initial_delay: 0.1,
81
- max_delay: 60.0,
82
- multiplier: 1.3,
83
- retry_codes: [4, 14]
76
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
84
77
  }
85
78
 
86
79
  default_config.rpcs.async_batch_annotate_images.timeout = 600.0
87
80
  default_config.rpcs.async_batch_annotate_images.retry_policy = {
88
- initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 14]
81
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
92
82
  }
93
83
 
94
84
  default_config.rpcs.async_batch_annotate_files.timeout = 600.0
95
85
  default_config.rpcs.async_batch_annotate_files.retry_policy = {
96
- initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 14]
86
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
100
87
  }
101
88
 
102
89
  default_config
@@ -128,19 +115,15 @@ module Google
128
115
  ##
129
116
  # Create a new ImageAnnotator client object.
130
117
  #
131
- # ## Examples
132
- #
133
- # To create a new ImageAnnotator client with the default
134
- # configuration:
118
+ # @example
135
119
  #
136
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
137
122
  #
138
- # To create a new ImageAnnotator client with a custom
139
- # configuration:
140
- #
141
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
142
- # config.timeout = 10.0
143
- # end
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
144
127
  #
145
128
  # @yield [config] Configure the ImageAnnotator client.
146
129
  # @yieldparam config [Client::Configuration]
@@ -160,14 +143,13 @@ module Google
160
143
 
161
144
  # Create credentials
162
145
  credentials = @config.credentials
163
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
164
147
  # but only if the default endpoint does not have a region prefix.
165
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
166
- @config.endpoint == Client.configure.endpoint &&
148
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
167
149
  !@config.endpoint.split(".").first.include?("-")
168
- credentials ||= Credentials.default scope: @config.scope,
150
+ credentials ||= Credentials.default scope: @config.scope,
169
151
  enable_self_signed_jwt: enable_self_signed_jwt
170
- if credentials.is_a?(String) || credentials.is_a?(Hash)
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
171
153
  credentials = Credentials.new credentials, scope: @config.scope
172
154
  end
173
155
  @quota_project_id = @config.quota_project
@@ -238,6 +220,21 @@ module Google
238
220
  #
239
221
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
240
222
  #
223
+ # @example Basic example
224
+ # require "google/cloud/vision/v1"
225
+ #
226
+ # # Create a client object. The client can be reused for multiple calls.
227
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
228
+ #
229
+ # # Create a request. To set request fields, pass in keyword arguments.
230
+ # request = Google::Cloud::Vision::V1::BatchAnnotateImagesRequest.new
231
+ #
232
+ # # Call the batch_annotate_images method.
233
+ # result = client.batch_annotate_images request
234
+ #
235
+ # # The returned object is of type Google::Cloud::Vision::V1::BatchAnnotateImagesResponse.
236
+ # p result
237
+ #
241
238
  def batch_annotate_images request, options = nil
242
239
  raise ::ArgumentError, "request must be provided" if request.nil?
243
240
 
@@ -258,7 +255,9 @@ module Google
258
255
  options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
259
256
  metadata: metadata,
260
257
  retry_policy: @config.rpcs.batch_annotate_images.retry_policy
261
- options.apply_defaults metadata: @config.metadata,
258
+
259
+ options.apply_defaults timeout: @config.timeout,
260
+ metadata: @config.metadata,
262
261
  retry_policy: @config.retry_policy
263
262
 
264
263
  @image_annotator_stub.call_rpc :batch_annotate_images, request, options: options do |response, operation|
@@ -318,6 +317,21 @@ module Google
318
317
  #
319
318
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
320
319
  #
320
+ # @example Basic example
321
+ # require "google/cloud/vision/v1"
322
+ #
323
+ # # Create a client object. The client can be reused for multiple calls.
324
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
325
+ #
326
+ # # Create a request. To set request fields, pass in keyword arguments.
327
+ # request = Google::Cloud::Vision::V1::BatchAnnotateFilesRequest.new
328
+ #
329
+ # # Call the batch_annotate_files method.
330
+ # result = client.batch_annotate_files request
331
+ #
332
+ # # The returned object is of type Google::Cloud::Vision::V1::BatchAnnotateFilesResponse.
333
+ # p result
334
+ #
321
335
  def batch_annotate_files request, options = nil
322
336
  raise ::ArgumentError, "request must be provided" if request.nil?
323
337
 
@@ -338,7 +352,9 @@ module Google
338
352
  options.apply_defaults timeout: @config.rpcs.batch_annotate_files.timeout,
339
353
  metadata: metadata,
340
354
  retry_policy: @config.rpcs.batch_annotate_files.retry_policy
341
- options.apply_defaults metadata: @config.metadata,
355
+
356
+ options.apply_defaults timeout: @config.timeout,
357
+ metadata: @config.metadata,
342
358
  retry_policy: @config.retry_policy
343
359
 
344
360
  @image_annotator_stub.call_rpc :batch_annotate_files, request, options: options do |response, operation|
@@ -401,6 +417,28 @@ module Google
401
417
  #
402
418
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
403
419
  #
420
+ # @example Basic example
421
+ # require "google/cloud/vision/v1"
422
+ #
423
+ # # Create a client object. The client can be reused for multiple calls.
424
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
425
+ #
426
+ # # Create a request. To set request fields, pass in keyword arguments.
427
+ # request = Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest.new
428
+ #
429
+ # # Call the async_batch_annotate_images method.
430
+ # result = client.async_batch_annotate_images request
431
+ #
432
+ # # The returned object is of type Gapic::Operation. You can use this
433
+ # # object to check the status of an operation, cancel it, or wait
434
+ # # for results. Here is how to block until completion:
435
+ # result.wait_until_done! timeout: 60
436
+ # if result.response?
437
+ # p result.response
438
+ # else
439
+ # puts "Error!"
440
+ # end
441
+ #
404
442
  def async_batch_annotate_images request, options = nil
405
443
  raise ::ArgumentError, "request must be provided" if request.nil?
406
444
 
@@ -421,7 +459,9 @@ module Google
421
459
  options.apply_defaults timeout: @config.rpcs.async_batch_annotate_images.timeout,
422
460
  metadata: metadata,
423
461
  retry_policy: @config.rpcs.async_batch_annotate_images.retry_policy
424
- options.apply_defaults metadata: @config.metadata,
462
+
463
+ options.apply_defaults timeout: @config.timeout,
464
+ metadata: @config.metadata,
425
465
  retry_policy: @config.retry_policy
426
466
 
427
467
  @image_annotator_stub.call_rpc :async_batch_annotate_images, request, options: options do |response, operation|
@@ -480,6 +520,28 @@ module Google
480
520
  #
481
521
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
482
522
  #
523
+ # @example Basic example
524
+ # require "google/cloud/vision/v1"
525
+ #
526
+ # # Create a client object. The client can be reused for multiple calls.
527
+ # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
528
+ #
529
+ # # Create a request. To set request fields, pass in keyword arguments.
530
+ # request = Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest.new
531
+ #
532
+ # # Call the async_batch_annotate_files method.
533
+ # result = client.async_batch_annotate_files request
534
+ #
535
+ # # The returned object is of type Gapic::Operation. You can use this
536
+ # # object to check the status of an operation, cancel it, or wait
537
+ # # for results. Here is how to block until completion:
538
+ # result.wait_until_done! timeout: 60
539
+ # if result.response?
540
+ # p result.response
541
+ # else
542
+ # puts "Error!"
543
+ # end
544
+ #
483
545
  def async_batch_annotate_files request, options = nil
484
546
  raise ::ArgumentError, "request must be provided" if request.nil?
485
547
 
@@ -500,7 +562,9 @@ module Google
500
562
  options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
501
563
  metadata: metadata,
502
564
  retry_policy: @config.rpcs.async_batch_annotate_files.retry_policy
503
- options.apply_defaults metadata: @config.metadata,
565
+
566
+ options.apply_defaults timeout: @config.timeout,
567
+ metadata: @config.metadata,
504
568
  retry_policy: @config.retry_policy
505
569
 
506
570
  @image_annotator_stub.call_rpc :async_batch_annotate_files, request, options: options do |response, operation|
@@ -525,22 +589,21 @@ module Google
525
589
  # Configuration can be applied globally to all clients, or to a single client
526
590
  # on construction.
527
591
  #
528
- # # Examples
529
- #
530
- # To modify the global config, setting the timeout for batch_annotate_images
531
- # to 20 seconds, and all remaining timeouts to 10 seconds:
532
- #
533
- # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
534
- # config.timeout = 10.0
535
- # config.rpcs.batch_annotate_images.timeout = 20.0
536
- # end
592
+ # @example
537
593
  #
538
- # To apply the above configuration only to a new client:
594
+ # # Modify the global config, setting the timeout for
595
+ # # batch_annotate_images to 20 seconds,
596
+ # # and all remaining timeouts to 10 seconds.
597
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
598
+ # config.timeout = 10.0
599
+ # config.rpcs.batch_annotate_images.timeout = 20.0
600
+ # end
539
601
  #
540
- # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
541
- # config.timeout = 10.0
542
- # config.rpcs.batch_annotate_images.timeout = 20.0
543
- # end
602
+ # # Apply the above configuration only to a new client.
603
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
604
+ # config.timeout = 10.0
605
+ # config.rpcs.batch_annotate_images.timeout = 20.0
606
+ # end
544
607
  #
545
608
  # @!attribute [rw] endpoint
546
609
  # The hostname or hostname:port of the service endpoint.
@@ -604,7 +667,7 @@ module Google
604
667
  config_attr :scope, nil, ::String, ::Array, nil
605
668
  config_attr :lib_name, nil, ::String, nil
606
669
  config_attr :lib_version, nil, ::String, nil
607
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
670
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
608
671
  config_attr :interceptors, nil, ::Array, nil
609
672
  config_attr :timeout, nil, ::Numeric, nil
610
673
  config_attr :metadata, nil, ::Hash, nil
@@ -625,7 +688,7 @@ module Google
625
688
  def rpcs
626
689
  @rpcs ||= begin
627
690
  parent_rpcs = nil
628
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
691
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
629
692
  Rpcs.new parent_rpcs
630
693
  end
631
694
  end
@@ -671,13 +734,13 @@ module Google
671
734
 
672
735
  # @private
673
736
  def initialize parent_rpcs = nil
674
- batch_annotate_images_config = parent_rpcs&.batch_annotate_images if parent_rpcs&.respond_to? :batch_annotate_images
737
+ batch_annotate_images_config = parent_rpcs.batch_annotate_images if parent_rpcs.respond_to? :batch_annotate_images
675
738
  @batch_annotate_images = ::Gapic::Config::Method.new batch_annotate_images_config
676
- batch_annotate_files_config = parent_rpcs&.batch_annotate_files if parent_rpcs&.respond_to? :batch_annotate_files
739
+ batch_annotate_files_config = parent_rpcs.batch_annotate_files if parent_rpcs.respond_to? :batch_annotate_files
677
740
  @batch_annotate_files = ::Gapic::Config::Method.new batch_annotate_files_config
678
- async_batch_annotate_images_config = parent_rpcs&.async_batch_annotate_images if parent_rpcs&.respond_to? :async_batch_annotate_images
741
+ async_batch_annotate_images_config = parent_rpcs.async_batch_annotate_images if parent_rpcs.respond_to? :async_batch_annotate_images
679
742
  @async_batch_annotate_images = ::Gapic::Config::Method.new async_batch_annotate_images_config
680
- async_batch_annotate_files_config = parent_rpcs&.async_batch_annotate_files if parent_rpcs&.respond_to? :async_batch_annotate_files
743
+ async_batch_annotate_files_config = parent_rpcs.async_batch_annotate_files if parent_rpcs.respond_to? :async_batch_annotate_files
681
744
  @async_batch_annotate_files = ::Gapic::Config::Method.new async_batch_annotate_files_config
682
745
 
683
746
  yield self if block_given?
@@ -82,7 +82,7 @@ module Google
82
82
  # Create credentials
83
83
  credentials = @config.credentials
84
84
  credentials ||= Credentials.default scope: @config.scope
85
- if credentials.is_a?(String) || credentials.is_a?(Hash)
85
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
86
86
  credentials = Credentials.new credentials, scope: @config.scope
87
87
  end
88
88
  @quota_project_id = @config.quota_project
@@ -143,6 +143,27 @@ module Google
143
143
  #
144
144
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
145
145
  #
146
+ # @example Basic example
147
+ # require "google/longrunning"
148
+ #
149
+ # # Create a client object. The client can be reused for multiple calls.
150
+ # client = Google::Longrunning::Operations::Client.new
151
+ #
152
+ # # Create a request. To set request fields, pass in keyword arguments.
153
+ # request = Google::Longrunning::ListOperationsRequest.new
154
+ #
155
+ # # Call the list_operations method.
156
+ # result = client.list_operations request
157
+ #
158
+ # # The returned object is of type Gapic::PagedEnumerable. You can
159
+ # # iterate over all elements by calling #each, and the enumerable
160
+ # # will lazily make API calls to fetch subsequent pages. Other
161
+ # # methods are also available for managing paging directly.
162
+ # result.each do |response|
163
+ # # Each element is of type ::Google::Longrunning::Operation.
164
+ # p response
165
+ # end
166
+ #
146
167
  def list_operations request, options = nil
147
168
  raise ::ArgumentError, "request must be provided" if request.nil?
148
169
 
@@ -169,7 +190,9 @@ module Google
169
190
  options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
170
191
  metadata: metadata,
171
192
  retry_policy: @config.rpcs.list_operations.retry_policy
172
- options.apply_defaults metadata: @config.metadata,
193
+
194
+ options.apply_defaults timeout: @config.timeout,
195
+ metadata: @config.metadata,
173
196
  retry_policy: @config.retry_policy
174
197
 
175
198
  @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
@@ -213,6 +236,28 @@ module Google
213
236
  #
214
237
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
215
238
  #
239
+ # @example Basic example
240
+ # require "google/longrunning"
241
+ #
242
+ # # Create a client object. The client can be reused for multiple calls.
243
+ # client = Google::Longrunning::Operations::Client.new
244
+ #
245
+ # # Create a request. To set request fields, pass in keyword arguments.
246
+ # request = Google::Longrunning::GetOperationRequest.new
247
+ #
248
+ # # Call the get_operation method.
249
+ # result = client.get_operation request
250
+ #
251
+ # # The returned object is of type Gapic::Operation. You can use this
252
+ # # object to check the status of an operation, cancel it, or wait
253
+ # # for results. Here is how to block until completion:
254
+ # result.wait_until_done! timeout: 60
255
+ # if result.response?
256
+ # p result.response
257
+ # else
258
+ # puts "Error!"
259
+ # end
260
+ #
216
261
  def get_operation request, options = nil
217
262
  raise ::ArgumentError, "request must be provided" if request.nil?
218
263
 
@@ -239,7 +284,9 @@ module Google
239
284
  options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
240
285
  metadata: metadata,
241
286
  retry_policy: @config.rpcs.get_operation.retry_policy
242
- options.apply_defaults metadata: @config.metadata,
287
+
288
+ options.apply_defaults timeout: @config.timeout,
289
+ metadata: @config.metadata,
243
290
  retry_policy: @config.retry_policy
244
291
 
245
292
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
@@ -283,6 +330,21 @@ module Google
283
330
  #
284
331
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
285
332
  #
333
+ # @example Basic example
334
+ # require "google/longrunning"
335
+ #
336
+ # # Create a client object. The client can be reused for multiple calls.
337
+ # client = Google::Longrunning::Operations::Client.new
338
+ #
339
+ # # Create a request. To set request fields, pass in keyword arguments.
340
+ # request = Google::Longrunning::DeleteOperationRequest.new
341
+ #
342
+ # # Call the delete_operation method.
343
+ # result = client.delete_operation request
344
+ #
345
+ # # The returned object is of type Google::Protobuf::Empty.
346
+ # p result
347
+ #
286
348
  def delete_operation request, options = nil
287
349
  raise ::ArgumentError, "request must be provided" if request.nil?
288
350
 
@@ -309,7 +371,9 @@ module Google
309
371
  options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
310
372
  metadata: metadata,
311
373
  retry_policy: @config.rpcs.delete_operation.retry_policy
312
- options.apply_defaults metadata: @config.metadata,
374
+
375
+ options.apply_defaults timeout: @config.timeout,
376
+ metadata: @config.metadata,
313
377
  retry_policy: @config.retry_policy
314
378
 
315
379
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
@@ -358,6 +422,21 @@ module Google
358
422
  #
359
423
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
360
424
  #
425
+ # @example Basic example
426
+ # require "google/longrunning"
427
+ #
428
+ # # Create a client object. The client can be reused for multiple calls.
429
+ # client = Google::Longrunning::Operations::Client.new
430
+ #
431
+ # # Create a request. To set request fields, pass in keyword arguments.
432
+ # request = Google::Longrunning::CancelOperationRequest.new
433
+ #
434
+ # # Call the cancel_operation method.
435
+ # result = client.cancel_operation request
436
+ #
437
+ # # The returned object is of type Google::Protobuf::Empty.
438
+ # p result
439
+ #
361
440
  def cancel_operation request, options = nil
362
441
  raise ::ArgumentError, "request must be provided" if request.nil?
363
442
 
@@ -384,7 +463,9 @@ module Google
384
463
  options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
385
464
  metadata: metadata,
386
465
  retry_policy: @config.rpcs.cancel_operation.retry_policy
387
- options.apply_defaults metadata: @config.metadata,
466
+
467
+ options.apply_defaults timeout: @config.timeout,
468
+ metadata: @config.metadata,
388
469
  retry_policy: @config.retry_policy
389
470
 
390
471
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
@@ -396,9 +477,9 @@ module Google
396
477
  end
397
478
 
398
479
  ##
399
- # Waits for the specified long-running operation until it is done or reaches
400
- # at most a specified timeout, returning the latest state. If the operation
401
- # is already done, the latest state is immediately returned. If the timeout
480
+ # Waits until the specified long-running operation is done or reaches at most
481
+ # a specified timeout, returning the latest state. If the operation is
482
+ # already done, the latest state is immediately returned. If the timeout
402
483
  # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
484
  # timeout is used. If the server does not support this method, it returns
404
485
  # `google.rpc.Code.UNIMPLEMENTED`.
@@ -436,6 +517,28 @@ module Google
436
517
  #
437
518
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
519
  #
520
+ # @example Basic example
521
+ # require "google/longrunning"
522
+ #
523
+ # # Create a client object. The client can be reused for multiple calls.
524
+ # client = Google::Longrunning::Operations::Client.new
525
+ #
526
+ # # Create a request. To set request fields, pass in keyword arguments.
527
+ # request = Google::Longrunning::WaitOperationRequest.new
528
+ #
529
+ # # Call the wait_operation method.
530
+ # result = client.wait_operation request
531
+ #
532
+ # # The returned object is of type Gapic::Operation. You can use this
533
+ # # object to check the status of an operation, cancel it, or wait
534
+ # # for results. Here is how to block until completion:
535
+ # result.wait_until_done! timeout: 60
536
+ # if result.response?
537
+ # p result.response
538
+ # else
539
+ # puts "Error!"
540
+ # end
541
+ #
439
542
  def wait_operation request, options = nil
440
543
  raise ::ArgumentError, "request must be provided" if request.nil?
441
544
 
@@ -456,7 +559,9 @@ module Google
456
559
  options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
560
  metadata: metadata,
458
561
  retry_policy: @config.rpcs.wait_operation.retry_policy
459
- options.apply_defaults metadata: @config.metadata,
562
+
563
+ options.apply_defaults timeout: @config.timeout,
564
+ metadata: @config.metadata,
460
565
  retry_policy: @config.retry_policy
461
566
 
462
567
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
@@ -481,22 +586,21 @@ module Google
481
586
  # Configuration can be applied globally to all clients, or to a single client
482
587
  # on construction.
483
588
  #
484
- # # Examples
485
- #
486
- # To modify the global config, setting the timeout for list_operations
487
- # to 20 seconds, and all remaining timeouts to 10 seconds:
488
- #
489
- # ::Google::Longrunning::Operations::Client.configure do |config|
490
- # config.timeout = 10.0
491
- # config.rpcs.list_operations.timeout = 20.0
492
- # end
589
+ # @example
493
590
  #
494
- # To apply the above configuration only to a new client:
591
+ # # Modify the global config, setting the timeout for
592
+ # # list_operations to 20 seconds,
593
+ # # and all remaining timeouts to 10 seconds.
594
+ # ::Google::Longrunning::Operations::Client.configure do |config|
595
+ # config.timeout = 10.0
596
+ # config.rpcs.list_operations.timeout = 20.0
597
+ # end
495
598
  #
496
- # client = ::Google::Longrunning::Operations::Client.new do |config|
497
- # config.timeout = 10.0
498
- # config.rpcs.list_operations.timeout = 20.0
499
- # end
599
+ # # Apply the above configuration only to a new client.
600
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
601
+ # config.timeout = 10.0
602
+ # config.rpcs.list_operations.timeout = 20.0
603
+ # end
500
604
  #
501
605
  # @!attribute [rw] endpoint
502
606
  # The hostname or hostname:port of the service endpoint.
@@ -560,7 +664,7 @@ module Google
560
664
  config_attr :scope, nil, ::String, ::Array, nil
561
665
  config_attr :lib_name, nil, ::String, nil
562
666
  config_attr :lib_version, nil, ::String, nil
563
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
667
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
564
668
  config_attr :interceptors, nil, ::Array, nil
565
669
  config_attr :timeout, nil, ::Numeric, nil
566
670
  config_attr :metadata, nil, ::Hash, nil
@@ -581,7 +685,7 @@ module Google
581
685
  def rpcs
582
686
  @rpcs ||= begin
583
687
  parent_rpcs = nil
584
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
688
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
585
689
  Rpcs.new parent_rpcs
586
690
  end
587
691
  end
@@ -632,15 +736,15 @@ module Google
632
736
 
633
737
  # @private
634
738
  def initialize parent_rpcs = nil
635
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
739
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
636
740
  @list_operations = ::Gapic::Config::Method.new list_operations_config
637
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
741
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
638
742
  @get_operation = ::Gapic::Config::Method.new get_operation_config
639
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
743
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
640
744
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
641
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
745
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
642
746
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
- wait_operation_config = parent_rpcs&.wait_operation if parent_rpcs&.respond_to? :wait_operation
747
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
748
  @wait_operation = ::Gapic::Config::Method.new wait_operation_config
645
749
 
646
750
  yield self if block_given?