google-cloud-speech-v2 0.13.0 → 0.14.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.
@@ -163,15 +163,27 @@ module Google
163
163
  endpoint: @config.endpoint,
164
164
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
165
165
  universe_domain: @config.universe_domain,
166
- credentials: credentials
166
+ credentials: credentials,
167
+ logger: @config.logger
167
168
  )
168
169
 
170
+ @speech_stub.logger(stub: true)&.info do |entry|
171
+ entry.set_system_name
172
+ entry.set_service
173
+ entry.message = "Created client for #{entry.service}"
174
+ entry.set_credentials_fields credentials
175
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
176
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
177
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
178
+ end
179
+
169
180
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
170
181
  config.credentials = credentials
171
182
  config.quota_project = @quota_project_id
172
183
  config.endpoint = @speech_stub.endpoint
173
184
  config.universe_domain = @speech_stub.universe_domain
174
185
  config.bindings_override = @config.bindings_override
186
+ config.logger = @speech_stub.logger if config.respond_to? :logger=
175
187
  end
176
188
  end
177
189
 
@@ -189,6 +201,15 @@ module Google
189
201
  #
190
202
  attr_reader :location_client
191
203
 
204
+ ##
205
+ # The logger used for request/response debug logging.
206
+ #
207
+ # @return [Logger]
208
+ #
209
+ def logger
210
+ @speech_stub.logger
211
+ end
212
+
192
213
  # Service calls
193
214
 
194
215
  ##
@@ -284,7 +305,7 @@ module Google
284
305
  @speech_stub.create_recognizer request, options do |result, operation|
285
306
  result = ::Gapic::Operation.new result, @operations_client, options: options
286
307
  yield result, operation if block_given?
287
- return result
308
+ throw :response, result
288
309
  end
289
310
  rescue ::Gapic::Rest::Error => e
290
311
  raise ::Google::Cloud::Error.from_error(e)
@@ -383,7 +404,7 @@ module Google
383
404
  @speech_stub.list_recognizers request, options do |result, operation|
384
405
  result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_recognizers, "recognizers", request, result, options
385
406
  yield result, operation if block_given?
386
- return result
407
+ throw :response, result
387
408
  end
388
409
  rescue ::Gapic::Rest::Error => e
389
410
  raise ::Google::Cloud::Error.from_error(e)
@@ -466,7 +487,6 @@ module Google
466
487
 
467
488
  @speech_stub.get_recognizer request, options do |result, operation|
468
489
  yield result, operation if block_given?
469
- return result
470
490
  end
471
491
  rescue ::Gapic::Rest::Error => e
472
492
  raise ::Google::Cloud::Error.from_error(e)
@@ -562,7 +582,7 @@ module Google
562
582
  @speech_stub.update_recognizer request, options do |result, operation|
563
583
  result = ::Gapic::Operation.new result, @operations_client, options: options
564
584
  yield result, operation if block_given?
565
- return result
585
+ throw :response, result
566
586
  end
567
587
  rescue ::Gapic::Rest::Error => e
568
588
  raise ::Google::Cloud::Error.from_error(e)
@@ -660,7 +680,7 @@ module Google
660
680
  @speech_stub.delete_recognizer request, options do |result, operation|
661
681
  result = ::Gapic::Operation.new result, @operations_client, options: options
662
682
  yield result, operation if block_given?
663
- return result
683
+ throw :response, result
664
684
  end
665
685
  rescue ::Gapic::Rest::Error => e
666
686
  raise ::Google::Cloud::Error.from_error(e)
@@ -755,7 +775,7 @@ module Google
755
775
  @speech_stub.undelete_recognizer request, options do |result, operation|
756
776
  result = ::Gapic::Operation.new result, @operations_client, options: options
757
777
  yield result, operation if block_given?
758
- return result
778
+ throw :response, result
759
779
  end
760
780
  rescue ::Gapic::Rest::Error => e
761
781
  raise ::Google::Cloud::Error.from_error(e)
@@ -873,7 +893,6 @@ module Google
873
893
 
874
894
  @speech_stub.recognize request, options do |result, operation|
875
895
  yield result, operation if block_given?
876
- return result
877
896
  end
878
897
  rescue ::Gapic::Rest::Error => e
879
898
  raise ::Google::Cloud::Error.from_error(e)
@@ -993,7 +1012,7 @@ module Google
993
1012
  @speech_stub.batch_recognize request, options do |result, operation|
994
1013
  result = ::Gapic::Operation.new result, @operations_client, options: options
995
1014
  yield result, operation if block_given?
996
- return result
1015
+ throw :response, result
997
1016
  end
998
1017
  rescue ::Gapic::Rest::Error => e
999
1018
  raise ::Google::Cloud::Error.from_error(e)
@@ -1074,7 +1093,6 @@ module Google
1074
1093
 
1075
1094
  @speech_stub.get_config request, options do |result, operation|
1076
1095
  yield result, operation if block_given?
1077
- return result
1078
1096
  end
1079
1097
  rescue ::Gapic::Rest::Error => e
1080
1098
  raise ::Google::Cloud::Error.from_error(e)
@@ -1158,7 +1176,6 @@ module Google
1158
1176
 
1159
1177
  @speech_stub.update_config request, options do |result, operation|
1160
1178
  yield result, operation if block_given?
1161
- return result
1162
1179
  end
1163
1180
  rescue ::Gapic::Rest::Error => e
1164
1181
  raise ::Google::Cloud::Error.from_error(e)
@@ -1257,7 +1274,7 @@ module Google
1257
1274
  @speech_stub.create_custom_class request, options do |result, operation|
1258
1275
  result = ::Gapic::Operation.new result, @operations_client, options: options
1259
1276
  yield result, operation if block_given?
1260
- return result
1277
+ throw :response, result
1261
1278
  end
1262
1279
  rescue ::Gapic::Rest::Error => e
1263
1280
  raise ::Google::Cloud::Error.from_error(e)
@@ -1357,7 +1374,7 @@ module Google
1357
1374
  @speech_stub.list_custom_classes request, options do |result, operation|
1358
1375
  result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_custom_classes, "custom_classes", request, result, options
1359
1376
  yield result, operation if block_given?
1360
- return result
1377
+ throw :response, result
1361
1378
  end
1362
1379
  rescue ::Gapic::Rest::Error => e
1363
1380
  raise ::Google::Cloud::Error.from_error(e)
@@ -1438,7 +1455,6 @@ module Google
1438
1455
 
1439
1456
  @speech_stub.get_custom_class request, options do |result, operation|
1440
1457
  yield result, operation if block_given?
1441
- return result
1442
1458
  end
1443
1459
  rescue ::Gapic::Rest::Error => e
1444
1460
  raise ::Google::Cloud::Error.from_error(e)
@@ -1535,7 +1551,7 @@ module Google
1535
1551
  @speech_stub.update_custom_class request, options do |result, operation|
1536
1552
  result = ::Gapic::Operation.new result, @operations_client, options: options
1537
1553
  yield result, operation if block_given?
1538
- return result
1554
+ throw :response, result
1539
1555
  end
1540
1556
  rescue ::Gapic::Rest::Error => e
1541
1557
  raise ::Google::Cloud::Error.from_error(e)
@@ -1634,7 +1650,7 @@ module Google
1634
1650
  @speech_stub.delete_custom_class request, options do |result, operation|
1635
1651
  result = ::Gapic::Operation.new result, @operations_client, options: options
1636
1652
  yield result, operation if block_given?
1637
- return result
1653
+ throw :response, result
1638
1654
  end
1639
1655
  rescue ::Gapic::Rest::Error => e
1640
1656
  raise ::Google::Cloud::Error.from_error(e)
@@ -1730,7 +1746,7 @@ module Google
1730
1746
  @speech_stub.undelete_custom_class request, options do |result, operation|
1731
1747
  result = ::Gapic::Operation.new result, @operations_client, options: options
1732
1748
  yield result, operation if block_given?
1733
- return result
1749
+ throw :response, result
1734
1750
  end
1735
1751
  rescue ::Gapic::Rest::Error => e
1736
1752
  raise ::Google::Cloud::Error.from_error(e)
@@ -1829,7 +1845,7 @@ module Google
1829
1845
  @speech_stub.create_phrase_set request, options do |result, operation|
1830
1846
  result = ::Gapic::Operation.new result, @operations_client, options: options
1831
1847
  yield result, operation if block_given?
1832
- return result
1848
+ throw :response, result
1833
1849
  end
1834
1850
  rescue ::Gapic::Rest::Error => e
1835
1851
  raise ::Google::Cloud::Error.from_error(e)
@@ -1928,7 +1944,7 @@ module Google
1928
1944
  @speech_stub.list_phrase_sets request, options do |result, operation|
1929
1945
  result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_phrase_sets, "phrase_sets", request, result, options
1930
1946
  yield result, operation if block_given?
1931
- return result
1947
+ throw :response, result
1932
1948
  end
1933
1949
  rescue ::Gapic::Rest::Error => e
1934
1950
  raise ::Google::Cloud::Error.from_error(e)
@@ -2009,7 +2025,6 @@ module Google
2009
2025
 
2010
2026
  @speech_stub.get_phrase_set request, options do |result, operation|
2011
2027
  yield result, operation if block_given?
2012
- return result
2013
2028
  end
2014
2029
  rescue ::Gapic::Rest::Error => e
2015
2030
  raise ::Google::Cloud::Error.from_error(e)
@@ -2105,7 +2120,7 @@ module Google
2105
2120
  @speech_stub.update_phrase_set request, options do |result, operation|
2106
2121
  result = ::Gapic::Operation.new result, @operations_client, options: options
2107
2122
  yield result, operation if block_given?
2108
- return result
2123
+ throw :response, result
2109
2124
  end
2110
2125
  rescue ::Gapic::Rest::Error => e
2111
2126
  raise ::Google::Cloud::Error.from_error(e)
@@ -2203,7 +2218,7 @@ module Google
2203
2218
  @speech_stub.delete_phrase_set request, options do |result, operation|
2204
2219
  result = ::Gapic::Operation.new result, @operations_client, options: options
2205
2220
  yield result, operation if block_given?
2206
- return result
2221
+ throw :response, result
2207
2222
  end
2208
2223
  rescue ::Gapic::Rest::Error => e
2209
2224
  raise ::Google::Cloud::Error.from_error(e)
@@ -2298,7 +2313,7 @@ module Google
2298
2313
  @speech_stub.undelete_phrase_set request, options do |result, operation|
2299
2314
  result = ::Gapic::Operation.new result, @operations_client, options: options
2300
2315
  yield result, operation if block_given?
2301
- return result
2316
+ throw :response, result
2302
2317
  end
2303
2318
  rescue ::Gapic::Rest::Error => e
2304
2319
  raise ::Google::Cloud::Error.from_error(e)
@@ -2378,6 +2393,11 @@ module Google
2378
2393
  # default endpoint URL. The default value of nil uses the environment
2379
2394
  # universe (usually the default "googleapis.com" universe).
2380
2395
  # @return [::String,nil]
2396
+ # @!attribute [rw] logger
2397
+ # A custom logger to use for request/response debug logging, or the value
2398
+ # `:default` (the default) to construct a default logger, or `nil` to
2399
+ # explicitly disable logging.
2400
+ # @return [::Logger,:default,nil]
2381
2401
  #
2382
2402
  class Configuration
2383
2403
  extend ::Gapic::Config
@@ -2406,6 +2426,7 @@ module Google
2406
2426
  # by the host service.
2407
2427
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2408
2428
  config_attr :bindings_override, {}, ::Hash, nil
2429
+ config_attr :logger, :default, ::Logger, nil, :default
2409
2430
 
2410
2431
  # @private
2411
2432
  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
  ##