google-cloud-backupdr-v1 0.3.0 → 0.4.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: 30d56fe88312adab0f82fd466083541e92473ea1419a1738ba9ab7447798ed9f
4
- data.tar.gz: bfd0a4c2b0372673dd2e2306a26078deb811ea6c81d80fc366f4e9af9a8191f2
3
+ metadata.gz: 8464c5a5b3acf2653444c3e24d07a7876eda495a0e412bd66ffcc01843f76082
4
+ data.tar.gz: c7ac3e438dc32065603c7e3c8240e0bea68904bcda58b16b69cbedc2de7f9de3
5
5
  SHA512:
6
- metadata.gz: 7dbef25f62cec4c779b4aadc9c99eccaf1ae2060372bbca52f9503e7b1623fdb140761efcc921c5cb92dd0fe2d42dcb91f237ea501d990727d453125ce355c10
7
- data.tar.gz: 62abd37c3fa56d0caa7ee94aa33a29d72befe1a494610f38894960c3a165e2dd3f98c84cc6f831ded1a1575d22eab5572f9e7854060136c2e523c7c27c4f2b70
6
+ metadata.gz: c60aba990dde8494c9b6f45580e8717d71ec42639b44513922a8fa913b48ddf792814fb274014cc14ff494d15bace8f41e47533523e13db04da7b16ef116b9e4
7
+ data.tar.gz: bed59822ce3eea17388f1422457991d9890f35082be7569d0d200085499c30c992308b0d42665145451977597263356bbf1c77cb2a1cd45581fe64e680ee6c46
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/backup-disaster-recovery/docs/reference/rpc)
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/backupdr/v1"
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::BackupDR::V1::BackupDR::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).
@@ -233,14 +233,26 @@ module Google
233
233
  universe_domain: @config.universe_domain,
234
234
  channel_args: @config.channel_args,
235
235
  interceptors: @config.interceptors,
236
- channel_pool_config: @config.channel_pool
236
+ channel_pool_config: @config.channel_pool,
237
+ logger: @config.logger
237
238
  )
238
239
 
240
+ @backup_dr_stub.stub_logger&.info do |entry|
241
+ entry.set_system_name
242
+ entry.set_service
243
+ entry.message = "Created client for #{entry.service}"
244
+ entry.set_credentials_fields credentials
245
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
246
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
247
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
248
+ end
249
+
239
250
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
240
251
  config.credentials = credentials
241
252
  config.quota_project = @quota_project_id
242
253
  config.endpoint = @backup_dr_stub.endpoint
243
254
  config.universe_domain = @backup_dr_stub.universe_domain
255
+ config.logger = @backup_dr_stub.logger if config.respond_to? :logger=
244
256
  end
245
257
 
246
258
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -248,6 +260,7 @@ module Google
248
260
  config.quota_project = @quota_project_id
249
261
  config.endpoint = @backup_dr_stub.endpoint
250
262
  config.universe_domain = @backup_dr_stub.universe_domain
263
+ config.logger = @backup_dr_stub.logger if config.respond_to? :logger=
251
264
  end
252
265
  end
253
266
 
@@ -272,6 +285,15 @@ module Google
272
285
  #
273
286
  attr_reader :iam_policy_client
274
287
 
288
+ ##
289
+ # The logger used for request/response debug logging.
290
+ #
291
+ # @return [Logger]
292
+ #
293
+ def logger
294
+ @backup_dr_stub.logger
295
+ end
296
+
275
297
  # Service calls
276
298
 
277
299
  ##
@@ -373,7 +395,7 @@ module Google
373
395
  @backup_dr_stub.call_rpc :list_management_servers, request, options: options do |response, operation|
374
396
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_management_servers, request, response, operation, options
375
397
  yield response, operation if block_given?
376
- return response
398
+ throw :response, response
377
399
  end
378
400
  rescue ::GRPC::BadStatus => e
379
401
  raise ::Google::Cloud::Error.from_error(e)
@@ -460,7 +482,6 @@ module Google
460
482
 
461
483
  @backup_dr_stub.call_rpc :get_management_server, request, options: options do |response, operation|
462
484
  yield response, operation if block_given?
463
- return response
464
485
  end
465
486
  rescue ::GRPC::BadStatus => e
466
487
  raise ::Google::Cloud::Error.from_error(e)
@@ -576,7 +597,7 @@ module Google
576
597
  @backup_dr_stub.call_rpc :create_management_server, request, options: options do |response, operation|
577
598
  response = ::Gapic::Operation.new response, @operations_client, options: options
578
599
  yield response, operation if block_given?
579
- return response
600
+ throw :response, response
580
601
  end
581
602
  rescue ::GRPC::BadStatus => e
582
603
  raise ::Google::Cloud::Error.from_error(e)
@@ -684,7 +705,7 @@ module Google
684
705
  @backup_dr_stub.call_rpc :delete_management_server, request, options: options do |response, operation|
685
706
  response = ::Gapic::Operation.new response, @operations_client, options: options
686
707
  yield response, operation if block_given?
687
- return response
708
+ throw :response, response
688
709
  end
689
710
  rescue ::GRPC::BadStatus => e
690
711
  raise ::Google::Cloud::Error.from_error(e)
@@ -801,7 +822,7 @@ module Google
801
822
  @backup_dr_stub.call_rpc :create_backup_vault, request, options: options do |response, operation|
802
823
  response = ::Gapic::Operation.new response, @operations_client, options: options
803
824
  yield response, operation if block_given?
804
- return response
825
+ throw :response, response
805
826
  end
806
827
  rescue ::GRPC::BadStatus => e
807
828
  raise ::Google::Cloud::Error.from_error(e)
@@ -909,7 +930,7 @@ module Google
909
930
  @backup_dr_stub.call_rpc :list_backup_vaults, request, options: options do |response, operation|
910
931
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_backup_vaults, request, response, operation, options
911
932
  yield response, operation if block_given?
912
- return response
933
+ throw :response, response
913
934
  end
914
935
  rescue ::GRPC::BadStatus => e
915
936
  raise ::Google::Cloud::Error.from_error(e)
@@ -1016,7 +1037,7 @@ module Google
1016
1037
  @backup_dr_stub.call_rpc :fetch_usable_backup_vaults, request, options: options do |response, operation|
1017
1038
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :fetch_usable_backup_vaults, request, response, operation, options
1018
1039
  yield response, operation if block_given?
1019
- return response
1040
+ throw :response, response
1020
1041
  end
1021
1042
  rescue ::GRPC::BadStatus => e
1022
1043
  raise ::Google::Cloud::Error.from_error(e)
@@ -1106,7 +1127,6 @@ module Google
1106
1127
 
1107
1128
  @backup_dr_stub.call_rpc :get_backup_vault, request, options: options do |response, operation|
1108
1129
  yield response, operation if block_given?
1109
- return response
1110
1130
  end
1111
1131
  rescue ::GRPC::BadStatus => e
1112
1132
  raise ::Google::Cloud::Error.from_error(e)
@@ -1226,7 +1246,7 @@ module Google
1226
1246
  @backup_dr_stub.call_rpc :update_backup_vault, request, options: options do |response, operation|
1227
1247
  response = ::Gapic::Operation.new response, @operations_client, options: options
1228
1248
  yield response, operation if block_given?
1229
- return response
1249
+ throw :response, response
1230
1250
  end
1231
1251
  rescue ::GRPC::BadStatus => e
1232
1252
  raise ::Google::Cloud::Error.from_error(e)
@@ -1347,7 +1367,7 @@ module Google
1347
1367
  @backup_dr_stub.call_rpc :delete_backup_vault, request, options: options do |response, operation|
1348
1368
  response = ::Gapic::Operation.new response, @operations_client, options: options
1349
1369
  yield response, operation if block_given?
1350
- return response
1370
+ throw :response, response
1351
1371
  end
1352
1372
  rescue ::GRPC::BadStatus => e
1353
1373
  raise ::Google::Cloud::Error.from_error(e)
@@ -1452,7 +1472,7 @@ module Google
1452
1472
  @backup_dr_stub.call_rpc :list_data_sources, request, options: options do |response, operation|
1453
1473
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_data_sources, request, response, operation, options
1454
1474
  yield response, operation if block_given?
1455
- return response
1475
+ throw :response, response
1456
1476
  end
1457
1477
  rescue ::GRPC::BadStatus => e
1458
1478
  raise ::Google::Cloud::Error.from_error(e)
@@ -1539,7 +1559,6 @@ module Google
1539
1559
 
1540
1560
  @backup_dr_stub.call_rpc :get_data_source, request, options: options do |response, operation|
1541
1561
  yield response, operation if block_given?
1542
- return response
1543
1562
  end
1544
1563
  rescue ::GRPC::BadStatus => e
1545
1564
  raise ::Google::Cloud::Error.from_error(e)
@@ -1655,7 +1674,7 @@ module Google
1655
1674
  @backup_dr_stub.call_rpc :update_data_source, request, options: options do |response, operation|
1656
1675
  response = ::Gapic::Operation.new response, @operations_client, options: options
1657
1676
  yield response, operation if block_given?
1658
- return response
1677
+ throw :response, response
1659
1678
  end
1660
1679
  rescue ::GRPC::BadStatus => e
1661
1680
  raise ::Google::Cloud::Error.from_error(e)
@@ -1763,7 +1782,7 @@ module Google
1763
1782
  @backup_dr_stub.call_rpc :list_backups, request, options: options do |response, operation|
1764
1783
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_backups, request, response, operation, options
1765
1784
  yield response, operation if block_given?
1766
- return response
1785
+ throw :response, response
1767
1786
  end
1768
1787
  rescue ::GRPC::BadStatus => e
1769
1788
  raise ::Google::Cloud::Error.from_error(e)
@@ -1853,7 +1872,6 @@ module Google
1853
1872
 
1854
1873
  @backup_dr_stub.call_rpc :get_backup, request, options: options do |response, operation|
1855
1874
  yield response, operation if block_given?
1856
- return response
1857
1875
  end
1858
1876
  rescue ::GRPC::BadStatus => e
1859
1877
  raise ::Google::Cloud::Error.from_error(e)
@@ -1967,7 +1985,7 @@ module Google
1967
1985
  @backup_dr_stub.call_rpc :update_backup, request, options: options do |response, operation|
1968
1986
  response = ::Gapic::Operation.new response, @operations_client, options: options
1969
1987
  yield response, operation if block_given?
1970
- return response
1988
+ throw :response, response
1971
1989
  end
1972
1990
  rescue ::GRPC::BadStatus => e
1973
1991
  raise ::Google::Cloud::Error.from_error(e)
@@ -2075,7 +2093,7 @@ module Google
2075
2093
  @backup_dr_stub.call_rpc :delete_backup, request, options: options do |response, operation|
2076
2094
  response = ::Gapic::Operation.new response, @operations_client, options: options
2077
2095
  yield response, operation if block_given?
2078
- return response
2096
+ throw :response, response
2079
2097
  end
2080
2098
  rescue ::GRPC::BadStatus => e
2081
2099
  raise ::Google::Cloud::Error.from_error(e)
@@ -2188,7 +2206,7 @@ module Google
2188
2206
  @backup_dr_stub.call_rpc :restore_backup, request, options: options do |response, operation|
2189
2207
  response = ::Gapic::Operation.new response, @operations_client, options: options
2190
2208
  yield response, operation if block_given?
2191
- return response
2209
+ throw :response, response
2192
2210
  end
2193
2211
  rescue ::GRPC::BadStatus => e
2194
2212
  raise ::Google::Cloud::Error.from_error(e)
@@ -2305,7 +2323,7 @@ module Google
2305
2323
  @backup_dr_stub.call_rpc :create_backup_plan, request, options: options do |response, operation|
2306
2324
  response = ::Gapic::Operation.new response, @operations_client, options: options
2307
2325
  yield response, operation if block_given?
2308
- return response
2326
+ throw :response, response
2309
2327
  end
2310
2328
  rescue ::GRPC::BadStatus => e
2311
2329
  raise ::Google::Cloud::Error.from_error(e)
@@ -2393,7 +2411,6 @@ module Google
2393
2411
 
2394
2412
  @backup_dr_stub.call_rpc :get_backup_plan, request, options: options do |response, operation|
2395
2413
  yield response, operation if block_given?
2396
- return response
2397
2414
  end
2398
2415
  rescue ::GRPC::BadStatus => e
2399
2416
  raise ::Google::Cloud::Error.from_error(e)
@@ -2506,7 +2523,7 @@ module Google
2506
2523
  @backup_dr_stub.call_rpc :list_backup_plans, request, options: options do |response, operation|
2507
2524
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_backup_plans, request, response, operation, options
2508
2525
  yield response, operation if block_given?
2509
- return response
2526
+ throw :response, response
2510
2527
  end
2511
2528
  rescue ::GRPC::BadStatus => e
2512
2529
  raise ::Google::Cloud::Error.from_error(e)
@@ -2616,7 +2633,7 @@ module Google
2616
2633
  @backup_dr_stub.call_rpc :delete_backup_plan, request, options: options do |response, operation|
2617
2634
  response = ::Gapic::Operation.new response, @operations_client, options: options
2618
2635
  yield response, operation if block_given?
2619
- return response
2636
+ throw :response, response
2620
2637
  end
2621
2638
  rescue ::GRPC::BadStatus => e
2622
2639
  raise ::Google::Cloud::Error.from_error(e)
@@ -2731,7 +2748,7 @@ module Google
2731
2748
  @backup_dr_stub.call_rpc :create_backup_plan_association, request, options: options do |response, operation|
2732
2749
  response = ::Gapic::Operation.new response, @operations_client, options: options
2733
2750
  yield response, operation if block_given?
2734
- return response
2751
+ throw :response, response
2735
2752
  end
2736
2753
  rescue ::GRPC::BadStatus => e
2737
2754
  raise ::Google::Cloud::Error.from_error(e)
@@ -2818,7 +2835,6 @@ module Google
2818
2835
 
2819
2836
  @backup_dr_stub.call_rpc :get_backup_plan_association, request, options: options do |response, operation|
2820
2837
  yield response, operation if block_given?
2821
- return response
2822
2838
  end
2823
2839
  rescue ::GRPC::BadStatus => e
2824
2840
  raise ::Google::Cloud::Error.from_error(e)
@@ -2921,7 +2937,7 @@ module Google
2921
2937
  @backup_dr_stub.call_rpc :list_backup_plan_associations, request, options: options do |response, operation|
2922
2938
  response = ::Gapic::PagedEnumerable.new @backup_dr_stub, :list_backup_plan_associations, request, response, operation, options
2923
2939
  yield response, operation if block_given?
2924
- return response
2940
+ throw :response, response
2925
2941
  end
2926
2942
  rescue ::GRPC::BadStatus => e
2927
2943
  raise ::Google::Cloud::Error.from_error(e)
@@ -3030,7 +3046,7 @@ module Google
3030
3046
  @backup_dr_stub.call_rpc :delete_backup_plan_association, request, options: options do |response, operation|
3031
3047
  response = ::Gapic::Operation.new response, @operations_client, options: options
3032
3048
  yield response, operation if block_given?
3033
- return response
3049
+ throw :response, response
3034
3050
  end
3035
3051
  rescue ::GRPC::BadStatus => e
3036
3052
  raise ::Google::Cloud::Error.from_error(e)
@@ -3141,7 +3157,7 @@ module Google
3141
3157
  @backup_dr_stub.call_rpc :trigger_backup, request, options: options do |response, operation|
3142
3158
  response = ::Gapic::Operation.new response, @operations_client, options: options
3143
3159
  yield response, operation if block_given?
3144
- return response
3160
+ throw :response, response
3145
3161
  end
3146
3162
  rescue ::GRPC::BadStatus => e
3147
3163
  raise ::Google::Cloud::Error.from_error(e)
@@ -3230,6 +3246,11 @@ module Google
3230
3246
  # default endpoint URL. The default value of nil uses the environment
3231
3247
  # universe (usually the default "googleapis.com" universe).
3232
3248
  # @return [::String,nil]
3249
+ # @!attribute [rw] logger
3250
+ # A custom logger to use for request/response debug logging, or the value
3251
+ # `:default` (the default) to construct a default logger, or `nil` to
3252
+ # explicitly disable logging.
3253
+ # @return [::Logger,:default,nil]
3233
3254
  #
3234
3255
  class Configuration
3235
3256
  extend ::Gapic::Config
@@ -3254,6 +3275,7 @@ module Google
3254
3275
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3255
3276
  config_attr :quota_project, nil, ::String, nil
3256
3277
  config_attr :universe_domain, nil, ::String, nil
3278
+ config_attr :logger, :default, ::Logger, nil, :default
3257
3279
 
3258
3280
  # @private
3259
3281
  def initialize parent_config = nil
@@ -213,7 +213,7 @@ module Google
213
213
  wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
214
214
  response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
215
215
  yield response, operation if block_given?
216
- return response
216
+ throw :response, response
217
217
  end
218
218
  rescue ::GRPC::BadStatus => e
219
219
  raise ::Google::Cloud::Error.from_error(e)
@@ -309,7 +309,7 @@ module Google
309
309
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
310
310
  response = ::Gapic::Operation.new response, @operations_client, options: options
311
311
  yield response, operation if block_given?
312
- return response
312
+ throw :response, response
313
313
  end
314
314
  rescue ::GRPC::BadStatus => e
315
315
  raise ::Google::Cloud::Error.from_error(e)
@@ -398,7 +398,6 @@ module Google
398
398
 
399
399
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
400
400
  yield response, operation if block_given?
401
- return response
402
401
  end
403
402
  rescue ::GRPC::BadStatus => e
404
403
  raise ::Google::Cloud::Error.from_error(e)
@@ -494,7 +493,6 @@ module Google
494
493
 
495
494
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
496
495
  yield response, operation if block_given?
497
- return response
498
496
  end
499
497
  rescue ::GRPC::BadStatus => e
500
498
  raise ::Google::Cloud::Error.from_error(e)
@@ -592,7 +590,7 @@ module Google
592
590
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
593
591
  response = ::Gapic::Operation.new response, @operations_client, options: options
594
592
  yield response, operation if block_given?
595
- return response
593
+ throw :response, response
596
594
  end
597
595
  rescue ::GRPC::BadStatus => e
598
596
  raise ::Google::Cloud::Error.from_error(e)
@@ -681,6 +679,11 @@ module Google
681
679
  # default endpoint URL. The default value of nil uses the environment
682
680
  # universe (usually the default "googleapis.com" universe).
683
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]
684
687
  #
685
688
  class Configuration
686
689
  extend ::Gapic::Config
@@ -705,6 +708,7 @@ module Google
705
708
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
706
709
  config_attr :quota_project, nil, ::String, nil
707
710
  config_attr :universe_domain, nil, ::String, nil
711
+ config_attr :logger, :default, ::Logger, nil, :default
708
712
 
709
713
  # @private
710
714
  def initialize parent_config = nil