google-cloud-notebooks-v1 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -235,14 +235,26 @@ module Google
235
235
  universe_domain: @config.universe_domain,
236
236
  channel_args: @config.channel_args,
237
237
  interceptors: @config.interceptors,
238
- channel_pool_config: @config.channel_pool
238
+ channel_pool_config: @config.channel_pool,
239
+ logger: @config.logger
239
240
  )
240
241
 
242
+ @notebook_service_stub.stub_logger&.info do |entry|
243
+ entry.set_system_name
244
+ entry.set_service
245
+ entry.message = "Created client for #{entry.service}"
246
+ entry.set_credentials_fields credentials
247
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
248
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
249
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
250
+ end
251
+
241
252
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
242
253
  config.credentials = credentials
243
254
  config.quota_project = @quota_project_id
244
255
  config.endpoint = @notebook_service_stub.endpoint
245
256
  config.universe_domain = @notebook_service_stub.universe_domain
257
+ config.logger = @notebook_service_stub.logger if config.respond_to? :logger=
246
258
  end
247
259
 
248
260
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -250,6 +262,7 @@ module Google
250
262
  config.quota_project = @quota_project_id
251
263
  config.endpoint = @notebook_service_stub.endpoint
252
264
  config.universe_domain = @notebook_service_stub.universe_domain
265
+ config.logger = @notebook_service_stub.logger if config.respond_to? :logger=
253
266
  end
254
267
  end
255
268
 
@@ -274,6 +287,15 @@ module Google
274
287
  #
275
288
  attr_reader :iam_policy_client
276
289
 
290
+ ##
291
+ # The logger used for request/response debug logging.
292
+ #
293
+ # @return [Logger]
294
+ #
295
+ def logger
296
+ @notebook_service_stub.logger
297
+ end
298
+
277
299
  # Service calls
278
300
 
279
301
  ##
@@ -367,7 +389,7 @@ module Google
367
389
  @notebook_service_stub.call_rpc :list_instances, request, options: options do |response, operation|
368
390
  response = ::Gapic::PagedEnumerable.new @notebook_service_stub, :list_instances, request, response, operation, options
369
391
  yield response, operation if block_given?
370
- return response
392
+ throw :response, response
371
393
  end
372
394
  rescue ::GRPC::BadStatus => e
373
395
  raise ::Google::Cloud::Error.from_error(e)
@@ -454,7 +476,6 @@ module Google
454
476
 
455
477
  @notebook_service_stub.call_rpc :get_instance, request, options: options do |response, operation|
456
478
  yield response, operation if block_given?
457
- return response
458
479
  end
459
480
  rescue ::GRPC::BadStatus => e
460
481
  raise ::Google::Cloud::Error.from_error(e)
@@ -553,7 +574,7 @@ module Google
553
574
  @notebook_service_stub.call_rpc :create_instance, request, options: options do |response, operation|
554
575
  response = ::Gapic::Operation.new response, @operations_client, options: options
555
576
  yield response, operation if block_given?
556
- return response
577
+ throw :response, response
557
578
  end
558
579
  rescue ::GRPC::BadStatus => e
559
580
  raise ::Google::Cloud::Error.from_error(e)
@@ -656,7 +677,7 @@ module Google
656
677
  @notebook_service_stub.call_rpc :register_instance, request, options: options do |response, operation|
657
678
  response = ::Gapic::Operation.new response, @operations_client, options: options
658
679
  yield response, operation if block_given?
659
- return response
680
+ throw :response, response
660
681
  end
661
682
  rescue ::GRPC::BadStatus => e
662
683
  raise ::Google::Cloud::Error.from_error(e)
@@ -758,7 +779,7 @@ module Google
758
779
  @notebook_service_stub.call_rpc :set_instance_accelerator, request, options: options do |response, operation|
759
780
  response = ::Gapic::Operation.new response, @operations_client, options: options
760
781
  yield response, operation if block_given?
761
- return response
782
+ throw :response, response
762
783
  end
763
784
  rescue ::GRPC::BadStatus => e
764
785
  raise ::Google::Cloud::Error.from_error(e)
@@ -856,7 +877,7 @@ module Google
856
877
  @notebook_service_stub.call_rpc :set_instance_machine_type, request, options: options do |response, operation|
857
878
  response = ::Gapic::Operation.new response, @operations_client, options: options
858
879
  yield response, operation if block_given?
859
- return response
880
+ throw :response, response
860
881
  end
861
882
  rescue ::GRPC::BadStatus => e
862
883
  raise ::Google::Cloud::Error.from_error(e)
@@ -953,7 +974,7 @@ module Google
953
974
  @notebook_service_stub.call_rpc :update_instance_config, request, options: options do |response, operation|
954
975
  response = ::Gapic::Operation.new response, @operations_client, options: options
955
976
  yield response, operation if block_given?
956
- return response
977
+ throw :response, response
957
978
  end
958
979
  rescue ::GRPC::BadStatus => e
959
980
  raise ::Google::Cloud::Error.from_error(e)
@@ -1050,7 +1071,7 @@ module Google
1050
1071
  @notebook_service_stub.call_rpc :update_shielded_instance_config, request, options: options do |response, operation|
1051
1072
  response = ::Gapic::Operation.new response, @operations_client, options: options
1052
1073
  yield response, operation if block_given?
1053
- return response
1074
+ throw :response, response
1054
1075
  end
1055
1076
  rescue ::GRPC::BadStatus => e
1056
1077
  raise ::Google::Cloud::Error.from_error(e)
@@ -1148,7 +1169,7 @@ module Google
1148
1169
  @notebook_service_stub.call_rpc :set_instance_labels, request, options: options do |response, operation|
1149
1170
  response = ::Gapic::Operation.new response, @operations_client, options: options
1150
1171
  yield response, operation if block_given?
1151
- return response
1172
+ throw :response, response
1152
1173
  end
1153
1174
  rescue ::GRPC::BadStatus => e
1154
1175
  raise ::Google::Cloud::Error.from_error(e)
@@ -1237,7 +1258,6 @@ module Google
1237
1258
 
1238
1259
  @notebook_service_stub.call_rpc :update_instance_metadata_items, request, options: options do |response, operation|
1239
1260
  yield response, operation if block_given?
1240
- return response
1241
1261
  end
1242
1262
  rescue ::GRPC::BadStatus => e
1243
1263
  raise ::Google::Cloud::Error.from_error(e)
@@ -1332,7 +1352,7 @@ module Google
1332
1352
  @notebook_service_stub.call_rpc :delete_instance, request, options: options do |response, operation|
1333
1353
  response = ::Gapic::Operation.new response, @operations_client, options: options
1334
1354
  yield response, operation if block_given?
1335
- return response
1355
+ throw :response, response
1336
1356
  end
1337
1357
  rescue ::GRPC::BadStatus => e
1338
1358
  raise ::Google::Cloud::Error.from_error(e)
@@ -1427,7 +1447,7 @@ module Google
1427
1447
  @notebook_service_stub.call_rpc :start_instance, request, options: options do |response, operation|
1428
1448
  response = ::Gapic::Operation.new response, @operations_client, options: options
1429
1449
  yield response, operation if block_given?
1430
- return response
1450
+ throw :response, response
1431
1451
  end
1432
1452
  rescue ::GRPC::BadStatus => e
1433
1453
  raise ::Google::Cloud::Error.from_error(e)
@@ -1522,7 +1542,7 @@ module Google
1522
1542
  @notebook_service_stub.call_rpc :stop_instance, request, options: options do |response, operation|
1523
1543
  response = ::Gapic::Operation.new response, @operations_client, options: options
1524
1544
  yield response, operation if block_given?
1525
- return response
1545
+ throw :response, response
1526
1546
  end
1527
1547
  rescue ::GRPC::BadStatus => e
1528
1548
  raise ::Google::Cloud::Error.from_error(e)
@@ -1617,7 +1637,7 @@ module Google
1617
1637
  @notebook_service_stub.call_rpc :reset_instance, request, options: options do |response, operation|
1618
1638
  response = ::Gapic::Operation.new response, @operations_client, options: options
1619
1639
  yield response, operation if block_given?
1620
- return response
1640
+ throw :response, response
1621
1641
  end
1622
1642
  rescue ::GRPC::BadStatus => e
1623
1643
  raise ::Google::Cloud::Error.from_error(e)
@@ -1721,7 +1741,7 @@ module Google
1721
1741
  @notebook_service_stub.call_rpc :report_instance_info, request, options: options do |response, operation|
1722
1742
  response = ::Gapic::Operation.new response, @operations_client, options: options
1723
1743
  yield response, operation if block_given?
1724
- return response
1744
+ throw :response, response
1725
1745
  end
1726
1746
  rescue ::GRPC::BadStatus => e
1727
1747
  raise ::Google::Cloud::Error.from_error(e)
@@ -1811,7 +1831,6 @@ module Google
1811
1831
 
1812
1832
  @notebook_service_stub.call_rpc :is_instance_upgradeable, request, options: options do |response, operation|
1813
1833
  yield response, operation if block_given?
1814
- return response
1815
1834
  end
1816
1835
  rescue ::GRPC::BadStatus => e
1817
1836
  raise ::Google::Cloud::Error.from_error(e)
@@ -1898,7 +1917,6 @@ module Google
1898
1917
 
1899
1918
  @notebook_service_stub.call_rpc :get_instance_health, request, options: options do |response, operation|
1900
1919
  yield response, operation if block_given?
1901
- return response
1902
1920
  end
1903
1921
  rescue ::GRPC::BadStatus => e
1904
1922
  raise ::Google::Cloud::Error.from_error(e)
@@ -1996,7 +2014,7 @@ module Google
1996
2014
  @notebook_service_stub.call_rpc :upgrade_instance, request, options: options do |response, operation|
1997
2015
  response = ::Gapic::Operation.new response, @operations_client, options: options
1998
2016
  yield response, operation if block_given?
1999
- return response
2017
+ throw :response, response
2000
2018
  end
2001
2019
  rescue ::GRPC::BadStatus => e
2002
2020
  raise ::Google::Cloud::Error.from_error(e)
@@ -2094,7 +2112,7 @@ module Google
2094
2112
  @notebook_service_stub.call_rpc :rollback_instance, request, options: options do |response, operation|
2095
2113
  response = ::Gapic::Operation.new response, @operations_client, options: options
2096
2114
  yield response, operation if block_given?
2097
- return response
2115
+ throw :response, response
2098
2116
  end
2099
2117
  rescue ::GRPC::BadStatus => e
2100
2118
  raise ::Google::Cloud::Error.from_error(e)
@@ -2191,7 +2209,7 @@ module Google
2191
2209
  @notebook_service_stub.call_rpc :diagnose_instance, request, options: options do |response, operation|
2192
2210
  response = ::Gapic::Operation.new response, @operations_client, options: options
2193
2211
  yield response, operation if block_given?
2194
- return response
2212
+ throw :response, response
2195
2213
  end
2196
2214
  rescue ::GRPC::BadStatus => e
2197
2215
  raise ::Google::Cloud::Error.from_error(e)
@@ -2293,7 +2311,7 @@ module Google
2293
2311
  @notebook_service_stub.call_rpc :upgrade_instance_internal, request, options: options do |response, operation|
2294
2312
  response = ::Gapic::Operation.new response, @operations_client, options: options
2295
2313
  yield response, operation if block_given?
2296
- return response
2314
+ throw :response, response
2297
2315
  end
2298
2316
  rescue ::GRPC::BadStatus => e
2299
2317
  raise ::Google::Cloud::Error.from_error(e)
@@ -2389,7 +2407,7 @@ module Google
2389
2407
  @notebook_service_stub.call_rpc :list_environments, request, options: options do |response, operation|
2390
2408
  response = ::Gapic::PagedEnumerable.new @notebook_service_stub, :list_environments, request, response, operation, options
2391
2409
  yield response, operation if block_given?
2392
- return response
2410
+ throw :response, response
2393
2411
  end
2394
2412
  rescue ::GRPC::BadStatus => e
2395
2413
  raise ::Google::Cloud::Error.from_error(e)
@@ -2476,7 +2494,6 @@ module Google
2476
2494
 
2477
2495
  @notebook_service_stub.call_rpc :get_environment, request, options: options do |response, operation|
2478
2496
  yield response, operation if block_given?
2479
- return response
2480
2497
  end
2481
2498
  rescue ::GRPC::BadStatus => e
2482
2499
  raise ::Google::Cloud::Error.from_error(e)
@@ -2577,7 +2594,7 @@ module Google
2577
2594
  @notebook_service_stub.call_rpc :create_environment, request, options: options do |response, operation|
2578
2595
  response = ::Gapic::Operation.new response, @operations_client, options: options
2579
2596
  yield response, operation if block_given?
2580
- return response
2597
+ throw :response, response
2581
2598
  end
2582
2599
  rescue ::GRPC::BadStatus => e
2583
2600
  raise ::Google::Cloud::Error.from_error(e)
@@ -2672,7 +2689,7 @@ module Google
2672
2689
  @notebook_service_stub.call_rpc :delete_environment, request, options: options do |response, operation|
2673
2690
  response = ::Gapic::Operation.new response, @operations_client, options: options
2674
2691
  yield response, operation if block_given?
2675
- return response
2692
+ throw :response, response
2676
2693
  end
2677
2694
  rescue ::GRPC::BadStatus => e
2678
2695
  raise ::Google::Cloud::Error.from_error(e)
@@ -2773,7 +2790,7 @@ module Google
2773
2790
  @notebook_service_stub.call_rpc :list_schedules, request, options: options do |response, operation|
2774
2791
  response = ::Gapic::PagedEnumerable.new @notebook_service_stub, :list_schedules, request, response, operation, options
2775
2792
  yield response, operation if block_given?
2776
- return response
2793
+ throw :response, response
2777
2794
  end
2778
2795
  rescue ::GRPC::BadStatus => e
2779
2796
  raise ::Google::Cloud::Error.from_error(e)
@@ -2860,7 +2877,6 @@ module Google
2860
2877
 
2861
2878
  @notebook_service_stub.call_rpc :get_schedule, request, options: options do |response, operation|
2862
2879
  yield response, operation if block_given?
2863
- return response
2864
2880
  end
2865
2881
  rescue ::GRPC::BadStatus => e
2866
2882
  raise ::Google::Cloud::Error.from_error(e)
@@ -2955,7 +2971,7 @@ module Google
2955
2971
  @notebook_service_stub.call_rpc :delete_schedule, request, options: options do |response, operation|
2956
2972
  response = ::Gapic::Operation.new response, @operations_client, options: options
2957
2973
  yield response, operation if block_given?
2958
- return response
2974
+ throw :response, response
2959
2975
  end
2960
2976
  rescue ::GRPC::BadStatus => e
2961
2977
  raise ::Google::Cloud::Error.from_error(e)
@@ -3054,7 +3070,7 @@ module Google
3054
3070
  @notebook_service_stub.call_rpc :create_schedule, request, options: options do |response, operation|
3055
3071
  response = ::Gapic::Operation.new response, @operations_client, options: options
3056
3072
  yield response, operation if block_given?
3057
- return response
3073
+ throw :response, response
3058
3074
  end
3059
3075
  rescue ::GRPC::BadStatus => e
3060
3076
  raise ::Google::Cloud::Error.from_error(e)
@@ -3149,7 +3165,7 @@ module Google
3149
3165
  @notebook_service_stub.call_rpc :trigger_schedule, request, options: options do |response, operation|
3150
3166
  response = ::Gapic::Operation.new response, @operations_client, options: options
3151
3167
  yield response, operation if block_given?
3152
- return response
3168
+ throw :response, response
3153
3169
  end
3154
3170
  rescue ::GRPC::BadStatus => e
3155
3171
  raise ::Google::Cloud::Error.from_error(e)
@@ -3252,7 +3268,7 @@ module Google
3252
3268
  @notebook_service_stub.call_rpc :list_executions, request, options: options do |response, operation|
3253
3269
  response = ::Gapic::PagedEnumerable.new @notebook_service_stub, :list_executions, request, response, operation, options
3254
3270
  yield response, operation if block_given?
3255
- return response
3271
+ throw :response, response
3256
3272
  end
3257
3273
  rescue ::GRPC::BadStatus => e
3258
3274
  raise ::Google::Cloud::Error.from_error(e)
@@ -3339,7 +3355,6 @@ module Google
3339
3355
 
3340
3356
  @notebook_service_stub.call_rpc :get_execution, request, options: options do |response, operation|
3341
3357
  yield response, operation if block_given?
3342
- return response
3343
3358
  end
3344
3359
  rescue ::GRPC::BadStatus => e
3345
3360
  raise ::Google::Cloud::Error.from_error(e)
@@ -3434,7 +3449,7 @@ module Google
3434
3449
  @notebook_service_stub.call_rpc :delete_execution, request, options: options do |response, operation|
3435
3450
  response = ::Gapic::Operation.new response, @operations_client, options: options
3436
3451
  yield response, operation if block_given?
3437
- return response
3452
+ throw :response, response
3438
3453
  end
3439
3454
  rescue ::GRPC::BadStatus => e
3440
3455
  raise ::Google::Cloud::Error.from_error(e)
@@ -3533,7 +3548,7 @@ module Google
3533
3548
  @notebook_service_stub.call_rpc :create_execution, request, options: options do |response, operation|
3534
3549
  response = ::Gapic::Operation.new response, @operations_client, options: options
3535
3550
  yield response, operation if block_given?
3536
- return response
3551
+ throw :response, response
3537
3552
  end
3538
3553
  rescue ::GRPC::BadStatus => e
3539
3554
  raise ::Google::Cloud::Error.from_error(e)
@@ -3622,6 +3637,11 @@ module Google
3622
3637
  # default endpoint URL. The default value of nil uses the environment
3623
3638
  # universe (usually the default "googleapis.com" universe).
3624
3639
  # @return [::String,nil]
3640
+ # @!attribute [rw] logger
3641
+ # A custom logger to use for request/response debug logging, or the value
3642
+ # `:default` (the default) to construct a default logger, or `nil` to
3643
+ # explicitly disable logging.
3644
+ # @return [::Logger,:default,nil]
3625
3645
  #
3626
3646
  class Configuration
3627
3647
  extend ::Gapic::Config
@@ -3646,6 +3666,7 @@ module Google
3646
3666
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3647
3667
  config_attr :quota_project, nil, ::String, nil
3648
3668
  config_attr :universe_domain, nil, ::String, nil
3669
+ config_attr :logger, :default, ::Logger, nil, :default
3649
3670
 
3650
3671
  # @private
3651
3672
  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