google-cloud-automl-v1beta1 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -254,8 +254,19 @@ module Google
254
254
  endpoint: @config.endpoint,
255
255
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
256
256
  universe_domain: @config.universe_domain,
257
- credentials: credentials
257
+ credentials: credentials,
258
+ logger: @config.logger
258
259
  )
260
+
261
+ @auto_ml_stub.logger(stub: true)&.info do |entry|
262
+ entry.set_system_name
263
+ entry.set_service
264
+ entry.message = "Created client for #{entry.service}"
265
+ entry.set_credentials_fields credentials
266
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
267
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
268
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
269
+ end
259
270
  end
260
271
 
261
272
  ##
@@ -265,6 +276,15 @@ module Google
265
276
  #
266
277
  attr_reader :operations_client
267
278
 
279
+ ##
280
+ # The logger used for request/response debug logging.
281
+ #
282
+ # @return [Logger]
283
+ #
284
+ def logger
285
+ @auto_ml_stub.logger
286
+ end
287
+
268
288
  # Service calls
269
289
 
270
290
  ##
@@ -342,7 +362,6 @@ module Google
342
362
 
343
363
  @auto_ml_stub.create_dataset request, options do |result, operation|
344
364
  yield result, operation if block_given?
345
- return result
346
365
  end
347
366
  rescue ::Gapic::Rest::Error => e
348
367
  raise ::Google::Cloud::Error.from_error(e)
@@ -421,7 +440,6 @@ module Google
421
440
 
422
441
  @auto_ml_stub.get_dataset request, options do |result, operation|
423
442
  yield result, operation if block_given?
424
- return result
425
443
  end
426
444
  rescue ::Gapic::Rest::Error => e
427
445
  raise ::Google::Cloud::Error.from_error(e)
@@ -522,7 +540,7 @@ module Google
522
540
  @auto_ml_stub.list_datasets request, options do |result, operation|
523
541
  result = ::Gapic::Rest::PagedEnumerable.new @auto_ml_stub, :list_datasets, "datasets", request, result, options
524
542
  yield result, operation if block_given?
525
- return result
543
+ throw :response, result
526
544
  end
527
545
  rescue ::Gapic::Rest::Error => e
528
546
  raise ::Google::Cloud::Error.from_error(e)
@@ -603,7 +621,6 @@ module Google
603
621
 
604
622
  @auto_ml_stub.update_dataset request, options do |result, operation|
605
623
  yield result, operation if block_given?
606
- return result
607
624
  end
608
625
  rescue ::Gapic::Rest::Error => e
609
626
  raise ::Google::Cloud::Error.from_error(e)
@@ -694,7 +711,7 @@ module Google
694
711
  @auto_ml_stub.delete_dataset request, options do |result, operation|
695
712
  result = ::Gapic::Operation.new result, @operations_client, options: options
696
713
  yield result, operation if block_given?
697
- return result
714
+ throw :response, result
698
715
  end
699
716
  rescue ::Gapic::Rest::Error => e
700
717
  raise ::Google::Cloud::Error.from_error(e)
@@ -793,7 +810,7 @@ module Google
793
810
  @auto_ml_stub.import_data request, options do |result, operation|
794
811
  result = ::Gapic::Operation.new result, @operations_client, options: options
795
812
  yield result, operation if block_given?
796
- return result
813
+ throw :response, result
797
814
  end
798
815
  rescue ::Gapic::Rest::Error => e
799
816
  raise ::Google::Cloud::Error.from_error(e)
@@ -884,7 +901,7 @@ module Google
884
901
  @auto_ml_stub.export_data request, options do |result, operation|
885
902
  result = ::Gapic::Operation.new result, @operations_client, options: options
886
903
  yield result, operation if block_given?
887
- return result
904
+ throw :response, result
888
905
  end
889
906
  rescue ::Gapic::Rest::Error => e
890
907
  raise ::Google::Cloud::Error.from_error(e)
@@ -963,7 +980,6 @@ module Google
963
980
 
964
981
  @auto_ml_stub.get_annotation_spec request, options do |result, operation|
965
982
  yield result, operation if block_given?
966
- return result
967
983
  end
968
984
  rescue ::Gapic::Rest::Error => e
969
985
  raise ::Google::Cloud::Error.from_error(e)
@@ -1044,7 +1060,6 @@ module Google
1044
1060
 
1045
1061
  @auto_ml_stub.get_table_spec request, options do |result, operation|
1046
1062
  yield result, operation if block_given?
1047
- return result
1048
1063
  end
1049
1064
  rescue ::Gapic::Rest::Error => e
1050
1065
  raise ::Google::Cloud::Error.from_error(e)
@@ -1140,7 +1155,7 @@ module Google
1140
1155
  @auto_ml_stub.list_table_specs request, options do |result, operation|
1141
1156
  result = ::Gapic::Rest::PagedEnumerable.new @auto_ml_stub, :list_table_specs, "table_specs", request, result, options
1142
1157
  yield result, operation if block_given?
1143
- return result
1158
+ throw :response, result
1144
1159
  end
1145
1160
  rescue ::Gapic::Rest::Error => e
1146
1161
  raise ::Google::Cloud::Error.from_error(e)
@@ -1221,7 +1236,6 @@ module Google
1221
1236
 
1222
1237
  @auto_ml_stub.update_table_spec request, options do |result, operation|
1223
1238
  yield result, operation if block_given?
1224
- return result
1225
1239
  end
1226
1240
  rescue ::Gapic::Rest::Error => e
1227
1241
  raise ::Google::Cloud::Error.from_error(e)
@@ -1302,7 +1316,6 @@ module Google
1302
1316
 
1303
1317
  @auto_ml_stub.get_column_spec request, options do |result, operation|
1304
1318
  yield result, operation if block_given?
1305
- return result
1306
1319
  end
1307
1320
  rescue ::Gapic::Rest::Error => e
1308
1321
  raise ::Google::Cloud::Error.from_error(e)
@@ -1398,7 +1411,7 @@ module Google
1398
1411
  @auto_ml_stub.list_column_specs request, options do |result, operation|
1399
1412
  result = ::Gapic::Rest::PagedEnumerable.new @auto_ml_stub, :list_column_specs, "column_specs", request, result, options
1400
1413
  yield result, operation if block_given?
1401
- return result
1414
+ throw :response, result
1402
1415
  end
1403
1416
  rescue ::Gapic::Rest::Error => e
1404
1417
  raise ::Google::Cloud::Error.from_error(e)
@@ -1479,7 +1492,6 @@ module Google
1479
1492
 
1480
1493
  @auto_ml_stub.update_column_spec request, options do |result, operation|
1481
1494
  yield result, operation if block_given?
1482
- return result
1483
1495
  end
1484
1496
  rescue ::Gapic::Rest::Error => e
1485
1497
  raise ::Google::Cloud::Error.from_error(e)
@@ -1572,7 +1584,7 @@ module Google
1572
1584
  @auto_ml_stub.create_model request, options do |result, operation|
1573
1585
  result = ::Gapic::Operation.new result, @operations_client, options: options
1574
1586
  yield result, operation if block_given?
1575
- return result
1587
+ throw :response, result
1576
1588
  end
1577
1589
  rescue ::Gapic::Rest::Error => e
1578
1590
  raise ::Google::Cloud::Error.from_error(e)
@@ -1651,7 +1663,6 @@ module Google
1651
1663
 
1652
1664
  @auto_ml_stub.get_model request, options do |result, operation|
1653
1665
  yield result, operation if block_given?
1654
- return result
1655
1666
  end
1656
1667
  rescue ::Gapic::Rest::Error => e
1657
1668
  raise ::Google::Cloud::Error.from_error(e)
@@ -1752,7 +1763,7 @@ module Google
1752
1763
  @auto_ml_stub.list_models request, options do |result, operation|
1753
1764
  result = ::Gapic::Rest::PagedEnumerable.new @auto_ml_stub, :list_models, "model", request, result, options
1754
1765
  yield result, operation if block_given?
1755
- return result
1766
+ throw :response, result
1756
1767
  end
1757
1768
  rescue ::Gapic::Rest::Error => e
1758
1769
  raise ::Google::Cloud::Error.from_error(e)
@@ -1843,7 +1854,7 @@ module Google
1843
1854
  @auto_ml_stub.delete_model request, options do |result, operation|
1844
1855
  result = ::Gapic::Operation.new result, @operations_client, options: options
1845
1856
  yield result, operation if block_given?
1846
- return result
1857
+ throw :response, result
1847
1858
  end
1848
1859
  rescue ::Gapic::Rest::Error => e
1849
1860
  raise ::Google::Cloud::Error.from_error(e)
@@ -1945,7 +1956,7 @@ module Google
1945
1956
  @auto_ml_stub.deploy_model request, options do |result, operation|
1946
1957
  result = ::Gapic::Operation.new result, @operations_client, options: options
1947
1958
  yield result, operation if block_given?
1948
- return result
1959
+ throw :response, result
1949
1960
  end
1950
1961
  rescue ::Gapic::Rest::Error => e
1951
1962
  raise ::Google::Cloud::Error.from_error(e)
@@ -2038,7 +2049,7 @@ module Google
2038
2049
  @auto_ml_stub.undeploy_model request, options do |result, operation|
2039
2050
  result = ::Gapic::Operation.new result, @operations_client, options: options
2040
2051
  yield result, operation if block_given?
2041
- return result
2052
+ throw :response, result
2042
2053
  end
2043
2054
  rescue ::Gapic::Rest::Error => e
2044
2055
  raise ::Google::Cloud::Error.from_error(e)
@@ -2134,7 +2145,7 @@ module Google
2134
2145
  @auto_ml_stub.export_model request, options do |result, operation|
2135
2146
  result = ::Gapic::Operation.new result, @operations_client, options: options
2136
2147
  yield result, operation if block_given?
2137
- return result
2148
+ throw :response, result
2138
2149
  end
2139
2150
  rescue ::Gapic::Rest::Error => e
2140
2151
  raise ::Google::Cloud::Error.from_error(e)
@@ -2237,7 +2248,7 @@ module Google
2237
2248
  @auto_ml_stub.export_evaluated_examples request, options do |result, operation|
2238
2249
  result = ::Gapic::Operation.new result, @operations_client, options: options
2239
2250
  yield result, operation if block_given?
2240
- return result
2251
+ throw :response, result
2241
2252
  end
2242
2253
  rescue ::Gapic::Rest::Error => e
2243
2254
  raise ::Google::Cloud::Error.from_error(e)
@@ -2316,7 +2327,6 @@ module Google
2316
2327
 
2317
2328
  @auto_ml_stub.get_model_evaluation request, options do |result, operation|
2318
2329
  yield result, operation if block_given?
2319
- return result
2320
2330
  end
2321
2331
  rescue ::Gapic::Rest::Error => e
2322
2332
  raise ::Google::Cloud::Error.from_error(e)
@@ -2421,7 +2431,7 @@ module Google
2421
2431
  @auto_ml_stub.list_model_evaluations request, options do |result, operation|
2422
2432
  result = ::Gapic::Rest::PagedEnumerable.new @auto_ml_stub, :list_model_evaluations, "model_evaluation", request, result, options
2423
2433
  yield result, operation if block_given?
2424
- return result
2434
+ throw :response, result
2425
2435
  end
2426
2436
  rescue ::Gapic::Rest::Error => e
2427
2437
  raise ::Google::Cloud::Error.from_error(e)
@@ -2501,6 +2511,11 @@ module Google
2501
2511
  # default endpoint URL. The default value of nil uses the environment
2502
2512
  # universe (usually the default "googleapis.com" universe).
2503
2513
  # @return [::String,nil]
2514
+ # @!attribute [rw] logger
2515
+ # A custom logger to use for request/response debug logging, or the value
2516
+ # `:default` (the default) to construct a default logger, or `nil` to
2517
+ # explicitly disable logging.
2518
+ # @return [::Logger,:default,nil]
2504
2519
  #
2505
2520
  class Configuration
2506
2521
  extend ::Gapic::Config
@@ -2522,6 +2537,7 @@ module Google
2522
2537
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2523
2538
  config_attr :quota_project, nil, ::String, nil
2524
2539
  config_attr :universe_domain, nil, ::String, nil
2540
+ config_attr :logger, :default, ::Logger, nil, :default
2525
2541
 
2526
2542
  # @private
2527
2543
  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)
@@ -562,7 +553,7 @@ module Google
562
553
  @operations_stub.wait_operation request, options do |result, operation|
563
554
  result = ::Gapic::Operation.new result, @operations_client, options: options
564
555
  yield result, operation if block_given?
565
- return result
556
+ throw :response, result
566
557
  end
567
558
  rescue ::Gapic::Rest::Error => e
568
559
  raise ::Google::Cloud::Error.from_error(e)
@@ -642,6 +633,11 @@ module Google
642
633
  # default endpoint URL. The default value of nil uses the environment
643
634
  # universe (usually the default "googleapis.com" universe).
644
635
  # @return [::String,nil]
636
+ # @!attribute [rw] logger
637
+ # A custom logger to use for request/response debug logging, or the value
638
+ # `:default` (the default) to construct a default logger, or `nil` to
639
+ # explicitly disable logging.
640
+ # @return [::Logger,:default,nil]
645
641
  #
646
642
  class Configuration
647
643
  extend ::Gapic::Config
@@ -663,6 +659,7 @@ module Google
663
659
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
664
660
  config_attr :quota_project, nil, ::String, nil
665
661
  config_attr :universe_domain, nil, ::String, nil
662
+ config_attr :logger, :default, ::Logger, nil, :default
666
663
 
667
664
  # @private
668
665
  def initialize parent_config = nil
@@ -789,16 +786,18 @@ module Google
789
786
 
790
787
  response = @client_stub.make_http_request(
791
788
  verb,
792
- uri: uri,
793
- body: body || "",
794
- params: query_string_params,
789
+ uri: uri,
790
+ body: body || "",
791
+ params: query_string_params,
792
+ method_name: "list_operations",
795
793
  options: options
796
794
  )
797
795
  operation = ::Gapic::Rest::TransportOperation.new response
798
796
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
799
-
800
- yield result, operation if block_given?
801
- result
797
+ catch :response do
798
+ yield result, operation if block_given?
799
+ result
800
+ end
802
801
  end
803
802
 
804
803
  ##
@@ -827,16 +826,18 @@ module Google
827
826
 
828
827
  response = @client_stub.make_http_request(
829
828
  verb,
830
- uri: uri,
831
- body: body || "",
832
- params: query_string_params,
829
+ uri: uri,
830
+ body: body || "",
831
+ params: query_string_params,
832
+ method_name: "get_operation",
833
833
  options: options
834
834
  )
835
835
  operation = ::Gapic::Rest::TransportOperation.new response
836
836
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
837
-
838
- yield result, operation if block_given?
839
- result
837
+ catch :response do
838
+ yield result, operation if block_given?
839
+ result
840
+ end
840
841
  end
841
842
 
842
843
  ##
@@ -865,16 +866,18 @@ module Google
865
866
 
866
867
  response = @client_stub.make_http_request(
867
868
  verb,
868
- uri: uri,
869
- body: body || "",
870
- params: query_string_params,
869
+ uri: uri,
870
+ body: body || "",
871
+ params: query_string_params,
872
+ method_name: "delete_operation",
871
873
  options: options
872
874
  )
873
875
  operation = ::Gapic::Rest::TransportOperation.new response
874
876
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
875
-
876
- yield result, operation if block_given?
877
- result
877
+ catch :response do
878
+ yield result, operation if block_given?
879
+ result
880
+ end
878
881
  end
879
882
 
880
883
  ##
@@ -903,16 +906,18 @@ module Google
903
906
 
904
907
  response = @client_stub.make_http_request(
905
908
  verb,
906
- uri: uri,
907
- body: body || "",
908
- params: query_string_params,
909
+ uri: uri,
910
+ body: body || "",
911
+ params: query_string_params,
912
+ method_name: "cancel_operation",
909
913
  options: options
910
914
  )
911
915
  operation = ::Gapic::Rest::TransportOperation.new response
912
916
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
913
-
914
- yield result, operation if block_given?
915
- result
917
+ catch :response do
918
+ yield result, operation if block_given?
919
+ result
920
+ end
916
921
  end
917
922
 
918
923
  ##
@@ -941,16 +946,18 @@ module Google
941
946
 
942
947
  response = @client_stub.make_http_request(
943
948
  verb,
944
- uri: uri,
945
- body: body || "",
946
- params: query_string_params,
949
+ uri: uri,
950
+ body: body || "",
951
+ params: query_string_params,
952
+ method_name: "wait_operation",
947
953
  options: options
948
954
  )
949
955
  operation = ::Gapic::Rest::TransportOperation.new response
950
956
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
951
-
952
- yield result, operation if block_given?
953
- result
957
+ catch :response do
958
+ yield result, operation if block_given?
959
+ result
960
+ end
954
961
  end
955
962
 
956
963
  ##