google-cloud-os_config-v1 1.0.1 → 1.1.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: f3b2df2aa0dd2bf4ceb2ce238b0cd0ee06098face3d6f1d473d0265afb789410
4
- data.tar.gz: bdc4e908425e72e5d4c7d5f0e33cd3ec94924046e38a8d06c66a6466dd6bafcd
3
+ metadata.gz: 9ca8ac4f1a960275f76e6fb1bc1a5deddc255e16e40e4389212f6919428b1a92
4
+ data.tar.gz: c667c5ed89740d81f478fa8e85f60f58eff622b1a75030a69137e5ef1eecc887
5
5
  SHA512:
6
- metadata.gz: 8c25d99f5b1c5dd8d2da9c55ec64124d19a768c36aeab06ca49e31935cecc40b62694455f187556263506b1e452cc97a1c33f59671df2d65eb53f17429b6bf67
7
- data.tar.gz: 93af9980d22db0d2b6fa4df512269c6c3c1192965ad04704d6a1a3a51ba362c339d6a87a0e629b53d312a8c1a69077d3ce505ccaf2d1a0dce1e2e3f1721dde9d
6
+ metadata.gz: 573b9c7dd4660487455940786fc4dd11af8232a3ad2f91830281130d8dc85bbb802b583ea0f8a6deaaaecfb76f27fe870ff2cea621452201c234da79155c468d
7
+ data.tar.gz: a0e7a6765db87af6c6bc61dfacec9db22fe10c0f880a25e04f43f2b459aabeafbc64cbaf7bacedbf616b268d5cfc0936173ce49b2c115dca153765eb76e0fadf
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/compute/docs/manage-os)
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/os_config/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::OsConfig::V1::OsConfigService::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).
@@ -165,8 +165,28 @@ module Google
165
165
  universe_domain: @config.universe_domain,
166
166
  channel_args: @config.channel_args,
167
167
  interceptors: @config.interceptors,
168
- channel_pool_config: @config.channel_pool
168
+ channel_pool_config: @config.channel_pool,
169
+ logger: @config.logger
169
170
  )
171
+
172
+ @os_config_service_stub.stub_logger&.info do |entry|
173
+ entry.set_system_name
174
+ entry.set_service
175
+ entry.message = "Created client for #{entry.service}"
176
+ entry.set_credentials_fields credentials
177
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
178
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
179
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
180
+ end
181
+ end
182
+
183
+ ##
184
+ # The logger used for request/response debug logging.
185
+ #
186
+ # @return [Logger]
187
+ #
188
+ def logger
189
+ @os_config_service_stub.logger
170
190
  end
171
191
 
172
192
  # Service calls
@@ -270,7 +290,6 @@ module Google
270
290
 
271
291
  @os_config_service_stub.call_rpc :execute_patch_job, request, options: options do |response, operation|
272
292
  yield response, operation if block_given?
273
- return response
274
293
  end
275
294
  rescue ::GRPC::BadStatus => e
276
295
  raise ::Google::Cloud::Error.from_error(e)
@@ -357,7 +376,6 @@ module Google
357
376
 
358
377
  @os_config_service_stub.call_rpc :get_patch_job, request, options: options do |response, operation|
359
378
  yield response, operation if block_given?
360
- return response
361
379
  end
362
380
  rescue ::GRPC::BadStatus => e
363
381
  raise ::Google::Cloud::Error.from_error(e)
@@ -444,7 +462,6 @@ module Google
444
462
 
445
463
  @os_config_service_stub.call_rpc :cancel_patch_job, request, options: options do |response, operation|
446
464
  yield response, operation if block_given?
447
- return response
448
465
  end
449
466
  rescue ::GRPC::BadStatus => e
450
467
  raise ::Google::Cloud::Error.from_error(e)
@@ -544,7 +561,7 @@ module Google
544
561
  @os_config_service_stub.call_rpc :list_patch_jobs, request, options: options do |response, operation|
545
562
  response = ::Gapic::PagedEnumerable.new @os_config_service_stub, :list_patch_jobs, request, response, operation, options
546
563
  yield response, operation if block_given?
547
- return response
564
+ throw :response, response
548
565
  end
549
566
  rescue ::GRPC::BadStatus => e
550
567
  raise ::Google::Cloud::Error.from_error(e)
@@ -645,7 +662,7 @@ module Google
645
662
  @os_config_service_stub.call_rpc :list_patch_job_instance_details, request, options: options do |response, operation|
646
663
  response = ::Gapic::PagedEnumerable.new @os_config_service_stub, :list_patch_job_instance_details, request, response, operation, options
647
664
  yield response, operation if block_given?
648
- return response
665
+ throw :response, response
649
666
  end
650
667
  rescue ::GRPC::BadStatus => e
651
668
  raise ::Google::Cloud::Error.from_error(e)
@@ -742,7 +759,6 @@ module Google
742
759
 
743
760
  @os_config_service_stub.call_rpc :create_patch_deployment, request, options: options do |response, operation|
744
761
  yield response, operation if block_given?
745
- return response
746
762
  end
747
763
  rescue ::GRPC::BadStatus => e
748
764
  raise ::Google::Cloud::Error.from_error(e)
@@ -829,7 +845,6 @@ module Google
829
845
 
830
846
  @os_config_service_stub.call_rpc :get_patch_deployment, request, options: options do |response, operation|
831
847
  yield response, operation if block_given?
832
- return response
833
848
  end
834
849
  rescue ::GRPC::BadStatus => e
835
850
  raise ::Google::Cloud::Error.from_error(e)
@@ -927,7 +942,7 @@ module Google
927
942
  @os_config_service_stub.call_rpc :list_patch_deployments, request, options: options do |response, operation|
928
943
  response = ::Gapic::PagedEnumerable.new @os_config_service_stub, :list_patch_deployments, request, response, operation, options
929
944
  yield response, operation if block_given?
930
- return response
945
+ throw :response, response
931
946
  end
932
947
  rescue ::GRPC::BadStatus => e
933
948
  raise ::Google::Cloud::Error.from_error(e)
@@ -1014,7 +1029,6 @@ module Google
1014
1029
 
1015
1030
  @os_config_service_stub.call_rpc :delete_patch_deployment, request, options: options do |response, operation|
1016
1031
  yield response, operation if block_given?
1017
- return response
1018
1032
  end
1019
1033
  rescue ::GRPC::BadStatus => e
1020
1034
  raise ::Google::Cloud::Error.from_error(e)
@@ -1103,7 +1117,6 @@ module Google
1103
1117
 
1104
1118
  @os_config_service_stub.call_rpc :update_patch_deployment, request, options: options do |response, operation|
1105
1119
  yield response, operation if block_given?
1106
- return response
1107
1120
  end
1108
1121
  rescue ::GRPC::BadStatus => e
1109
1122
  raise ::Google::Cloud::Error.from_error(e)
@@ -1191,7 +1204,6 @@ module Google
1191
1204
 
1192
1205
  @os_config_service_stub.call_rpc :pause_patch_deployment, request, options: options do |response, operation|
1193
1206
  yield response, operation if block_given?
1194
- return response
1195
1207
  end
1196
1208
  rescue ::GRPC::BadStatus => e
1197
1209
  raise ::Google::Cloud::Error.from_error(e)
@@ -1279,7 +1291,6 @@ module Google
1279
1291
 
1280
1292
  @os_config_service_stub.call_rpc :resume_patch_deployment, request, options: options do |response, operation|
1281
1293
  yield response, operation if block_given?
1282
- return response
1283
1294
  end
1284
1295
  rescue ::GRPC::BadStatus => e
1285
1296
  raise ::Google::Cloud::Error.from_error(e)
@@ -1368,6 +1379,11 @@ module Google
1368
1379
  # default endpoint URL. The default value of nil uses the environment
1369
1380
  # universe (usually the default "googleapis.com" universe).
1370
1381
  # @return [::String,nil]
1382
+ # @!attribute [rw] logger
1383
+ # A custom logger to use for request/response debug logging, or the value
1384
+ # `:default` (the default) to construct a default logger, or `nil` to
1385
+ # explicitly disable logging.
1386
+ # @return [::Logger,:default,nil]
1371
1387
  #
1372
1388
  class Configuration
1373
1389
  extend ::Gapic::Config
@@ -1392,6 +1408,7 @@ module Google
1392
1408
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1393
1409
  config_attr :quota_project, nil, ::String, nil
1394
1410
  config_attr :universe_domain, nil, ::String, nil
1411
+ config_attr :logger, :default, ::Logger, nil, :default
1395
1412
 
1396
1413
  # @private
1397
1414
  def initialize parent_config = nil
@@ -158,8 +158,28 @@ module Google
158
158
  endpoint: @config.endpoint,
159
159
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
160
160
  universe_domain: @config.universe_domain,
161
- credentials: credentials
161
+ credentials: credentials,
162
+ logger: @config.logger
162
163
  )
164
+
165
+ @os_config_service_stub.logger(stub: true)&.info do |entry|
166
+ entry.set_system_name
167
+ entry.set_service
168
+ entry.message = "Created client for #{entry.service}"
169
+ entry.set_credentials_fields credentials
170
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
171
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
172
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
173
+ end
174
+ end
175
+
176
+ ##
177
+ # The logger used for request/response debug logging.
178
+ #
179
+ # @return [Logger]
180
+ #
181
+ def logger
182
+ @os_config_service_stub.logger
163
183
  end
164
184
 
165
185
  # Service calls
@@ -256,7 +276,6 @@ module Google
256
276
 
257
277
  @os_config_service_stub.execute_patch_job request, options do |result, operation|
258
278
  yield result, operation if block_given?
259
- return result
260
279
  end
261
280
  rescue ::Gapic::Rest::Error => e
262
281
  raise ::Google::Cloud::Error.from_error(e)
@@ -336,7 +355,6 @@ module Google
336
355
 
337
356
  @os_config_service_stub.get_patch_job request, options do |result, operation|
338
357
  yield result, operation if block_given?
339
- return result
340
358
  end
341
359
  rescue ::Gapic::Rest::Error => e
342
360
  raise ::Google::Cloud::Error.from_error(e)
@@ -416,7 +434,6 @@ module Google
416
434
 
417
435
  @os_config_service_stub.cancel_patch_job request, options do |result, operation|
418
436
  yield result, operation if block_given?
419
- return result
420
437
  end
421
438
  rescue ::Gapic::Rest::Error => e
422
439
  raise ::Google::Cloud::Error.from_error(e)
@@ -509,7 +526,7 @@ module Google
509
526
  @os_config_service_stub.list_patch_jobs request, options do |result, operation|
510
527
  result = ::Gapic::Rest::PagedEnumerable.new @os_config_service_stub, :list_patch_jobs, "patch_jobs", request, result, options
511
528
  yield result, operation if block_given?
512
- return result
529
+ throw :response, result
513
530
  end
514
531
  rescue ::Gapic::Rest::Error => e
515
532
  raise ::Google::Cloud::Error.from_error(e)
@@ -603,7 +620,7 @@ module Google
603
620
  @os_config_service_stub.list_patch_job_instance_details request, options do |result, operation|
604
621
  result = ::Gapic::Rest::PagedEnumerable.new @os_config_service_stub, :list_patch_job_instance_details, "patch_job_instance_details", request, result, options
605
622
  yield result, operation if block_given?
606
- return result
623
+ throw :response, result
607
624
  end
608
625
  rescue ::Gapic::Rest::Error => e
609
626
  raise ::Google::Cloud::Error.from_error(e)
@@ -693,7 +710,6 @@ module Google
693
710
 
694
711
  @os_config_service_stub.create_patch_deployment request, options do |result, operation|
695
712
  yield result, operation if block_given?
696
- return result
697
713
  end
698
714
  rescue ::Gapic::Rest::Error => e
699
715
  raise ::Google::Cloud::Error.from_error(e)
@@ -773,7 +789,6 @@ module Google
773
789
 
774
790
  @os_config_service_stub.get_patch_deployment request, options do |result, operation|
775
791
  yield result, operation if block_given?
776
- return result
777
792
  end
778
793
  rescue ::Gapic::Rest::Error => e
779
794
  raise ::Google::Cloud::Error.from_error(e)
@@ -864,7 +879,7 @@ module Google
864
879
  @os_config_service_stub.list_patch_deployments request, options do |result, operation|
865
880
  result = ::Gapic::Rest::PagedEnumerable.new @os_config_service_stub, :list_patch_deployments, "patch_deployments", request, result, options
866
881
  yield result, operation if block_given?
867
- return result
882
+ throw :response, result
868
883
  end
869
884
  rescue ::Gapic::Rest::Error => e
870
885
  raise ::Google::Cloud::Error.from_error(e)
@@ -944,7 +959,6 @@ module Google
944
959
 
945
960
  @os_config_service_stub.delete_patch_deployment request, options do |result, operation|
946
961
  yield result, operation if block_given?
947
- return result
948
962
  end
949
963
  rescue ::Gapic::Rest::Error => e
950
964
  raise ::Google::Cloud::Error.from_error(e)
@@ -1026,7 +1040,6 @@ module Google
1026
1040
 
1027
1041
  @os_config_service_stub.update_patch_deployment request, options do |result, operation|
1028
1042
  yield result, operation if block_given?
1029
- return result
1030
1043
  end
1031
1044
  rescue ::Gapic::Rest::Error => e
1032
1045
  raise ::Google::Cloud::Error.from_error(e)
@@ -1107,7 +1120,6 @@ module Google
1107
1120
 
1108
1121
  @os_config_service_stub.pause_patch_deployment request, options do |result, operation|
1109
1122
  yield result, operation if block_given?
1110
- return result
1111
1123
  end
1112
1124
  rescue ::Gapic::Rest::Error => e
1113
1125
  raise ::Google::Cloud::Error.from_error(e)
@@ -1188,7 +1200,6 @@ module Google
1188
1200
 
1189
1201
  @os_config_service_stub.resume_patch_deployment request, options do |result, operation|
1190
1202
  yield result, operation if block_given?
1191
- return result
1192
1203
  end
1193
1204
  rescue ::Gapic::Rest::Error => e
1194
1205
  raise ::Google::Cloud::Error.from_error(e)
@@ -1268,6 +1279,11 @@ module Google
1268
1279
  # default endpoint URL. The default value of nil uses the environment
1269
1280
  # universe (usually the default "googleapis.com" universe).
1270
1281
  # @return [::String,nil]
1282
+ # @!attribute [rw] logger
1283
+ # A custom logger to use for request/response debug logging, or the value
1284
+ # `:default` (the default) to construct a default logger, or `nil` to
1285
+ # explicitly disable logging.
1286
+ # @return [::Logger,:default,nil]
1271
1287
  #
1272
1288
  class Configuration
1273
1289
  extend ::Gapic::Config
@@ -1289,6 +1305,7 @@ module Google
1289
1305
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1290
1306
  config_attr :quota_project, nil, ::String, nil
1291
1307
  config_attr :universe_domain, nil, ::String, nil
1308
+ config_attr :logger, :default, ::Logger, nil, :default
1292
1309
 
1293
1310
  # @private
1294
1311
  def initialize parent_config = nil