google-cloud-speech-v2 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e71b10b5509a21133736a96a709c9611a19b386c65a21d18f5beed55c676c378
4
- data.tar.gz: 40ca64ebc4b35368af8f36c8b0a87560af61fd26d5da6637941424d0fd7854c9
3
+ metadata.gz: 4d7575ab1537c60b4502342a5a43468df1fc835957a3e5dc281defa4cc17e058
4
+ data.tar.gz: e64f1f4887c163ecc737e75c4c9e41df5da9840076370e047c93c407f4566a42
5
5
  SHA512:
6
- metadata.gz: 5285fe97b32ebf2d0fa1df6a664eb5cefa9172254f5b854c7473d55167517a7b5127a9d124002d0db33209e3a9e7fadd038c1e75a2083364ed57ec07b04f5706
7
- data.tar.gz: 451403350bd5a7e8af4a757a0ab2111e9e9604fc201b3db31f24fcb03e78c6ed933f944c8bddcf296271aa7f489083a448536413f07585f350d26f23b6d72ed8
6
+ metadata.gz: ec830111f7042638adced2e597de788cc49cce7ccfd1099166555e84f759415d40849559bf4ecc228c95ebfb0e126371b846d189e48744a0211956c4848d43e0
7
+ data.tar.gz: d2fff38be5303c70b97344b4579a663d3744891a7509e0882245442068fcc69140350ec37095905f78fb3bb146b116d4bb8ba789389d5faf590f64933bead043
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/speech-to-text)
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/speech/v2"
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::Speech::V2::Speech::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).
@@ -170,14 +170,26 @@ module Google
170
170
  universe_domain: @config.universe_domain,
171
171
  channel_args: @config.channel_args,
172
172
  interceptors: @config.interceptors,
173
- channel_pool_config: @config.channel_pool
173
+ channel_pool_config: @config.channel_pool,
174
+ logger: @config.logger
174
175
  )
175
176
 
177
+ @speech_stub.stub_logger&.info do |entry|
178
+ entry.set_system_name
179
+ entry.set_service
180
+ entry.message = "Created client for #{entry.service}"
181
+ entry.set_credentials_fields credentials
182
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
183
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
184
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
185
+ end
186
+
176
187
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
177
188
  config.credentials = credentials
178
189
  config.quota_project = @quota_project_id
179
190
  config.endpoint = @speech_stub.endpoint
180
191
  config.universe_domain = @speech_stub.universe_domain
192
+ config.logger = @speech_stub.logger if config.respond_to? :logger=
181
193
  end
182
194
  end
183
195
 
@@ -195,6 +207,15 @@ module Google
195
207
  #
196
208
  attr_reader :location_client
197
209
 
210
+ ##
211
+ # The logger used for request/response debug logging.
212
+ #
213
+ # @return [Logger]
214
+ #
215
+ def logger
216
+ @speech_stub.logger
217
+ end
218
+
198
219
  # Service calls
199
220
 
200
221
  ##
@@ -297,7 +318,7 @@ module Google
297
318
  @speech_stub.call_rpc :create_recognizer, request, options: options do |response, operation|
298
319
  response = ::Gapic::Operation.new response, @operations_client, options: options
299
320
  yield response, operation if block_given?
300
- return response
321
+ throw :response, response
301
322
  end
302
323
  rescue ::GRPC::BadStatus => e
303
324
  raise ::Google::Cloud::Error.from_error(e)
@@ -403,7 +424,7 @@ module Google
403
424
  @speech_stub.call_rpc :list_recognizers, request, options: options do |response, operation|
404
425
  response = ::Gapic::PagedEnumerable.new @speech_stub, :list_recognizers, request, response, operation, options
405
426
  yield response, operation if block_given?
406
- return response
427
+ throw :response, response
407
428
  end
408
429
  rescue ::GRPC::BadStatus => e
409
430
  raise ::Google::Cloud::Error.from_error(e)
@@ -493,7 +514,6 @@ module Google
493
514
 
494
515
  @speech_stub.call_rpc :get_recognizer, request, options: options do |response, operation|
495
516
  yield response, operation if block_given?
496
- return response
497
517
  end
498
518
  rescue ::GRPC::BadStatus => e
499
519
  raise ::Google::Cloud::Error.from_error(e)
@@ -596,7 +616,7 @@ module Google
596
616
  @speech_stub.call_rpc :update_recognizer, request, options: options do |response, operation|
597
617
  response = ::Gapic::Operation.new response, @operations_client, options: options
598
618
  yield response, operation if block_given?
599
- return response
619
+ throw :response, response
600
620
  end
601
621
  rescue ::GRPC::BadStatus => e
602
622
  raise ::Google::Cloud::Error.from_error(e)
@@ -701,7 +721,7 @@ module Google
701
721
  @speech_stub.call_rpc :delete_recognizer, request, options: options do |response, operation|
702
722
  response = ::Gapic::Operation.new response, @operations_client, options: options
703
723
  yield response, operation if block_given?
704
- return response
724
+ throw :response, response
705
725
  end
706
726
  rescue ::GRPC::BadStatus => e
707
727
  raise ::Google::Cloud::Error.from_error(e)
@@ -803,7 +823,7 @@ module Google
803
823
  @speech_stub.call_rpc :undelete_recognizer, request, options: options do |response, operation|
804
824
  response = ::Gapic::Operation.new response, @operations_client, options: options
805
825
  yield response, operation if block_given?
806
- return response
826
+ throw :response, response
807
827
  end
808
828
  rescue ::GRPC::BadStatus => e
809
829
  raise ::Google::Cloud::Error.from_error(e)
@@ -928,7 +948,6 @@ module Google
928
948
 
929
949
  @speech_stub.call_rpc :recognize, request, options: options do |response, operation|
930
950
  yield response, operation if block_given?
931
- return response
932
951
  end
933
952
  rescue ::GRPC::BadStatus => e
934
953
  raise ::Google::Cloud::Error.from_error(e)
@@ -1008,7 +1027,6 @@ module Google
1008
1027
 
1009
1028
  @speech_stub.call_rpc :streaming_recognize, request, options: options do |response, operation|
1010
1029
  yield response, operation if block_given?
1011
- return response
1012
1030
  end
1013
1031
  rescue ::GRPC::BadStatus => e
1014
1032
  raise ::Google::Cloud::Error.from_error(e)
@@ -1135,7 +1153,7 @@ module Google
1135
1153
  @speech_stub.call_rpc :batch_recognize, request, options: options do |response, operation|
1136
1154
  response = ::Gapic::Operation.new response, @operations_client, options: options
1137
1155
  yield response, operation if block_given?
1138
- return response
1156
+ throw :response, response
1139
1157
  end
1140
1158
  rescue ::GRPC::BadStatus => e
1141
1159
  raise ::Google::Cloud::Error.from_error(e)
@@ -1223,7 +1241,6 @@ module Google
1223
1241
 
1224
1242
  @speech_stub.call_rpc :get_config, request, options: options do |response, operation|
1225
1243
  yield response, operation if block_given?
1226
- return response
1227
1244
  end
1228
1245
  rescue ::GRPC::BadStatus => e
1229
1246
  raise ::Google::Cloud::Error.from_error(e)
@@ -1314,7 +1331,6 @@ module Google
1314
1331
 
1315
1332
  @speech_stub.call_rpc :update_config, request, options: options do |response, operation|
1316
1333
  yield response, operation if block_given?
1317
- return response
1318
1334
  end
1319
1335
  rescue ::GRPC::BadStatus => e
1320
1336
  raise ::Google::Cloud::Error.from_error(e)
@@ -1420,7 +1436,7 @@ module Google
1420
1436
  @speech_stub.call_rpc :create_custom_class, request, options: options do |response, operation|
1421
1437
  response = ::Gapic::Operation.new response, @operations_client, options: options
1422
1438
  yield response, operation if block_given?
1423
- return response
1439
+ throw :response, response
1424
1440
  end
1425
1441
  rescue ::GRPC::BadStatus => e
1426
1442
  raise ::Google::Cloud::Error.from_error(e)
@@ -1527,7 +1543,7 @@ module Google
1527
1543
  @speech_stub.call_rpc :list_custom_classes, request, options: options do |response, operation|
1528
1544
  response = ::Gapic::PagedEnumerable.new @speech_stub, :list_custom_classes, request, response, operation, options
1529
1545
  yield response, operation if block_given?
1530
- return response
1546
+ throw :response, response
1531
1547
  end
1532
1548
  rescue ::GRPC::BadStatus => e
1533
1549
  raise ::Google::Cloud::Error.from_error(e)
@@ -1615,7 +1631,6 @@ module Google
1615
1631
 
1616
1632
  @speech_stub.call_rpc :get_custom_class, request, options: options do |response, operation|
1617
1633
  yield response, operation if block_given?
1618
- return response
1619
1634
  end
1620
1635
  rescue ::GRPC::BadStatus => e
1621
1636
  raise ::Google::Cloud::Error.from_error(e)
@@ -1719,7 +1734,7 @@ module Google
1719
1734
  @speech_stub.call_rpc :update_custom_class, request, options: options do |response, operation|
1720
1735
  response = ::Gapic::Operation.new response, @operations_client, options: options
1721
1736
  yield response, operation if block_given?
1722
- return response
1737
+ throw :response, response
1723
1738
  end
1724
1739
  rescue ::GRPC::BadStatus => e
1725
1740
  raise ::Google::Cloud::Error.from_error(e)
@@ -1825,7 +1840,7 @@ module Google
1825
1840
  @speech_stub.call_rpc :delete_custom_class, request, options: options do |response, operation|
1826
1841
  response = ::Gapic::Operation.new response, @operations_client, options: options
1827
1842
  yield response, operation if block_given?
1828
- return response
1843
+ throw :response, response
1829
1844
  end
1830
1845
  rescue ::GRPC::BadStatus => e
1831
1846
  raise ::Google::Cloud::Error.from_error(e)
@@ -1928,7 +1943,7 @@ module Google
1928
1943
  @speech_stub.call_rpc :undelete_custom_class, request, options: options do |response, operation|
1929
1944
  response = ::Gapic::Operation.new response, @operations_client, options: options
1930
1945
  yield response, operation if block_given?
1931
- return response
1946
+ throw :response, response
1932
1947
  end
1933
1948
  rescue ::GRPC::BadStatus => e
1934
1949
  raise ::Google::Cloud::Error.from_error(e)
@@ -2034,7 +2049,7 @@ module Google
2034
2049
  @speech_stub.call_rpc :create_phrase_set, request, options: options do |response, operation|
2035
2050
  response = ::Gapic::Operation.new response, @operations_client, options: options
2036
2051
  yield response, operation if block_given?
2037
- return response
2052
+ throw :response, response
2038
2053
  end
2039
2054
  rescue ::GRPC::BadStatus => e
2040
2055
  raise ::Google::Cloud::Error.from_error(e)
@@ -2140,7 +2155,7 @@ module Google
2140
2155
  @speech_stub.call_rpc :list_phrase_sets, request, options: options do |response, operation|
2141
2156
  response = ::Gapic::PagedEnumerable.new @speech_stub, :list_phrase_sets, request, response, operation, options
2142
2157
  yield response, operation if block_given?
2143
- return response
2158
+ throw :response, response
2144
2159
  end
2145
2160
  rescue ::GRPC::BadStatus => e
2146
2161
  raise ::Google::Cloud::Error.from_error(e)
@@ -2228,7 +2243,6 @@ module Google
2228
2243
 
2229
2244
  @speech_stub.call_rpc :get_phrase_set, request, options: options do |response, operation|
2230
2245
  yield response, operation if block_given?
2231
- return response
2232
2246
  end
2233
2247
  rescue ::GRPC::BadStatus => e
2234
2248
  raise ::Google::Cloud::Error.from_error(e)
@@ -2331,7 +2345,7 @@ module Google
2331
2345
  @speech_stub.call_rpc :update_phrase_set, request, options: options do |response, operation|
2332
2346
  response = ::Gapic::Operation.new response, @operations_client, options: options
2333
2347
  yield response, operation if block_given?
2334
- return response
2348
+ throw :response, response
2335
2349
  end
2336
2350
  rescue ::GRPC::BadStatus => e
2337
2351
  raise ::Google::Cloud::Error.from_error(e)
@@ -2436,7 +2450,7 @@ module Google
2436
2450
  @speech_stub.call_rpc :delete_phrase_set, request, options: options do |response, operation|
2437
2451
  response = ::Gapic::Operation.new response, @operations_client, options: options
2438
2452
  yield response, operation if block_given?
2439
- return response
2453
+ throw :response, response
2440
2454
  end
2441
2455
  rescue ::GRPC::BadStatus => e
2442
2456
  raise ::Google::Cloud::Error.from_error(e)
@@ -2538,7 +2552,7 @@ module Google
2538
2552
  @speech_stub.call_rpc :undelete_phrase_set, request, options: options do |response, operation|
2539
2553
  response = ::Gapic::Operation.new response, @operations_client, options: options
2540
2554
  yield response, operation if block_given?
2541
- return response
2555
+ throw :response, response
2542
2556
  end
2543
2557
  rescue ::GRPC::BadStatus => e
2544
2558
  raise ::Google::Cloud::Error.from_error(e)
@@ -2627,6 +2641,11 @@ module Google
2627
2641
  # default endpoint URL. The default value of nil uses the environment
2628
2642
  # universe (usually the default "googleapis.com" universe).
2629
2643
  # @return [::String,nil]
2644
+ # @!attribute [rw] logger
2645
+ # A custom logger to use for request/response debug logging, or the value
2646
+ # `:default` (the default) to construct a default logger, or `nil` to
2647
+ # explicitly disable logging.
2648
+ # @return [::Logger,:default,nil]
2630
2649
  #
2631
2650
  class Configuration
2632
2651
  extend ::Gapic::Config
@@ -2651,6 +2670,7 @@ module Google
2651
2670
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2652
2671
  config_attr :quota_project, nil, ::String, nil
2653
2672
  config_attr :universe_domain, nil, ::String, nil
2673
+ config_attr :logger, :default, ::Logger, nil, :default
2654
2674
 
2655
2675
  # @private
2656
2676
  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