google-cloud-document_ai-v1beta3 0.36.1 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -78,17 +78,17 @@ module Google
78
78
 
79
79
  default_config.rpcs.process_document.timeout = 300.0
80
80
  default_config.rpcs.process_document.retry_policy = {
81
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
81
+ initial_delay: 1.0, max_delay: 90.0, multiplier: 9.0, retry_codes: [4, 14, 8]
82
82
  }
83
83
 
84
84
  default_config.rpcs.batch_process_documents.timeout = 120.0
85
85
  default_config.rpcs.batch_process_documents.retry_policy = {
86
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
86
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.5, retry_codes: [4, 14]
87
87
  }
88
88
 
89
89
  default_config.rpcs.review_document.timeout = 120.0
90
90
  default_config.rpcs.review_document.retry_policy = {
91
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
91
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.5, retry_codes: [4, 14]
92
92
  }
93
93
 
94
94
  default_config
@@ -176,15 +176,27 @@ module Google
176
176
  endpoint: @config.endpoint,
177
177
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
178
178
  universe_domain: @config.universe_domain,
179
- credentials: credentials
179
+ credentials: credentials,
180
+ logger: @config.logger
180
181
  )
181
182
 
183
+ @document_processor_service_stub.logger(stub: true)&.info do |entry|
184
+ entry.set_system_name
185
+ entry.set_service
186
+ entry.message = "Created client for #{entry.service}"
187
+ entry.set_credentials_fields credentials
188
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
189
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
190
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
191
+ end
192
+
182
193
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
183
194
  config.credentials = credentials
184
195
  config.quota_project = @quota_project_id
185
196
  config.endpoint = @document_processor_service_stub.endpoint
186
197
  config.universe_domain = @document_processor_service_stub.universe_domain
187
198
  config.bindings_override = @config.bindings_override
199
+ config.logger = @document_processor_service_stub.logger if config.respond_to? :logger=
188
200
  end
189
201
  end
190
202
 
@@ -202,6 +214,15 @@ module Google
202
214
  #
203
215
  attr_reader :location_client
204
216
 
217
+ ##
218
+ # The logger used for request/response debug logging.
219
+ #
220
+ # @return [Logger]
221
+ #
222
+ def logger
223
+ @document_processor_service_stub.logger
224
+ end
225
+
205
226
  # Service calls
206
227
 
207
228
  ##
@@ -316,7 +337,6 @@ module Google
316
337
 
317
338
  @document_processor_service_stub.process_document request, options do |result, operation|
318
339
  yield result, operation if block_given?
319
- return result
320
340
  end
321
341
  rescue ::Gapic::Rest::Error => e
322
342
  raise ::Google::Cloud::Error.from_error(e)
@@ -433,7 +453,7 @@ module Google
433
453
  @document_processor_service_stub.batch_process_documents request, options do |result, operation|
434
454
  result = ::Gapic::Operation.new result, @operations_client, options: options
435
455
  yield result, operation if block_given?
436
- return result
456
+ throw :response, result
437
457
  end
438
458
  rescue ::Gapic::Rest::Error => e
439
459
  raise ::Google::Cloud::Error.from_error(e)
@@ -515,7 +535,6 @@ module Google
515
535
 
516
536
  @document_processor_service_stub.fetch_processor_types request, options do |result, operation|
517
537
  yield result, operation if block_given?
518
- return result
519
538
  end
520
539
  rescue ::Gapic::Rest::Error => e
521
540
  raise ::Google::Cloud::Error.from_error(e)
@@ -606,7 +625,7 @@ module Google
606
625
  @document_processor_service_stub.list_processor_types request, options do |result, operation|
607
626
  result = ::Gapic::Rest::PagedEnumerable.new @document_processor_service_stub, :list_processor_types, "processor_types", request, result, options
608
627
  yield result, operation if block_given?
609
- return result
628
+ throw :response, result
610
629
  end
611
630
  rescue ::Gapic::Rest::Error => e
612
631
  raise ::Google::Cloud::Error.from_error(e)
@@ -685,7 +704,6 @@ module Google
685
704
 
686
705
  @document_processor_service_stub.get_processor_type request, options do |result, operation|
687
706
  yield result, operation if block_given?
688
- return result
689
707
  end
690
708
  rescue ::Gapic::Rest::Error => e
691
709
  raise ::Google::Cloud::Error.from_error(e)
@@ -777,7 +795,7 @@ module Google
777
795
  @document_processor_service_stub.list_processors request, options do |result, operation|
778
796
  result = ::Gapic::Rest::PagedEnumerable.new @document_processor_service_stub, :list_processors, "processors", request, result, options
779
797
  yield result, operation if block_given?
780
- return result
798
+ throw :response, result
781
799
  end
782
800
  rescue ::Gapic::Rest::Error => e
783
801
  raise ::Google::Cloud::Error.from_error(e)
@@ -856,7 +874,6 @@ module Google
856
874
 
857
875
  @document_processor_service_stub.get_processor request, options do |result, operation|
858
876
  yield result, operation if block_given?
859
- return result
860
877
  end
861
878
  rescue ::Gapic::Rest::Error => e
862
879
  raise ::Google::Cloud::Error.from_error(e)
@@ -962,7 +979,7 @@ module Google
962
979
  @document_processor_service_stub.train_processor_version request, options do |result, operation|
963
980
  result = ::Gapic::Operation.new result, @operations_client, options: options
964
981
  yield result, operation if block_given?
965
- return result
982
+ throw :response, result
966
983
  end
967
984
  rescue ::Gapic::Rest::Error => e
968
985
  raise ::Google::Cloud::Error.from_error(e)
@@ -1041,7 +1058,6 @@ module Google
1041
1058
 
1042
1059
  @document_processor_service_stub.get_processor_version request, options do |result, operation|
1043
1060
  yield result, operation if block_given?
1044
- return result
1045
1061
  end
1046
1062
  rescue ::Gapic::Rest::Error => e
1047
1063
  raise ::Google::Cloud::Error.from_error(e)
@@ -1134,7 +1150,7 @@ module Google
1134
1150
  @document_processor_service_stub.list_processor_versions request, options do |result, operation|
1135
1151
  result = ::Gapic::Rest::PagedEnumerable.new @document_processor_service_stub, :list_processor_versions, "processor_versions", request, result, options
1136
1152
  yield result, operation if block_given?
1137
- return result
1153
+ throw :response, result
1138
1154
  end
1139
1155
  rescue ::Gapic::Rest::Error => e
1140
1156
  raise ::Google::Cloud::Error.from_error(e)
@@ -1222,7 +1238,7 @@ module Google
1222
1238
  @document_processor_service_stub.delete_processor_version request, options do |result, operation|
1223
1239
  result = ::Gapic::Operation.new result, @operations_client, options: options
1224
1240
  yield result, operation if block_given?
1225
- return result
1241
+ throw :response, result
1226
1242
  end
1227
1243
  rescue ::Gapic::Rest::Error => e
1228
1244
  raise ::Google::Cloud::Error.from_error(e)
@@ -1309,7 +1325,7 @@ module Google
1309
1325
  @document_processor_service_stub.deploy_processor_version request, options do |result, operation|
1310
1326
  result = ::Gapic::Operation.new result, @operations_client, options: options
1311
1327
  yield result, operation if block_given?
1312
- return result
1328
+ throw :response, result
1313
1329
  end
1314
1330
  rescue ::Gapic::Rest::Error => e
1315
1331
  raise ::Google::Cloud::Error.from_error(e)
@@ -1396,7 +1412,7 @@ module Google
1396
1412
  @document_processor_service_stub.undeploy_processor_version request, options do |result, operation|
1397
1413
  result = ::Gapic::Operation.new result, @operations_client, options: options
1398
1414
  yield result, operation if block_given?
1399
- return result
1415
+ throw :response, result
1400
1416
  end
1401
1417
  rescue ::Gapic::Rest::Error => e
1402
1418
  raise ::Google::Cloud::Error.from_error(e)
@@ -1489,7 +1505,6 @@ module Google
1489
1505
 
1490
1506
  @document_processor_service_stub.create_processor request, options do |result, operation|
1491
1507
  yield result, operation if block_given?
1492
- return result
1493
1508
  end
1494
1509
  rescue ::Gapic::Rest::Error => e
1495
1510
  raise ::Google::Cloud::Error.from_error(e)
@@ -1577,7 +1592,7 @@ module Google
1577
1592
  @document_processor_service_stub.delete_processor request, options do |result, operation|
1578
1593
  result = ::Gapic::Operation.new result, @operations_client, options: options
1579
1594
  yield result, operation if block_given?
1580
- return result
1595
+ throw :response, result
1581
1596
  end
1582
1597
  rescue ::Gapic::Rest::Error => e
1583
1598
  raise ::Google::Cloud::Error.from_error(e)
@@ -1664,7 +1679,7 @@ module Google
1664
1679
  @document_processor_service_stub.enable_processor request, options do |result, operation|
1665
1680
  result = ::Gapic::Operation.new result, @operations_client, options: options
1666
1681
  yield result, operation if block_given?
1667
- return result
1682
+ throw :response, result
1668
1683
  end
1669
1684
  rescue ::Gapic::Rest::Error => e
1670
1685
  raise ::Google::Cloud::Error.from_error(e)
@@ -1751,7 +1766,7 @@ module Google
1751
1766
  @document_processor_service_stub.disable_processor request, options do |result, operation|
1752
1767
  result = ::Gapic::Operation.new result, @operations_client, options: options
1753
1768
  yield result, operation if block_given?
1754
- return result
1769
+ throw :response, result
1755
1770
  end
1756
1771
  rescue ::Gapic::Rest::Error => e
1757
1772
  raise ::Google::Cloud::Error.from_error(e)
@@ -1849,7 +1864,7 @@ module Google
1849
1864
  @document_processor_service_stub.set_default_processor_version request, options do |result, operation|
1850
1865
  result = ::Gapic::Operation.new result, @operations_client, options: options
1851
1866
  yield result, operation if block_given?
1852
- return result
1867
+ throw :response, result
1853
1868
  end
1854
1869
  rescue ::Gapic::Rest::Error => e
1855
1870
  raise ::Google::Cloud::Error.from_error(e)
@@ -1949,7 +1964,7 @@ module Google
1949
1964
  @document_processor_service_stub.review_document request, options do |result, operation|
1950
1965
  result = ::Gapic::Operation.new result, @operations_client, options: options
1951
1966
  yield result, operation if block_given?
1952
- return result
1967
+ throw :response, result
1953
1968
  end
1954
1969
  rescue ::Gapic::Rest::Error => e
1955
1970
  raise ::Google::Cloud::Error.from_error(e)
@@ -2043,7 +2058,7 @@ module Google
2043
2058
  @document_processor_service_stub.evaluate_processor_version request, options do |result, operation|
2044
2059
  result = ::Gapic::Operation.new result, @operations_client, options: options
2045
2060
  yield result, operation if block_given?
2046
- return result
2061
+ throw :response, result
2047
2062
  end
2048
2063
  rescue ::Gapic::Rest::Error => e
2049
2064
  raise ::Google::Cloud::Error.from_error(e)
@@ -2124,7 +2139,6 @@ module Google
2124
2139
 
2125
2140
  @document_processor_service_stub.get_evaluation request, options do |result, operation|
2126
2141
  yield result, operation if block_given?
2127
- return result
2128
2142
  end
2129
2143
  rescue ::Gapic::Rest::Error => e
2130
2144
  raise ::Google::Cloud::Error.from_error(e)
@@ -2218,7 +2232,7 @@ module Google
2218
2232
  @document_processor_service_stub.list_evaluations request, options do |result, operation|
2219
2233
  result = ::Gapic::Rest::PagedEnumerable.new @document_processor_service_stub, :list_evaluations, "evaluations", request, result, options
2220
2234
  yield result, operation if block_given?
2221
- return result
2235
+ throw :response, result
2222
2236
  end
2223
2237
  rescue ::Gapic::Rest::Error => e
2224
2238
  raise ::Google::Cloud::Error.from_error(e)
@@ -2315,7 +2329,7 @@ module Google
2315
2329
  @document_processor_service_stub.import_processor_version request, options do |result, operation|
2316
2330
  result = ::Gapic::Operation.new result, @operations_client, options: options
2317
2331
  yield result, operation if block_given?
2318
- return result
2332
+ throw :response, result
2319
2333
  end
2320
2334
  rescue ::Gapic::Rest::Error => e
2321
2335
  raise ::Google::Cloud::Error.from_error(e)
@@ -2395,6 +2409,11 @@ module Google
2395
2409
  # default endpoint URL. The default value of nil uses the environment
2396
2410
  # universe (usually the default "googleapis.com" universe).
2397
2411
  # @return [::String,nil]
2412
+ # @!attribute [rw] logger
2413
+ # A custom logger to use for request/response debug logging, or the value
2414
+ # `:default` (the default) to construct a default logger, or `nil` to
2415
+ # explicitly disable logging.
2416
+ # @return [::Logger,:default,nil]
2398
2417
  #
2399
2418
  class Configuration
2400
2419
  extend ::Gapic::Config
@@ -2423,6 +2442,7 @@ module Google
2423
2442
  # by the host service.
2424
2443
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2425
2444
  config_attr :bindings_override, {}, ::Hash, nil
2445
+ config_attr :logger, :default, ::Logger, nil, :default
2426
2446
 
2427
2447
  # @private
2428
2448
  def initialize parent_config = nil
@@ -115,14 +115,6 @@ module Google
115
115
  # Lists operations that match the specified filter in the request. If the
116
116
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
117
117
  #
118
- # NOTE: the `name` binding allows API services to override the binding
119
- # to use different resource name schemes, such as `users/*/operations`. To
120
- # override the binding, API services can add a binding such as
121
- # `"/v1/{name=users/*}/operations"` to their service configuration.
122
- # For backwards compatibility, the default name includes the operations
123
- # collection id, however overriding users must ensure the name binding
124
- # is the parent resource, without the operations collection id.
125
- #
126
118
  # @overload list_operations(request, options = nil)
127
119
  # Pass arguments to `list_operations` via a request object, either of type
128
120
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -204,7 +196,7 @@ module Google
204
196
  @operations_stub.list_operations request, options do |result, operation|
205
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
206
198
  yield result, operation if block_given?
207
- return result
199
+ throw :response, result
208
200
  end
209
201
  rescue ::Gapic::Rest::Error => e
210
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -293,7 +285,7 @@ module Google
293
285
  @operations_stub.get_operation request, options do |result, operation|
294
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
295
287
  yield result, operation if block_given?
296
- return result
288
+ throw :response, result
297
289
  end
298
290
  rescue ::Gapic::Rest::Error => e
299
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -375,7 +367,6 @@ module Google
375
367
 
376
368
  @operations_stub.delete_operation request, options do |result, operation|
377
369
  yield result, operation if block_given?
378
- return result
379
370
  end
380
371
  rescue ::Gapic::Rest::Error => e
381
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -390,8 +381,9 @@ module Google
390
381
  # other methods to check whether the cancellation succeeded or whether the
391
382
  # operation completed despite cancellation. On successful cancellation,
392
383
  # the operation is not deleted; instead, it becomes an operation with
393
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
394
- # corresponding to `Code.CANCELLED`.
384
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
385
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
386
+ # `Code.CANCELLED`.
395
387
  #
396
388
  # @overload cancel_operation(request, options = nil)
397
389
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -463,7 +455,6 @@ module Google
463
455
 
464
456
  @operations_stub.cancel_operation request, options do |result, operation|
465
457
  yield result, operation if block_given?
466
- return result
467
458
  end
468
459
  rescue ::Gapic::Rest::Error => e
469
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -543,6 +534,11 @@ module Google
543
534
  # default endpoint URL. The default value of nil uses the environment
544
535
  # universe (usually the default "googleapis.com" universe).
545
536
  # @return [::String,nil]
537
+ # @!attribute [rw] logger
538
+ # A custom logger to use for request/response debug logging, or the value
539
+ # `:default` (the default) to construct a default logger, or `nil` to
540
+ # explicitly disable logging.
541
+ # @return [::Logger,:default,nil]
546
542
  #
547
543
  class Configuration
548
544
  extend ::Gapic::Config
@@ -564,6 +560,7 @@ module Google
564
560
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
565
561
  config_attr :quota_project, nil, ::String, nil
566
562
  config_attr :universe_domain, nil, ::String, nil
563
+ config_attr :logger, :default, ::Logger, nil, :default
567
564
 
568
565
  # @private
569
566
  def initialize parent_config = nil
@@ -683,16 +680,18 @@ module Google
683
680
 
684
681
  response = @client_stub.make_http_request(
685
682
  verb,
686
- uri: uri,
687
- body: body || "",
688
- params: query_string_params,
683
+ uri: uri,
684
+ body: body || "",
685
+ params: query_string_params,
686
+ method_name: "list_operations",
689
687
  options: options
690
688
  )
691
689
  operation = ::Gapic::Rest::TransportOperation.new response
692
690
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
693
-
694
- yield result, operation if block_given?
695
- result
691
+ catch :response do
692
+ yield result, operation if block_given?
693
+ result
694
+ end
696
695
  end
697
696
 
698
697
  ##
@@ -721,16 +720,18 @@ module Google
721
720
 
722
721
  response = @client_stub.make_http_request(
723
722
  verb,
724
- uri: uri,
725
- body: body || "",
726
- params: query_string_params,
723
+ uri: uri,
724
+ body: body || "",
725
+ params: query_string_params,
726
+ method_name: "get_operation",
727
727
  options: options
728
728
  )
729
729
  operation = ::Gapic::Rest::TransportOperation.new response
730
730
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
731
-
732
- yield result, operation if block_given?
733
- result
731
+ catch :response do
732
+ yield result, operation if block_given?
733
+ result
734
+ end
734
735
  end
735
736
 
736
737
  ##
@@ -759,16 +760,18 @@ module Google
759
760
 
760
761
  response = @client_stub.make_http_request(
761
762
  verb,
762
- uri: uri,
763
- body: body || "",
764
- params: query_string_params,
763
+ uri: uri,
764
+ body: body || "",
765
+ params: query_string_params,
766
+ method_name: "delete_operation",
765
767
  options: options
766
768
  )
767
769
  operation = ::Gapic::Rest::TransportOperation.new response
768
770
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
769
-
770
- yield result, operation if block_given?
771
- result
771
+ catch :response do
772
+ yield result, operation if block_given?
773
+ result
774
+ end
772
775
  end
773
776
 
774
777
  ##
@@ -797,16 +800,18 @@ module Google
797
800
 
798
801
  response = @client_stub.make_http_request(
799
802
  verb,
800
- uri: uri,
801
- body: body || "",
802
- params: query_string_params,
803
+ uri: uri,
804
+ body: body || "",
805
+ params: query_string_params,
806
+ method_name: "cancel_operation",
803
807
  options: options
804
808
  )
805
809
  operation = ::Gapic::Rest::TransportOperation.new response
806
810
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
807
-
808
- yield result, operation if block_given?
809
- result
811
+ catch :response do
812
+ yield result, operation if block_given?
813
+ result
814
+ end
810
815
  end
811
816
 
812
817
  ##