google-cloud-document_ai-v1beta3 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8de579b7a9ff1c66c2a433d059c8484f516b5f297a98f9e588ae2d944523435
4
- data.tar.gz: f0bd35e8ce2ebe2647d310822c3e0ffd77ccf56b0819df15dd41ea0722317c90
3
+ metadata.gz: ab99446e7d19cb1049e50c7a1d91fb1fd858c0070fd48434f54f6daff13732b1
4
+ data.tar.gz: 43ffc29fa13d848589abf71efcbdb926b284df4cc5cb1a1ec058057e3a175097
5
5
  SHA512:
6
- metadata.gz: a96931556cff97b33657f0efd386d80ff1cb32918c7d21f9f5c9fec3f0eb217ce33a7e4b15ddfa312d7ceb928c66f0c0acc70b192c079a90c83239d2411771bf
7
- data.tar.gz: 75ff0f64f9b58bf6121efacd53b1e5d0302acf339da499dce6b4f21d59e31df2c2e7a2468868ebe8b77dd97e3e7d91cff91bf85dbda49706fef999595a41d8e0
6
+ metadata.gz: 4c5ec313168396a2d69727d14768244830192ca3b5d3280ed66009b41b365018226996831542c28770c8a3ba7535d92f03bcf617742733386af6fe281b6f8ee3
7
+ data.tar.gz: 9f168ebbf2ec2e66466f6ff1ce69db277d3700a83f4563f8d2c4c37755d51c351a1bc6380fcdca7b161d767a200daec29ff13b2d81e2f7f9d1ad7d903d4b82e0
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/document-ai/docs)
44
44
  for general usage information.
45
45
 
46
- ## Enabling Logging
47
-
48
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
- or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest)
51
- that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
52
- and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
53
-
54
- Configuring a Ruby stdlib logger:
46
+ ## Debug Logging
47
+
48
+ This library comes with opt-in Debug Logging that can help you troubleshoot
49
+ your application's integration with the API. When logging is activated, key
50
+ events such as requests and responses, along with data payloads and metadata
51
+ such as headers and client configuration, are logged to the standard error
52
+ stream.
53
+
54
+ **WARNING:** Client Library Debug Logging includes your data payloads in
55
+ plaintext, which could include sensitive data such as PII for yourself or your
56
+ customers, private keys, or other security data that could be compromising if
57
+ leaked. Always practice good data hygiene with your application logs, and follow
58
+ the principle of least access. Google also recommends that Client Library Debug
59
+ Logging be enabled only temporarily during active debugging, and not used
60
+ permanently in production.
61
+
62
+ To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
63
+ to the value `all`. Alternatively, you can set the value to a comma-delimited
64
+ list of client library gem names. This will select the default logging behavior,
65
+ which writes logs to the standard error stream. On a local workstation, this may
66
+ result in logs appearing on the console. When running on a Google Cloud hosting
67
+ service such as [Google Cloud Run](https://cloud.google.com/run), this generally
68
+ results in logs appearing alongside your application logs in the
69
+ [Google Cloud Logging](https://cloud.google.com/logging/) service.
70
+
71
+ You can customize logging by modifying the `logger` configuration when
72
+ constructing a client object. For example:
55
73
 
56
74
  ```ruby
75
+ require "google/cloud/document_ai/v1beta3"
57
76
  require "logger"
58
77
 
59
- module MyLogger
60
- LOGGER = Logger.new $stderr, level: Logger::WARN
61
- def logger
62
- LOGGER
63
- end
64
- end
65
-
66
- # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
67
- module GRPC
68
- extend MyLogger
78
+ client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
79
+ config.logger = Logger.new "my-app.log"
69
80
  end
70
81
  ```
71
82
 
72
-
73
83
  ## Google Cloud Samples
74
84
 
75
85
  To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
@@ -76,17 +76,17 @@ module Google
76
76
 
77
77
  default_config.rpcs.process_document.timeout = 300.0
78
78
  default_config.rpcs.process_document.retry_policy = {
79
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
79
+ initial_delay: 1.0, max_delay: 90.0, multiplier: 9.0, retry_codes: [4, 14, 8]
80
80
  }
81
81
 
82
82
  default_config.rpcs.batch_process_documents.timeout = 120.0
83
83
  default_config.rpcs.batch_process_documents.retry_policy = {
84
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
84
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.5, retry_codes: [4, 14]
85
85
  }
86
86
 
87
87
  default_config.rpcs.review_document.timeout = 120.0
88
88
  default_config.rpcs.review_document.retry_policy = {
89
- initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
89
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.5, retry_codes: [4, 14]
90
90
  }
91
91
 
92
92
  default_config
@@ -183,14 +183,26 @@ module Google
183
183
  universe_domain: @config.universe_domain,
184
184
  channel_args: @config.channel_args,
185
185
  interceptors: @config.interceptors,
186
- channel_pool_config: @config.channel_pool
186
+ channel_pool_config: @config.channel_pool,
187
+ logger: @config.logger
187
188
  )
188
189
 
190
+ @document_processor_service_stub.stub_logger&.info do |entry|
191
+ entry.set_system_name
192
+ entry.set_service
193
+ entry.message = "Created client for #{entry.service}"
194
+ entry.set_credentials_fields credentials
195
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
196
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
197
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
198
+ end
199
+
189
200
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
190
201
  config.credentials = credentials
191
202
  config.quota_project = @quota_project_id
192
203
  config.endpoint = @document_processor_service_stub.endpoint
193
204
  config.universe_domain = @document_processor_service_stub.universe_domain
205
+ config.logger = @document_processor_service_stub.logger if config.respond_to? :logger=
194
206
  end
195
207
  end
196
208
 
@@ -208,6 +220,15 @@ module Google
208
220
  #
209
221
  attr_reader :location_client
210
222
 
223
+ ##
224
+ # The logger used for request/response debug logging.
225
+ #
226
+ # @return [Logger]
227
+ #
228
+ def logger
229
+ @document_processor_service_stub.logger
230
+ end
231
+
211
232
  # Service calls
212
233
 
213
234
  ##
@@ -329,7 +350,6 @@ module Google
329
350
 
330
351
  @document_processor_service_stub.call_rpc :process_document, request, options: options do |response, operation|
331
352
  yield response, operation if block_given?
332
- return response
333
353
  end
334
354
  rescue ::GRPC::BadStatus => e
335
355
  raise ::Google::Cloud::Error.from_error(e)
@@ -453,7 +473,7 @@ module Google
453
473
  @document_processor_service_stub.call_rpc :batch_process_documents, request, options: options do |response, operation|
454
474
  response = ::Gapic::Operation.new response, @operations_client, options: options
455
475
  yield response, operation if block_given?
456
- return response
476
+ throw :response, response
457
477
  end
458
478
  rescue ::GRPC::BadStatus => e
459
479
  raise ::Google::Cloud::Error.from_error(e)
@@ -542,7 +562,6 @@ module Google
542
562
 
543
563
  @document_processor_service_stub.call_rpc :fetch_processor_types, request, options: options do |response, operation|
544
564
  yield response, operation if block_given?
545
- return response
546
565
  end
547
566
  rescue ::GRPC::BadStatus => e
548
567
  raise ::Google::Cloud::Error.from_error(e)
@@ -640,7 +659,7 @@ module Google
640
659
  @document_processor_service_stub.call_rpc :list_processor_types, request, options: options do |response, operation|
641
660
  response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processor_types, request, response, operation, options
642
661
  yield response, operation if block_given?
643
- return response
662
+ throw :response, response
644
663
  end
645
664
  rescue ::GRPC::BadStatus => e
646
665
  raise ::Google::Cloud::Error.from_error(e)
@@ -726,7 +745,6 @@ module Google
726
745
 
727
746
  @document_processor_service_stub.call_rpc :get_processor_type, request, options: options do |response, operation|
728
747
  yield response, operation if block_given?
729
- return response
730
748
  end
731
749
  rescue ::GRPC::BadStatus => e
732
750
  raise ::Google::Cloud::Error.from_error(e)
@@ -825,7 +843,7 @@ module Google
825
843
  @document_processor_service_stub.call_rpc :list_processors, request, options: options do |response, operation|
826
844
  response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processors, request, response, operation, options
827
845
  yield response, operation if block_given?
828
- return response
846
+ throw :response, response
829
847
  end
830
848
  rescue ::GRPC::BadStatus => e
831
849
  raise ::Google::Cloud::Error.from_error(e)
@@ -911,7 +929,6 @@ module Google
911
929
 
912
930
  @document_processor_service_stub.call_rpc :get_processor, request, options: options do |response, operation|
913
931
  yield response, operation if block_given?
914
- return response
915
932
  end
916
933
  rescue ::GRPC::BadStatus => e
917
934
  raise ::Google::Cloud::Error.from_error(e)
@@ -1024,7 +1041,7 @@ module Google
1024
1041
  @document_processor_service_stub.call_rpc :train_processor_version, request, options: options do |response, operation|
1025
1042
  response = ::Gapic::Operation.new response, @operations_client, options: options
1026
1043
  yield response, operation if block_given?
1027
- return response
1044
+ throw :response, response
1028
1045
  end
1029
1046
  rescue ::GRPC::BadStatus => e
1030
1047
  raise ::Google::Cloud::Error.from_error(e)
@@ -1110,7 +1127,6 @@ module Google
1110
1127
 
1111
1128
  @document_processor_service_stub.call_rpc :get_processor_version, request, options: options do |response, operation|
1112
1129
  yield response, operation if block_given?
1113
- return response
1114
1130
  end
1115
1131
  rescue ::GRPC::BadStatus => e
1116
1132
  raise ::Google::Cloud::Error.from_error(e)
@@ -1210,7 +1226,7 @@ module Google
1210
1226
  @document_processor_service_stub.call_rpc :list_processor_versions, request, options: options do |response, operation|
1211
1227
  response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processor_versions, request, response, operation, options
1212
1228
  yield response, operation if block_given?
1213
- return response
1229
+ throw :response, response
1214
1230
  end
1215
1231
  rescue ::GRPC::BadStatus => e
1216
1232
  raise ::Google::Cloud::Error.from_error(e)
@@ -1305,7 +1321,7 @@ module Google
1305
1321
  @document_processor_service_stub.call_rpc :delete_processor_version, request, options: options do |response, operation|
1306
1322
  response = ::Gapic::Operation.new response, @operations_client, options: options
1307
1323
  yield response, operation if block_given?
1308
- return response
1324
+ throw :response, response
1309
1325
  end
1310
1326
  rescue ::GRPC::BadStatus => e
1311
1327
  raise ::Google::Cloud::Error.from_error(e)
@@ -1399,7 +1415,7 @@ module Google
1399
1415
  @document_processor_service_stub.call_rpc :deploy_processor_version, request, options: options do |response, operation|
1400
1416
  response = ::Gapic::Operation.new response, @operations_client, options: options
1401
1417
  yield response, operation if block_given?
1402
- return response
1418
+ throw :response, response
1403
1419
  end
1404
1420
  rescue ::GRPC::BadStatus => e
1405
1421
  raise ::Google::Cloud::Error.from_error(e)
@@ -1493,7 +1509,7 @@ module Google
1493
1509
  @document_processor_service_stub.call_rpc :undeploy_processor_version, request, options: options do |response, operation|
1494
1510
  response = ::Gapic::Operation.new response, @operations_client, options: options
1495
1511
  yield response, operation if block_given?
1496
- return response
1512
+ throw :response, response
1497
1513
  end
1498
1514
  rescue ::GRPC::BadStatus => e
1499
1515
  raise ::Google::Cloud::Error.from_error(e)
@@ -1593,7 +1609,6 @@ module Google
1593
1609
 
1594
1610
  @document_processor_service_stub.call_rpc :create_processor, request, options: options do |response, operation|
1595
1611
  yield response, operation if block_given?
1596
- return response
1597
1612
  end
1598
1613
  rescue ::GRPC::BadStatus => e
1599
1614
  raise ::Google::Cloud::Error.from_error(e)
@@ -1688,7 +1703,7 @@ module Google
1688
1703
  @document_processor_service_stub.call_rpc :delete_processor, request, options: options do |response, operation|
1689
1704
  response = ::Gapic::Operation.new response, @operations_client, options: options
1690
1705
  yield response, operation if block_given?
1691
- return response
1706
+ throw :response, response
1692
1707
  end
1693
1708
  rescue ::GRPC::BadStatus => e
1694
1709
  raise ::Google::Cloud::Error.from_error(e)
@@ -1782,7 +1797,7 @@ module Google
1782
1797
  @document_processor_service_stub.call_rpc :enable_processor, request, options: options do |response, operation|
1783
1798
  response = ::Gapic::Operation.new response, @operations_client, options: options
1784
1799
  yield response, operation if block_given?
1785
- return response
1800
+ throw :response, response
1786
1801
  end
1787
1802
  rescue ::GRPC::BadStatus => e
1788
1803
  raise ::Google::Cloud::Error.from_error(e)
@@ -1876,7 +1891,7 @@ module Google
1876
1891
  @document_processor_service_stub.call_rpc :disable_processor, request, options: options do |response, operation|
1877
1892
  response = ::Gapic::Operation.new response, @operations_client, options: options
1878
1893
  yield response, operation if block_given?
1879
- return response
1894
+ throw :response, response
1880
1895
  end
1881
1896
  rescue ::GRPC::BadStatus => e
1882
1897
  raise ::Google::Cloud::Error.from_error(e)
@@ -1981,7 +1996,7 @@ module Google
1981
1996
  @document_processor_service_stub.call_rpc :set_default_processor_version, request, options: options do |response, operation|
1982
1997
  response = ::Gapic::Operation.new response, @operations_client, options: options
1983
1998
  yield response, operation if block_given?
1984
- return response
1999
+ throw :response, response
1985
2000
  end
1986
2001
  rescue ::GRPC::BadStatus => e
1987
2002
  raise ::Google::Cloud::Error.from_error(e)
@@ -2088,7 +2103,7 @@ module Google
2088
2103
  @document_processor_service_stub.call_rpc :review_document, request, options: options do |response, operation|
2089
2104
  response = ::Gapic::Operation.new response, @operations_client, options: options
2090
2105
  yield response, operation if block_given?
2091
- return response
2106
+ throw :response, response
2092
2107
  end
2093
2108
  rescue ::GRPC::BadStatus => e
2094
2109
  raise ::Google::Cloud::Error.from_error(e)
@@ -2189,7 +2204,7 @@ module Google
2189
2204
  @document_processor_service_stub.call_rpc :evaluate_processor_version, request, options: options do |response, operation|
2190
2205
  response = ::Gapic::Operation.new response, @operations_client, options: options
2191
2206
  yield response, operation if block_given?
2192
- return response
2207
+ throw :response, response
2193
2208
  end
2194
2209
  rescue ::GRPC::BadStatus => e
2195
2210
  raise ::Google::Cloud::Error.from_error(e)
@@ -2277,7 +2292,6 @@ module Google
2277
2292
 
2278
2293
  @document_processor_service_stub.call_rpc :get_evaluation, request, options: options do |response, operation|
2279
2294
  yield response, operation if block_given?
2280
- return response
2281
2295
  end
2282
2296
  rescue ::GRPC::BadStatus => e
2283
2297
  raise ::Google::Cloud::Error.from_error(e)
@@ -2378,7 +2392,7 @@ module Google
2378
2392
  @document_processor_service_stub.call_rpc :list_evaluations, request, options: options do |response, operation|
2379
2393
  response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_evaluations, request, response, operation, options
2380
2394
  yield response, operation if block_given?
2381
- return response
2395
+ throw :response, response
2382
2396
  end
2383
2397
  rescue ::GRPC::BadStatus => e
2384
2398
  raise ::Google::Cloud::Error.from_error(e)
@@ -2482,7 +2496,7 @@ module Google
2482
2496
  @document_processor_service_stub.call_rpc :import_processor_version, request, options: options do |response, operation|
2483
2497
  response = ::Gapic::Operation.new response, @operations_client, options: options
2484
2498
  yield response, operation if block_given?
2485
- return response
2499
+ throw :response, response
2486
2500
  end
2487
2501
  rescue ::GRPC::BadStatus => e
2488
2502
  raise ::Google::Cloud::Error.from_error(e)
@@ -2571,6 +2585,11 @@ module Google
2571
2585
  # default endpoint URL. The default value of nil uses the environment
2572
2586
  # universe (usually the default "googleapis.com" universe).
2573
2587
  # @return [::String,nil]
2588
+ # @!attribute [rw] logger
2589
+ # A custom logger to use for request/response debug logging, or the value
2590
+ # `:default` (the default) to construct a default logger, or `nil` to
2591
+ # explicitly disable logging.
2592
+ # @return [::Logger,:default,nil]
2574
2593
  #
2575
2594
  class Configuration
2576
2595
  extend ::Gapic::Config
@@ -2595,6 +2614,7 @@ module Google
2595
2614
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2596
2615
  config_attr :quota_project, nil, ::String, nil
2597
2616
  config_attr :universe_domain, nil, ::String, nil
2617
+ config_attr :logger, :default, ::Logger, nil, :default
2598
2618
 
2599
2619
  # @private
2600
2620
  def initialize parent_config = nil
@@ -124,14 +124,6 @@ module Google
124
124
  # Lists operations that match the specified filter in the request. If the
125
125
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
126
126
  #
127
- # NOTE: the `name` binding allows API services to override the binding
128
- # to use different resource name schemes, such as `users/*/operations`. To
129
- # override the binding, API services can add a binding such as
130
- # `"/v1/{name=users/*}/operations"` to their service configuration.
131
- # For backwards compatibility, the default name includes the operations
132
- # collection id, however overriding users must ensure the name binding
133
- # is the parent resource, without the operations collection id.
134
- #
135
127
  # @overload list_operations(request, options = nil)
136
128
  # Pass arguments to `list_operations` via a request object, either of type
137
129
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -221,7 +213,7 @@ module Google
221
213
  wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
222
214
  response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
223
215
  yield response, operation if block_given?
224
- return response
216
+ throw :response, response
225
217
  end
226
218
  rescue ::GRPC::BadStatus => e
227
219
  raise ::Google::Cloud::Error.from_error(e)
@@ -317,7 +309,7 @@ module Google
317
309
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
318
310
  response = ::Gapic::Operation.new response, @operations_client, options: options
319
311
  yield response, operation if block_given?
320
- return response
312
+ throw :response, response
321
313
  end
322
314
  rescue ::GRPC::BadStatus => e
323
315
  raise ::Google::Cloud::Error.from_error(e)
@@ -406,7 +398,6 @@ module Google
406
398
 
407
399
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
408
400
  yield response, operation if block_given?
409
- return response
410
401
  end
411
402
  rescue ::GRPC::BadStatus => e
412
403
  raise ::Google::Cloud::Error.from_error(e)
@@ -421,8 +412,9 @@ module Google
421
412
  # other methods to check whether the cancellation succeeded or whether the
422
413
  # operation completed despite cancellation. On successful cancellation,
423
414
  # the operation is not deleted; instead, it becomes an operation with
424
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
425
- # corresponding to `Code.CANCELLED`.
415
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
416
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
417
+ # `Code.CANCELLED`.
426
418
  #
427
419
  # @overload cancel_operation(request, options = nil)
428
420
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -501,7 +493,6 @@ module Google
501
493
 
502
494
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
503
495
  yield response, operation if block_given?
504
- return response
505
496
  end
506
497
  rescue ::GRPC::BadStatus => e
507
498
  raise ::Google::Cloud::Error.from_error(e)
@@ -599,7 +590,7 @@ module Google
599
590
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
600
591
  response = ::Gapic::Operation.new response, @operations_client, options: options
601
592
  yield response, operation if block_given?
602
- return response
593
+ throw :response, response
603
594
  end
604
595
  rescue ::GRPC::BadStatus => e
605
596
  raise ::Google::Cloud::Error.from_error(e)
@@ -688,6 +679,11 @@ module Google
688
679
  # default endpoint URL. The default value of nil uses the environment
689
680
  # universe (usually the default "googleapis.com" universe).
690
681
  # @return [::String,nil]
682
+ # @!attribute [rw] logger
683
+ # A custom logger to use for request/response debug logging, or the value
684
+ # `:default` (the default) to construct a default logger, or `nil` to
685
+ # explicitly disable logging.
686
+ # @return [::Logger,:default,nil]
691
687
  #
692
688
  class Configuration
693
689
  extend ::Gapic::Config
@@ -712,6 +708,7 @@ module Google
712
708
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
713
709
  config_attr :quota_project, nil, ::String, nil
714
710
  config_attr :universe_domain, nil, ::String, nil
711
+ config_attr :logger, :default, ::Logger, nil, :default
715
712
 
716
713
  # @private
717
714
  def initialize parent_config = nil